OOP Analysis

A Designer is provided with the following statement of requirements by their customer, amongst a larger set of requirements :

The company has multiple warehouses, and each has location (street address) and a manager. Each product has a bar-code and products can be stored in a warehouse, removed from a warehouse or transferred between warehouses. Each product has a specific location (floor/shelf) within each warehouse.

Based on this single statement, which of the following describes a reasonable initial design :

  1. There is a location class with a warehouse and manager fields which has a transfer method. There is a bar-code class with a product field. The bar-code class has a store and remove method.
  2. There is a product class with a bar-code field. There is a warehouse class with location and manager fields and store, remove and transfer methods.
  3. There are no obvious classes, methods or data fields that can be derived from that statement.
  4. There are store, remove and transfer classes. Each of these classes have warehouse and product fields.
3 4 1 2

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Tony Flury
Sep 19, 2015

The best way to do at least a first pass on OOP Analysis is to scan through the sentences and underline the words and double underline the verbs. Nouns are candidates for your object classes, and the verbs are candidates for methods.

In our example then we have many nouns (warehouse, bar-code, address), so you now need to asses whether one noun represents something that is related to one of the other nouns - for instance a bar-code is related to a product, and an address is related to a warehouse, and there is no direct relationship between a bar-code and a warehouse (for instance). You can probably write these relationships in terms of :

  • A has a B :
  • A product has a bar-code
  • A warehouse has an address
  • A warehouse has a manager

When you have all of the relationships written down, the nouns on the left side are good candidate for classes and those on the right side are good candidates for attributes or properties of the noun on the left hand side.

With your list of verbs/methods - look at your sentences to see which nouns those verbs act on - that will give you a clue as to which classes these methods apply to. Don't stop with just one sentence - go through each sentence, work out the best class/attribute/method design that will satisfy your requirements.

It is very rare that there is only one right design.

I agree with your logic but I think number 2 is bad design. Storage and transfer methods are typically product dependent not warehouse dependent. It makes sense to have storage locations within the Warehouse class but not the storage method of each product, otherwise every new product item with a new storage method would require each warehouse database to be updated versus assigning the method to the product itself. So the correct answer is still bad design.

Bhekinkosi Ncube - 5 years, 8 months ago

Log in to reply

Which is why I said it was a reasonable initial design given that sentence only. Other statements might well have clarified the design to the point that the initial design is changed. I agree that the answer is not a good design - but the first design rarely is.

Tony Flury - 5 years, 8 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...