aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Modeling Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Modeling Classes" Watch "Modeling Classes" New topic
Author

Modeling Classes

shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
I have been through the Post by Tom Tees. It is very obvious that any Java coder who begins must have to go through this frustration of "Class Identification and Relationships among classes". I tried to follow the thumb rules of Object Oriented design and found myself in more confused state. OOSAD or Object Oriented System Analysis and Design Talks about Identifying classes through textaul Analysisin the following way.

Noun (which is part of the system) = Class
Attributes = class members
Behavior (associated) = method

Let us try with an example of Library Management System

1. Student enters the library
2. Student Select a book
3. Student shows his/her library card and Book to the Librarian
4. Librarian checks to see if the student is a defaulter else
5. Librarian issues the book to the Student

Problem 1 : Mostly in any User Specification all the nouns will become the classes - Student, Book, Librarian, LibraryCard and All verbs become methods - select, check, issue. where should we provide the select method. how do we identify to which class book selection is associated with. here are the ambiguities

"The Student selects" - so select method should be in Student class
"The Book is selected" - so the select method should be in Book class

"The Librarian checks " - so check method should be a part of Librarian class
"The Library card is checked" - so check method should be a part of LibraryCard class

"The Librarian issues" - so since issueing is performed by librarian it should be a part of Librarian class
"The book is issued" - so it should be a part of the Book Class

Problem 2 : Student, Librarian, Book, LibraryCard these are all Domain classes. But no where i could find the Service classes in the textual analysis like BookSelector Class instead i am having the book selection process in the Student Class as a method. does it happen this way that i need to create a BookSelector class that calls the methods on the Domain object like the domain object will have the functionality for selection of book and the Service class will call this method.

But what i know is that the functionality is stored in the service layer and the domain layer simpley has domain objects that have attributes and setter/getter.If this is the case then textual analysis goes wrong beauce what OOAD says that the process is a part of the identified class we dont identify Service classes in textual analysis. what is the way out?

Problem 3 : They say the we dont have classes for the Actors because actors are out of the system.In that case how are we going to store information about the student. How is the librarian going to search if a particular student has issued how many books?

Does the layered approach contradicts the Object oriented approach.






Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4240
    
    7

There are a few different issues in that post! Here's my (brief) take on them:
how do we identify to which class book selection is associated with

If you're following this sort of structured approach, my answer would be: you don't know yet. All you can really tell is that there is a relationship between Student and Book. Which classes have responsibility for different operations is a design decision, and that's going to depend on your use cases.

For example, how are you going to represent a book being selected? If your use cases tell you that you need to know who has selected a book, then the Book is likely to have a link to a Student, and the Book class will probably contain the operation. If the use cases require the link to be the other way round, you'd probably reverse this.

I would guess the book will probably later go on to dynamic modelling, which is where these sort of things get resolved.

But no where i could find the Service classes in the textual analysis like BookSelector

You start off producing a domain model, and these sort of classes shouldn't be present in a domain model. They're an implementation detail, and that comes later. At the analysis stage you're trying to understand what a system should do, not how it will do it.

But what i know is that the functionality is stored in the service layer and the domain layer simpley has domain objects that have attributes and setter/getter.

Ah, well. That's what's called an "anaemic domain model". It's considered good practice for a Service-Oriented architecture, but not for a OO architecture. Sounds like you're mixing tw0 approaches that aren't entirely compatible.

They say the we dont have classes for the Actors because actors are out of the system.In that case how are we going to store information about the student.

Well, if there's a need to store information about them, then you can say they're within the system. In this case you definitely need a Student class because you need to know things about them. But some Actors are clearly outside.

Does the layered approach contradicts the Object oriented approach.

Not necessarily (depending on how you do it - see above). Just remember your domain model is going to sit in the business-logic layer. In an OO approach you still use layers, but your services are simpler.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Modeling Classes
 
Similar Threads
Help me figure out the wrong answer !(Long post)
Disagreement with "Coding to an Interface" example : Voilate the basic usage of interface
Longer Post - ALL IBM ICE EXAM Q's for UML
Answers to IBM 486 sample test
Confusion between domain model and presentation model