This section contains a brief overview of object-oriented design methods that allow for the most reliable and productive development. The following is a brief list of the most important concepts and ideas required for object-oriented design.
1. Keep close to the problem domain. Do not stray too far or the scope of the project will grow to an uncontrollable size.
164 8 Object-Oriented Design
2. Discover objects, do not invent them. Objects should be obvious and necessary.
If you are forcing them, then they are most likely not correct.
3. Using a standard naming convention. These vary from project to project, but some common practices consist of using nouns as class names and attributes.
Using verbs for method names is also common.
4. Modern languages and toolkits provide almost every data structure and low level component you can imagine. Use them. These classes built into the language are widely understood, documented, and implemented. There is no need to rebuild something that is already proven and readily available.
8.9 Chapter Summary and Conclusions
This chapter focuses on object design. Object design is adding details to the requirements analysis and making implementation decisions. The process of object design serves as the stepping stone to implementation. This phase closes the gap between the application objects and the off-the-shelf components by identifying additional solution objects and refining existing objects. At the end of this step there should be a complete design that is ready to be implemented.
Objects are categorized in a few different groups. Application objects, also called
‘‘domain objects’’, represent concepts of domain that are relevant to the system.
Solution objects represent components that do not have a counterpart in the appli-cation domain, such as persistent data stores, user interface objects, or middleware.
Inheritance is embodied by all object-oriented languages. It provides a crucial and necessary mechanism to promote reusability. The focus of inheritance during object design is to reduce redundancy and enhance extensibility.
A clear and concise design revolves around well enumerated and documented interfaces to the outside world. Whereas internal components are not seen or directly manipulated (this does not mean that they should not be thought out) by the end user interfaces. This can make or break a project in terms of usability.
Interface specification activities of object design include:
• Identifying missing attributes and operations
• Specifying type signatures and visibility
• Specifying invariants
• Specifying preconditions and postconditions
The class implementer is responsible for realizing the class under consideration.
Class implementers design the internal data structures and implement the code for each class. Class extenders may invoke operations provided by the class of interest, and they focus on specialized versions of the same services.
A constraint is a restriction on one or more values of (part of) an object-oriented model or system. The context definition of an OCL expression specifies the model entity for which the OCL expression is defined.
Managing object design adds a couple of new layers of complication. The two main considerations added during object design in relation to communication are as follows:
• Increased communication complexity: Object design revolves around UML, OCL and many other methodologies. These techniques are normally out of the scope of many stake holders understanding. Using simple and concise documentation is the key to demonstrating ideas and concepts.
• Consistency with prior decisions and documents is increasingly problematic as the complexity of the system increases, and flaws may be found in the work of previous stages. Also, stake holders may change their requirements.
Object design teams should work closely with the other teams to create the most accurate rendition of the requirements. However, do not forget to document these changes before moving to the next phase.
The Object Design Document (ODD) provides insight into the Object design phase. The following information is essential for maintaining a complete and useful document:
• Communication among stakeholders. This should be documented and time stamped. A complete and coherent dialogue will help in the resolution of conflicts and assure that all features desired are implemented.
• Level of detail and rate of change are essential for tracking progress of a project.
• Level of detail and elicitation effort. Detailing the effort allows for a com-parison between the rate of change and the effort (or the man hours). Using this information, managers can determine if the project is on schedule.
• Testing requirements will provide a metric by which the delivery system should perform.
8.10 Exercises
1. Give an outline of steps required in object-oriented design.
2. For each of the following objects, indicate if it is an application object or a solution object:
• League
• League store
• Match
• Match view
• Move
3. Indicate which occurrences of the following inheritance relationship is spec-ification inheritance and which implementation inheritance is:
• A Rectangle class inherits from a Polygon class
166 8 Object-Oriented Design
• A Set class inherits from a BinaryTree class
• A Set class inherits from a Bag class
• A Player class inherits from a User class
• A Window class inherits from a Polygon class
4. Consider Polyline, Polygon, and Point classes Write the following constraints in OCL:
• A polygon is composed of a sequence of at least three points
• A polygon is composed of a sequence of points starting and ending at the same point
• The points returned by the getpoints (bbox) method of a polygon are within the bbox rectangle
5. Why is maintaining consistency between the analysis model and the object model difficult? Illustrate your point with a change to the object design model.
6. Group Diary
A group diary and time management system is intended to support the timet-abling of meetings and appointments across a group of co-workers. When an appointment is to be made that involves a number of people, the system finds a common slot in each of their diaries and arranges the appointment for that time.
If no common slots are available, it interacts with the user to rearrange his or her personal diary to make room for the appointment.
• For the bored: Announce successful meetings per email. Permit people to block out personal time. Set up provisional meetings that must be con-firmed by all participants before they are finalized.
• Identify possible objects in your system and develop an object-oriented design for it. You may make any reasonable assumptions about the systems when deriving the design.
• Draw a sequence diagram showing the interactions of objects in your system.
• Draw a state chart showing the possible state changes in one or more of the objects defined.
• Write a precise interface in Java of the objects you have defined.
7. Define: (a) precondition; (b) postcondition; (c) assertion; (d) invariance con-dition; (e) Types; (f) signature
8. How do you decide whether something is to be modeled as an attribute or a class?
9. Define the terms: pattern, design pattern, analysis pattern, and organizational pattern architectural pattern. Give examples of each.
10. Produce a framework template for school timetable preparation: allocating suitable classrooms, qualified teachers, ten subjects, and five one-hour time-slots per weekday. Include all invariants; e.g. Chemistry needs a classroom with sinks and there must be at least five hours of Math and English per week.
Are there any rules that are hard to express in OCL? Why is this? Apply the same framework to factory production scheduling.
11. Write patterns to deal with the following situations:
a. The needs to inform all users of e-mail of a change to their e-mail addresses, when some may be on holiday;
b. Users in a workshop continually disagree with each other;
c. Management resists object technology because they consider it too risky.
Compare two architectural styles from the following list: layers, pipes and filters, peer-to-peer, and client–server.
References
Berard E V (2002) Object-oriented design. The Object Agency, Prolouge
Bruegge B, Dutoit A (1999) Object-oriented software engineering: conquering complex and changing systems. Pearson Education, Ltd., Upper Saddle River
Bruegge B, Dutoit A (2000) Object-oriented software engineering: conquering complex and changing systems. Pearson Education, Ltd., Upper Saddle River
Bruegge B, Dutoit A (2004) Object-oriented software engineering: using UML, patterns, and java, 2nd edn. Pearson Education, Ltd., Upper Saddle River
Coad P, Yourdon E (1990) Object-oriented analysis. PrenticeHall, Englewood Clis, New Jersey Eliens A (1995) Principles of object-oriented software development. Addison-Wesley
Schach S (2008) Object-oriented software engineering. McGraw-Hill Higher Education, Boston Implementing a class. In: Object-oriented software design and construction. Virginia Tech.http://
peopl.cs.vt.edu/*kafura/cs2704/implementing.html. Accessed 15 July 2006
Introduction to OCL. The professional website of Jos Warmer and Anneke Kleppe. http://
www.klasse.nl/ocl/ocl-introduction.html. Accessed 15 July 2006
http://www.objenv.com/cetus/oo_ooa_ood_tools.html. Accessed 28 Sept 2006 http://www.toa.com/pub/ood_article.txt. Accessed 28 Sept 2006
http://ee.hawaii.edu/*tep/EE467/BDLecs/html/odd.html. Accessed 1 July 2009
168 8 Object-Oriented Design