SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Sahil Rally wrote:Problem : I want that client calls the getFilterType() method and i am able to return the types of enums i defined within the class. So that client is unaware of the number and can just iterate over the returned list and put .values over the returned items and gets the various values supported by each type of enum type defined within the class.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Sahil Rally wrote:With that i wanted to have retrieved list to be generalized enough so that client class code does not care whether it retrieved filters from Jeans or from Tshirt or from other. It all knows is to iterate over the retrieved list , put .values on each item and display it to the user.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Sahil Rally wrote:May be there is a better way to solve the above problem which i am unable to think of...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Sahil Rally wrote:Let me write what i have understood from your tips.
1) (Important one) Keep your Implementation thoughts away while you think of the possible elegant solution and design .
2) Tshirt entity should be represented by following classes in the project
A) Tshirt Pojo : Having member variables which stores its state.
B) Tshirt BluePrint class : Which contains Factory Method for Tshirt class and "Categories" such as "Neck Types" , "Colour" etc.
C) Tshirt BluePrint Class : It contains the public method for the client code : getFilters() which it has to override since it implements Filterable interface.
But there are 2 still things i will get confronted with again...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Sahil Rally wrote:1) Even if BluePrint class contains the categories, what is the best way to return the List of Enum types or may be something else (if you think of differently ), so that client code just iterate over the list and have all the Categories and sub-categories. By Category i mean NECK and by sub-category i mean POLO,ROUND etc...
For Client Code : the following code should work , no matter it is called on TShirt, Jeans or Trousers...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |