GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Design doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Design doubt" Watch "Design doubt" New topic
Author

Design doubt

Kushmakar Sharma
Greenhorn

Joined: Apr 22, 2010
Posts: 2
Hi,

I am a beginner in Java and have started reading Head First Java by O'Reilly publication. Though I am able to understand most of the concepts of OOP and how they are implemented in Java, one question that has me perplexed is: How do we decide the number of classes a particular application will need? In the book there is an example of a Dot Com Bust game in which 3 different classes are created. One is the GameHelper class, another is the DotCom Class and the third one is DotComBust class. What factors decide how many classes are we gonna have in the application?

Regards,
Kush
manoj r patil
Ranch Hand

Joined: Jun 06, 2002
Posts: 181
Are you really understood OOP or you need to revisit the basic concepts?

You question sounds to me like "someone is asking as how many tables one application should have in its DB model?" and the answer is it totally depends on the architect and there is a famous quote, "No design is wrong!" ...but any design can be improved further considering different aspects


love your job and not your company;
...because you never know when your company will stop loving you!
Kushmakar Sharma
Greenhorn

Joined: Apr 22, 2010
Posts: 2
Hi Manoj,

Thanks for the reply. I understand that an architect decides the number of classes to be coded. But what are some of the design considerations that an architect keeps in mind while doing so? To take your DB analogy, DBA might decide number of tables depending on the speed of data retrieval or the ease of access. What derives the number of classes - maintainability probably.. anything apart from that?

Thanks,
Kush
Colin Wright
Greenhorn

Joined: Apr 21, 2010
Posts: 8
There is no really good answer to this question, it depends on the application and there are no hard and fast rule.

In OOP, a class should represent a type of object in your application so the question is how many types of objects are their in your application. Classes should always try to work for themselves, and should work together to achieve the purpose of the application.

But there is more than one way to skin a cat so often two programmers given the same functional requirements might come up with a different set of classes.

In a way you question is meaningless, if you have understood OOP the question always needs to be answered for the particular application requirements and is more a set of questions asking yourself should this be an object repeatedly?

 
GeeCON Prague 2014
 
subject: Design doubt