• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

IBM - eStore.com

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a question from IBM pre-assessment exam:
eStore.com sells small appliances over the Internet. Currently, the store's catalog includes over 50 appliances from 10 different suppliers. A partial class diagram is shown in Figure Sample 1. There are two new requirements for eStore.com: discounts for damaged goods, and searches by size and color. Using Figure Sample 2, which of the following is the BEST way to extend the class diagram to handle these requirements? http://certify.torolab.ibm.com/figures/test486F20.gif
a) No changes are needed due to these requirements.
b) Create a new class "PhysicalProduct" that represents an actual product in the warehouse. Associate the PhysicalProduct with its related InventoryProduct.
c) Add new capabilities to the Inventory class for the management of its Products.
d) Extend the InventoryProduct class to handle the new requirements.
My answere b. My reason is that isDamaged() should be a feature of a physical product. Any other opinion?
[This message has been edited by Caroline Iux (edited May 20, 2001).]
 
Marshal
Posts: 15887
265
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say the best answer would be B, too.
Junilu
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same answer, same reason.
 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would lean towards D.
Reasons

  1. It is better not to assume the type of Product (brittle, physical ,etc.).Let's provide these methods/attributes in the more generic class -InventoryProduct to allow greater flexibility in the future.
  2. Since the nature of the goods is not specified, there is not enough justification that the new requirement is for PhysicalProduct only - May be for other goods also - who knows - Hence providing these features in would-be super class seems better.

  3. Hope this helps,
    Sandeep
    [This message has been edited by Desai Sandeep (edited May 21, 2001).]
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would also go for option D. It is difficult to understand why an additional class 'Physical Products'is required when 'Inventory Products' can do the job. The way I understand 'Inventory Products' is a software class for the products sold by estore and hence should be the class with the responsibility for determining if it is damaged and hold size and color attributes
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a typical situation for the visitor pattern, which handles when a new functionality is needed. The solution is to create a new class/object for the new functionality. So the answer is B.
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Laojar,
How would you say that the new class would be a "PhysicalProduct" not a "BrittleProduct" from the question?It is not possible to classify the "InventoryProduct" given the problem.Hence I will settle for D.
-- Sandeep
[This message has been edited by Desai Sandeep (edited May 22, 2001).]
 
Caroline Iux
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note InventoryProduct has an attribute of amountOnHand, which implies InventroryProduct is a generic class for a type of products. For example, it represents all blue size 12 Survivor T-shirts. So to add isDamaged() to InventoryProduct is not reasonable cause we need able to tell which T-shirts is damaged.
To extend InventoryProduct class means the subclass will have the amountOnHand attribute too, thus makes me think (D) is not correct.
My 2 cents.
[This message has been edited by Caroline Iux (edited May 23, 2001).]
 
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Caroline: My reason exactly; you beat me to it.
Desai: How could a product that is not a physical product be damaged? It could be a BrittleProduct, but that is not one of the options given. Furthermore, BrittleProduct would just be a subtype of PhysicalProduct.
So, with those two thoughts in mind, my answer is definitely B.
Paul R
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would suggest to consider this problem on "as-is" basis.Any Inventory Product could be damaged.The isDamaged() method could be interpreted in a more generic term - inferior quality products.
We can have isDamaged() method in the super class and can override this method in any of the future sub-classes.This would allow more flexibility in the future.
If the subclass represents a T-shirt, I will find out if it is torn in my sub class.If it is, I will return true from the subclass isDamaged() method, suggesting that T-shirt is actually damaged and is not of production quality.
We may have the internal representation (attribute) of the sub class as per requirements of the class, but one common behaviour across relatively similar classes (all of them would be InventoryProducts) would ensure the methods are kept in manageable proportions.
Hope this helps,
Sandeep
Infact, I would have liked the examiner give one more option on this, i.e. isDamaged() in the Purchasable interface.This is a responsibility which all InventoryProducts have to implement.The Inventory would consider the InventoryProduct, if and only if isDamaged is false.All the subclasses - Physical,Brittle,T-shirts, etc. would polymorphically override this method to determine the quality of the product.
Thanks,
Sandeep
Added reasoning for another possible option which I consider relevant in this case - isDamaged() method in the Purchasable interface.
[This message has been edited by Desai Sandeep (edited June 03, 2001).]
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please let me know your views on my post above.My answer is D.
Thanks,
Sandeep
[This message has been edited by Desai Sandeep (edited June 03, 2001).]
 
Caroline Iux
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone who got 100% on pre-assessment exam? Desai? Maybe you are sure about the answer now. I am trying to update the list of IBM questions with answers.
Thanks!
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Caroline,
You guessed it right.I have scored 100% in the pre-assessment test.Infact, I had planned to post the correct answers with analysis for all the questions of the pre-assessment test after passing Test 486.
Your earlier answer B for this question was correct .
I had given some thought on this question as to why B is correct.
The best way to tackle such questions (as well as likes of Student,Instructor ) is to think in terms of instances

  • Ask what are the instances of InventoryProduct - Cement,Kerosene,Shirts,Books,Crockery,etc.
  • Ask what are the instances of PhysicalProduct - Utensils,Crockery,etc.
  • Look at the instances and see if you can classify them as different types.If you can classify the instances as different types,then represent them as a subtype of your supertype.In this case we can say PhysicalProduct is infact a subtype of InventoryProduct due to following reasons:

    1. It has additional properties (like size and color) of interest.
    2. It has an additional operation (isDamaged()) of interest.
    3. Also,you can classify the instances into other subtypes like BrittleProducts(glass items),LiquidProducts(kerosene), etc., which may have disjoint attributes and operations from that specified in the PhysicalProduct subtype as well as InventoryProduct supertype.


    4. Also, as Larman suggests, we need to ask if these subtypes are valid or not.They are because, they satisfy:

      1. 100% conformance rule.The association of InventoryProduct with Inventory would also be valid for any of the subtypes of InventoryProduct, viz., PhysicalProduct,LiquidProduct,etc also.The amountOnHand attribute defined for InventoryProduct is also valid for any of the subtypes.
      2. is-a rule.We can say "PhysicalProduct is a kind of InventoryProduct" or "LiquidProduct is a kind of InventoryProduct"

      3. Hence, B is correct.
        But the most interesting thing is to analyse why D is incorrect?
        As Larman suggests, one of rule for creating a supertype should be of factoring the commonality (attributes and associations) of its subtypes.

        1. Ask "Are size and color common attributes of InventoryProduct which could be factored for all the subtypes?
        2. Ask "Is isDamaged() common operation for the InventoryProduct which could be factored for all the subtypes?

        3. The answer is "NO".How do I say that?Look at the instances.
          Is it correct to say:

          • Kerosene isDamaged(), or,
          • Cement has size, or,
          • Books have color.

          • All the above statments are incorrect.These attributes and operations are very much specific to a disjoint subtype of InventoryProduct ,i.e. PhysicalProduct.
            To reiterate, put only those attributes and operations in the supertype which are applicable to all its instances
            Hence D is not the correct answer.
            C is incorrect for a very obvious reason that the attributes (size and color) and operation(isDamaged()) belong to InventoryProduct types and not Inventory types.
            A is incorrect since we can say with the discussion above that changes are needed due to these requirements.
            Hope this helps,
            Sandeep
            [This message has been edited by Desai Sandeep (edited June 10, 2001).]
 
    Bookmark Topic Watch Topic
  • New Topic