This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Grouping classes into the package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Grouping classes into the package" Watch "Grouping classes into the package" New topic
Author

Grouping classes into the package

wenjin_h
Greenhorn

Joined: Apr 18, 2001
Posts: 8
I got a question which I can't find answer from the books. Could someone give a answer and explain the reason for me? Thank you very much!
9)
Valid reasons for grouping classes into the same package are that, the classes:
(this question has 2 correct choices)

a) are related by aggregation.

b) are worked on by the same group of developers.

c) are related by specialization.

d) support the same high-level services.

Avijeet Dash
Ranch Hand

Joined: Jan 21, 2001
Posts: 148
my answer would be its c and d.
Caroline Iux
Ranch Hand

Joined: May 14, 2001
Posts: 103
My 2 cents: a,c
To group classes into a package means these classes are closely related to eath other. Specialization and generalization both mean high coupling, thus should be put in the same package.
b is not right because it reversed the order of things. Developers could be assigned according to the different packages, but that doesn't mean package is grouped based on developers assignment. Grouping happens before assigning developer.
d is not right. On the same layer, in this case, high-level services layer, there are very possibly more than one package. See Larmen's book, on page 277, we have four packages: relational database interface, communication, object databases interface, reporting. Just because the classes are on the same layer, doesn't necessarily mean they should be grouped into the same package.
Panagiotis Varlagas
Ranch Hand

Joined: Nov 27, 2000
Posts: 233
The answer IS in the books, and in Larman in particular (p.352):
"To partition the conceptual model into packages, place elements together that:
- are in the same subject area - closely related by concept or purpose
- are in a type hierarchy together
- participate in the same use cases
- are strongly associated"
This being said, I would go for d. (Sorry Caroline). Note what d says:
"support the SAME high-level services".
In the example of p. 277, the high-level services are broken in four group services (RDB, Comm, OODB, reporting). You say that "Just because the classes are on the same layer, doesn't necessarily mean they should be grouped into the same package." I agree, but a layer contains a set of _dissimilar_ high-level services. These can be grouped in clusters of similarity and have one package for each cluster. (Once again the key word is SAME).
My two cents,
Panagiotis.
Caroline Iux
Ranch Hand

Joined: May 14, 2001
Posts: 103
Originally posted by Panagiotis Varlagas:
The answer IS in the books, and in Larman in particular (p.352):
"To partition the conceptual model into packages, place elements together that:
- are in the same subject area - closely related by concept or purpose
- are in a type hierarchy together
- participate in the same use cases
- are strongly associated"

Thanks for your answer. First of all, the question has 2 correct answers. I am still not convinced why a,c is not the answer. "Aggregation" is closed related by concept, so it's right. "Specialization" is in a type hierarchy( Larman, p335 generalization-specialization type hierarchy" ), c should be in the answer too.
I can see your point of answer d. I guess it depends on whether "SAME" means the same level or the same service here.
Panagiotis Varlagas
Ranch Hand

Joined: Nov 27, 2000
Posts: 233
I can't rule out answer (a) completely myself either. I would consider classes related by aggregation as "strongly associated" and thus as candidates for belonging in the same package.
I guess we need some input from other ranchers here; this is a toughie.
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi,
A and C are correct!!
This is perfect - why are we getting confused??

Originally posted by Panagiotis Varlagas:
"To partition the conceptual model into packages, place elements together that:
- are in the same subject area - closely related by concept or purpose
- are in a type hierarchy together
- participate in the same use cases
- are strongly associated"

A and C are correct, for the reasons Caroline and Panagiotis mentioned.
"Same High level services" may be in different layers as well as in different packages.Different layers leads to multi-tiered architecture.The same High-level service may be in different tiers.On each tier, there may be n number of packages based on aggregation and specialization.However, they would still fall under the same High-level service group.
Also, High-level service is very generic in nature, hence it may not be grouped in the same package.
The example that comes in my mind right now is the Event Model of Java - EventListener is a high-level service which is in java.util.* package.However the implemention of this interface is in other high-level package like java.awt.event.*.
Even though, they support the same Event handling model (high level service) of Java, they are in different packages.
Hope this helps,
Sandeep
[This message has been edited by Desai Sandeep (edited May 21, 2001).]


<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Grouping classes into the package
 
Similar Threads
IBM ICE Question - Classes
Confusion on 3 ICE Questions..
Use of packages
Package question
Criteria for package