• Post Reply Bookmark Topic Watch Topic
  • New Topic

identification of the class by nature of the problem  RSS feed

 
lalit khera
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys.

Please let me know, how to identify the classes/objects/methods for a given problem.
For example:
Considering an application for bank application which needs basic operations like deposit, withdraw, calculating simple interest.
Now how to identify which classes are to be declared assuming we have 3 kinds of account type, a,b,c
Now we write 3 classes for each account type or 1 class with methods overloaded for all 3 types or anything else.
please reply soon.

I am reffering head first java.

thanks

 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lalit khera wrote:Please let me know, how to identify the classes/objects/methods for a given problem.

The old maxim in my days was: "things, actions and events"; and I'd add "but mostly things".

One way is to start with an accurate and concise description of the requirements of the application and do a lexical analysis of it (ie, give it a good read; probably 3 or 4 times at least), noting down:
1. The nouns; especially proper nouns.
2. The verbs.

The first list will usually be a good source of class names, the second for methods; but some "actions" may be large enough to qualify as business processes, and may warrant a class of their own (unfortunately, working out that sort of stuff only comes with practise ). Also, don't forget that some "events" (these are usually actions based on a time, rather than something done interactively, eg: month-end, bank charges) may also qualify as classes in their own right.

And then, in the spirit of breaking down problems, do the same thing with each sizeable "class" you get from the first cut.

It's very basic, but it may give you a kick-start.

Winston
 
lalit khera
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
lalit khera wrote:Please let me know, how to identify the classes/objects/methods for a given problem.

The old maxim in my days was: "things, actions and events"; and I'd add "but mostly things".

One way is to start with an accurate and concise description of the requirements of the application and do a lexical analysis of it (ie, give it a good read; probably 3 or 4 times at least), noting down:
1. The nouns; especially proper nouns.
2. The verbs.

The first list will usually be a good source of class names, the second for methods; but some "actions" may be large enough to qualify as business processes, and may warrant a class of their own (unfortunately, working out that sort of stuff only comes with practise ). Also, don't forget that some "events" (these are usually actions based on a time, rather than something done interactively, eg: month-end, bank charges) may also qualify as classes in their own right.

And then, in the spirit of breaking down problems, do the same thing with each sizeable "class" you get from the first cut.

It's very basic, but it may give you a kick-start.

Winston



Thanks winston
now i got how to move. yes its kick start for me.
Can you provide me some good links for the case studies for the practice purpose for the identification of the potential classes required.
Solved problems can be appreciated. it may or may not contain the source code but a sort of uml diagram which helps identfying the classes and methods.

thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!