How to identify classes
Hi All,
I am beginner to OOAD. Please guide me by specifying any easy steps or procedure available to identify classes from requirements.
Thanks in Advance.
Also please suggest me good books and online materials/tutorials on ooad topic.
Thanks & Regards,
Vasu
Try describing the problem in plain english (or your native language). Look at your description and note the "things" in it (subjects and objects in the sentences). Also note the actions that happend between these things (verbs).
For example:
Create a program that allows a customer at a bank to access information about his bank account. Requirements are that the customer should be able to check the current balance on his account and withdraw an amount of cash from his account as long as the amount does not exceed the current balance of the account. The balance in an account can never go below zero.
In this description, I note the following 'things':
Customer
Bank
Account
Amount (of cash)
Balance
The would be my initial candidate classes. Some may be modelled using basic types from Java, others using Java standard classes, and still others will require custom classes. In this simple case, I would probably implement Amount and Balance as floats in Java. The others would likely end up as custom classes.
I also note the following 'actions':
check the Balance (on an Account)
withdraw an Amount (from the Balance of an Account)
These actions can be translated into methods, of the class Account in this case. A partial implementation of the class Account would probably look something like this:public class Account {
private float balance;
// check the balance on the account
public void getBalance() {
return balance;
}
// withdraw an amount from the account balance
public void withdraw(float amount) {
if(balance >= amount) {
balance = balance - amount;
} else {
// report to user that there was insufficient balance
}
}
}
There are a number of tools which may be able to help you in various ways.I find using tools to see a call tree, remove methods and class which are not used, and tools to reverse engineer the "design" can be useful.
Hi...
As per RUP...
1)Is this candidate inside our system boundary?
If not, it might be an actor of our system.
2)Does this candidate have identifiable behavior for our problem domain?
(i.e., can we name the services/functions that are needed in our problem domain and that this candidate would own and provide?)
3)Does this candidate have identifiable structure?
(i.e., can we identify some set of data this candidate should own and manage?)
4)Does this candidate have relationships with any other candidates?
if all questions answer is YES then it's Class.
You can find out more information on
http://www-128.ibm.com/developerworks/rational/library/5383.html
thx
itcube.ians