Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns (Lecture I)

Slides:



Advertisements
Similar presentations
Object-Oriented Application Frameworks Much of the cost and effort stems from the continuous re- discovery and re-invention of core concepts and components.
Advertisements

Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 7, Object Design.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 7, Object Design.
CEN Ninth Lecture Introduction to Software Engineering (CEN-4010) Instructor: Masoud Sadjadi Object Design.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 7, Object Design.
Page 1 Building Reliable Component-based Systems Chapter 7 - Role-Based Component Engineering Chapter 7 Role-Based Component Engineering.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 8 Slide 1 System models.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns.
Modified from Sommerville’s originalsSoftware Engineering, 7th edition. Chapter 8 Slide 1 System models.
Chapter 8, Object Design Introduction to Design Patterns
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns I.
Chapter 7, Object Design.
Modified from Sommerville’s originalsSoftware Engineering, 7th edition. Chapter 8 Slide 1 System models.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 7, Object Design.
Feb. 23, 2004CS WPI1 CS 509 Design of Software Systems Lecture #5 Monday, Feb. 23, 2004.
Software Engineering Module 1 -Components Teaching unit 3 – Advanced development Ernesto Damiani Free University of Bozen - Bolzano Lesson 2 – Components.
Chapter 8 Object Design Reuse and Patterns. Finding Objects The hardest problems in object-oriented system development are: –Identifying objects –Decomposing.
ASP.NET Programming with C# and SQL Server First Edition
Objectives Explain the purpose and objectives of object- oriented design Develop design class diagrams Develop interaction diagrams based on the principles.
Reuse Activities Selecting Design Patterns and Components
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 1 Object Design  Object design  Detail requirements.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Object-Oriented Analysis and Design
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse 2.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns I.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 18 Slide 1 Software Reuse.
Software Engineering Muhammad Fahad Khan
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse.
The Design Discipline.
Systems Analysis and Design in a Changing World, Fifth Edition
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 11 : Frameworks SWE 316: Software Design and Architecture  To understand.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Specifying Interfaces.
Ceg860 (Prasad)L6MR1 Modularity Extendibility Reusability.
©Ian Sommerville 2000 Software Engineering, 6th edition. Slide 1 Component-based development l Building software from reusable components l Objectives.
12 Systems Analysis and Design in a Changing World, Fifth Edition.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part V: Design The Design Workflow Design Classes Refining Analysis Relationships.
Using UML, Patterns, and Java Object-Oriented Software Engineering Art for Chapter 8, Object Design: Reusing Pattern Solutions.
R R R 1 Frameworks III Practical Issues. R R R 2 How to use Application Frameworks Application developed with Framework has 3 parts: –framework –concrete.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns.
Modified by Juan M. Gomez Software Engineering, 6th edition. Chapter 7 Slide 1 Chapter 7 System Models.
Systems Analysis and Design in a Changing World, 3rd Edition
Sommerville 2004,Mejia-Alvarez 2009Software Engineering, 7th edition. Chapter 8 Slide 1 System models.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Specifying Interfaces.
Chapter 8 Object Design Reuse and Patterns. Object Design Object design is the process of adding details to the requirements analysis and making implementation.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 18 Slide 1 Software Reuse.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Lecture 18: Object-Oriented Design
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Systems Analysis and Design in a Changing World, Fourth Edition
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
Review of Parnas’ Criteria for Decomposing Systems into Modules Zheng Wang, Yuan Zhang Michigan State University 04/19/2002.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
From Use Cases to Implementation 1. Structural and Behavioral Aspects of Collaborations  Two aspects of Collaborations Structural – specifies the static.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
© 2010 IBM Corporation RESTFul Service Modelling in Rational Software Architect April, 2011.
From Use Cases to Implementation 1. Mapping Requirements Directly to Design and Code  For many, if not most, of our requirements it is relatively easy.
Two New UML Diagram Types Component Diagram Deployment Diagram.
Why is Design so Difficult? Analysis: Focuses on the application domain Design: Focuses on the solution domain –The solution domain is changing very rapidly.
Software Reuse. Objectives l To explain the benefits of software reuse and some reuse problems l To discuss several different ways to implement software.
Chapter 8 Object Design: Reuse and Patterns 1.
Introduction to Software Engineering (CEN-4010)
Chapter 8, Object Design: Reuse and Patterns
Chapter 8, Object Design: Reuse and Patterns
Chapter 8, Object Design: Reuse and Patterns I
Presentation transcript:

Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns (Lecture I)

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 2 Object Design  Object design is the process of adding details to the requirements analysis and making implementation decisions  The object designer must choose among different ways to implement the analysis model with the goal to minimize execution time, memory and other measures of cost.  Requirements Analysis: Use cases, functional and dynamic model deliver operations for object model  Object Design: Iterates on the models, in particular the object model and refine the models  Object Design serves as the basis of implementation

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 3 Object Design: Closing the Gap

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 4 Examples of Object Design Activities  Identification of existing components  Full definition of associations  Full definition of classes  System Design => Service, Object Design => API  Specifying the contract for each component  Choosing algorithms and data structures  Identifying possibilities of reuse  Detection of solution-domain classes  Optimization  Increase of inheritance  Decision on control  Packaging

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 5 A More Detailed View of Object Design Activities Specifying constraints Specifying types & signatures Identifying patterns Adjusting patterns Identifying missing attributes & operations Specifying visibility Specification Specifying exceptions Reuse Identifying components Adjusting components Select Subsystem

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 6 Detailed View of Object Design Activities (ctd) Collapsing classes RestructuringOptimization Revisiting inheritance Optimizing access paths Caching complex computations Delaying complex computations Check Use Cases Realizing associations

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 7 A Little Bit of Terminology: Activities  Object-Oriented methodologies use these terms:  System Design Activity  Decomposition into subsystems  Object Design Activity  Implementation language chosen  Data structures and algorithms chosen  Structured analysis/structured design uses these terms:  Preliminary Design Activity  Decomposition into subsystems  Data structures are chosen  Detailed Design Activity  Algorithms are chosen  Data structures are refined  Implementation language is chosen  Typically in parallel with preliminary design, not a separate activity

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 8 Plan for the next Lectures 1. Reuse: Identification of existing solutions  Use of inheritance  Off-the-shelf components and additional solution objects  Design patterns 2. Interface specification  Describes precisely each class interface 3. Object model restructuring  Transforms the object design model to improve its understandability and extensibility 4. Object model optimization  Transforms the object design model to address performance criteria such as response time or memory utilization. Object Design lectures Mapping Models to Code lecture

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 9 Outline of Today  Reuse Concepts  The use of inheritance  Implementation vs. Specification Inheritance  Delegation  Components and Frameworks  Documenting the Object Design  JavaDoc

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 10 Reuse Concepts  Application objects versus solution objects  Specification inheritance and implementation inheritance  The Liskov Substitution Principle  Delegation (Section 8.3.3)  Delegation and inheritance in design patterns

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 11 Application domain vs solution domain objects  Application objects, also called domain objects, represent concepts of the domain that are relevant to the system.  They are identified by the application domain specialists and by the end users.  Solution objects represent concepts that do not have a counterpart in the application domain,  They are identified by the developers  Examples: Persistent data stores, user interface objects, middleware.

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 12 Application Domain vs Solution Domain Objects Incident Report Requirements Analysis (Language of Application Domain) Incident Report Object Design (Language of Solution Domain) Text boxMenuScrollbar

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 13 Implementation of Application Domain Classes  New objects are often needed during object design:  The use of design patterns introduces new classes  The implementation of algorithms may necessitate objects to hold values  New low-level operations may be needed during the decomposition of high-level operations  Example: The EraseArea() operation in a drawing program.  Conceptually very simple  Implementation  Area represented by pixels  Repair () cleans up objects partially covered by the erased area  Redraw() draws objects uncovered by the erasure  Draw() erases pixels in background color not covered by other objects

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14 Observation about Modeling of the Real World  [Gamma et al 94]:  Strict modeling of the real world leads to a system that reflects today’s realities but not necessarily tomorrow’s.  There is a need for reusable and flexible designs  Design knowledge complements application domain knowledge and solution domain knowledge.

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15 Reuse  Main goal:  Reuse knowledge from previous experience to current problem  Reuse functionality already available  Composition (also called Black Box Reuse)  New functionality is obtained by aggregation  The new object with more functionality is an aggregation of existing components  Inheritance (also called White-box Reuse)  New functionality is obtained by inheritance.  Three ways to get new functionality:  Implementation inheritance  Specification inheritance  Delegation

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 16 The use of inheritance  Inheritance is used to achieve two different goals  Description of Taxonomies  Interface Specification  Identification of taxonomies  Used during requirements analysis.  Activity: identify application domain objects that are hierarchically related  Goal: make the analysis model more understandable  Interface specification  Used during object design  Activity: identify abstract classes and common behaviors  Goal: increase reusability, enhance modifiability and extensibility  Inheritance is found either by specialization or generalization

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 17 Metamodel for Inheritance  Inheritance is used during analysis and object design Inheritance Specification Inheritance Implementation Inheritance for Reuse Taxonomy Inheritance detected by generalization Inheritance detected by specialization Analysis activity Object Design

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 18 Taxonomy Example Mammal Tiger Wolf Whale

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 19  Problem with implementation inheritance: Some of the inherited operations might exhibit unwanted behavior. What happens if the Stack user calls Remove() instead of Pop()?  Example: I have a List class, I need a Stack class. How about subclassing the Stack class from the List class and providing three methods, Push() and Pop(), Top()? Add() Remove() List Push() Pop() Stack Top() “Already implemented” Implementation Inheritance  A very similar class is already implemented that does almost the same as the desired class implementation.

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 20 Implementation Inheritance vs Specification Inheritance  Implementation inheritance  Also called class inheritance  Goal: Extend an applications’ functionality by reusing functionality in parent class  Inherit from an existing class with some or all operations already implemented  Specification inheritance  Also called subtyping  Inherit from an abstract class with all operations specified, but not yet implemented

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 21 Exercise 8-2: Implementation or Specification Inheritance?  Rectangle class inherits from Polygon class  Specification  Set class inherits from BinaryTree class  Implementation  Set class inherits from Bag class  Specification  Player class inherits from User class  Specification  Window class inherits from Polygon class  Implementation

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 22 Client Receiver Delegate Delegates to calls Delegation as alternative to Implementation Inheritance  Delegation is a way of making composition (for example aggregation) as powerful for reuse as inheritance  In Delegation two objects are involved in handling a request  A receiving object delegates operations to its delegate.  The developer can make sure that the receiving object does not allow the client to misuse the delegate object

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 23 Delegation instead of Implementation Inheritance  Inheritance: Extending a Base class by a new operation or overwriting an operation.  Delegation: Catching an operation and sending it to another object.  Which of the following models is better for implementing a stack? +Add() +Remove() List Stack +Push() +Pop() +Top() +Push() +Pop() +Top() Stack Add() Remove() List

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 24 Comparison: Delegation vs Implementation Inheritance  Delegation  Pro:  Flexibility: Any object can be replaced at run time by another one (as long as it has the same type)  Con:  Inefficiency: Objects are encapsulated.  Inheritance  Pro:  Straightforward to use  Supported by many programming languages  Easy to implement new functionality  Con:  Inheritance exposes a subclass to the details of its parent class  Any change in the parent class implementation forces the subclass to change (which requires recompilation of both)

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 25 Many design patterns use a combination of inheritance and delegation Lecture on Design Patterns

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 26 Component Selection  Select existing  off-the-shelf class libraries  frameworks or  components  Adjust the class libraries, framework or components  Change the API if you have the source code.  Use the adapter or bridge pattern if you don’t have access  Architecture Driven Design

Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 27 Reuse...  Look for existing classes in class libraries  JSAPI, JTAPI,....  Select data structures appropriate to the algorithms  Container classes  Arrays, lists, queues, stacks, sets, trees,...  It might be necessary to define new internal classes and operations  Complex operations defined in terms of lower-level operations might need new classes and operations

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 28 Frameworks  A framework is a reusable partial application that can be specialized to produce custom applications.  Frameworks are targeted to particular technologies, such as data processing or cellular communications, or to application domains, such as user interfaces or real-time avionics.  The key benefits of frameworks are reusability and extensibility.  Reusability leverages of the application domain knowledge and prior effort of experienced developers  Extensibility is provided by hook methods, which are overwritten by the application to extend the framework.  Hook methods systematically decouple the interfaces and behaviors of an application domain from the variations required by an application in a particular context.

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 29 Classification of Frameworks  Frameworks can be classified by their position in the software development process.  Frameworks can also be classified by the techniques used to extend them.  Whitebox frameworks  Blackbox frameworks

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 30 Frameworks in the Development Process  Infrastructure frameworks aim to simplify the software development process and are use internally in a project  Examples: ACE, Java Swing.  Middleware frameworks are used to integrate existing distributed applications and components.  Examples: MFC, DCOM, Java RMI, WebObjects, WebSphere, WebLogic Enterprise Application.  Enterprise application frameworks support the development of end-user applications. They are application specific and focus on domains  Example domains: telecommunications, avionics, environmental modeling, manufacturing, financial engineering, enterprise business activities.

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 31 White-box and Black-Box Frameworks  Whitebox frameworks:  Extensibility achieved through inheritance and dynamic binding.  Existing functionality is extended by subclassing framework base classes and overriding predefined hook methods  Often design patterns such as the template method pattern are used to override the hook methods.  Blackbox frameworks  Extensibility achieved by defining interfaces for components that can be plugged into the framework.  Existing functionality is reused by defining components that conform to a particular interface  These components are integrated with the framework via delegation.

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 32 Class libraries and Frameworks  Class Libraries:  Less domain specific  Provide a smaller scope of reuse.  Class libraries are passive; no constraint on control flow.  Framework:  Classes cooperate for a family of related applications.  Frameworks are active; affect the flow of control.  In practice, developers often use both:  Frameworks often use class libraries internally to simplify the development of the framework.  Framework event handlers use class libraries to perform basic tasks (e.g. string processing, file management, numerical analysis…. )

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 33 Components and Frameworks  Components  Self-contained instances of classes  Plugged together to form complete applications.  Blackbox that defines a cohesive set of operations,  Can be used based on the syntax and semantics of the interface.  Components can even be reused on the binary code level.  The advantage is that applications do not always have to be recompiled when components change.  Frameworks:  Often used to develop components  Components are often plugged into blackbox frameworks.

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 34 Example: Framework for Building Web Applications WebBrowser RelationalDatabase StaticHTML WOAdaptor WebServer WoRequest Template WebObjectsApplication WORequest EOF WebObjects

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 35 Documenting the Object Design: The Object Design Document (ODD)  Object design document  Same as the Requirements Analysis Document (RAD) plus...  … additions to object, functional and dynamic models (from solution domain)  … navigational map for object model  … Javadoc documentation for all classes  ODD Management issues  Update the system models in the RAD?  Should the ODD be a separate document?  Who is the target audience for these documents (Customer, developer?)  If time is short: Focus on the Navigational Map and Javadoc documentation?  ODD Template: 

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 36 Documenting Object Design: ODD Conventions  Each subsystem in a system provides a service (see Chapters on System Design)  Describes the set of operations provided by the subsystem  Specifying a service operation as  Signature: Name of operation, fully typed parameter list and return type  Abstract: Describes the operation  Pre: Precondition for calling the operation  Post: Postcondition describing important state after the execution of the operation  Use JavaDoc for the specification of service operations.

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 37 JavaDoc  Add documentation comments to the source code.  A doc comment consists of characters between /** and */  When JavaDoc parses a doc comment, leading * characters on each line are discarded. First, blanks and tabs preceding the initial * characters are also discarded.  Doc comments may include HTML tags  Example of a doc comment: /** * This is a doc comment */

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 38 More on JavaDoc  Doc comments are only recognized when placed immediately before class, interface, constructor, method or field declarations.  When you embed HTML tags within a doc comment, you should not use heading tags such as and, because JavaDoc creates an entire structured document and these structural tags interfere with the formatting of the generated document.  Class and Interface Doc Tags  Constructor and Method Doc Tags

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 39 Class and Interface Doc name-text  Creates an “Author” version-text  Creates a “Version” classname  Creates a hyperlink “See Also since-text  Adds a “Since” entry. Usually used to specify that a feature or change exists since the release number of the software specified in the deprecated-text  Adds a comment that this method can no longer be used. Convention is to describe method that serves as replacement  Replaced by setBounds(int, int, int, int).

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 40 Constructor and Method Doc Tags  Can as well parameter-name description Adds a parameter to the "Parameters" section. The description may be continued on the next description Adds a "Returns" section, which contains the description of the return fully-qualified-class-name description Adds a "Throws" section, which contains the name of the exception that may be thrown by the method. The exception is linked to its class classname Adds a hyperlink "See Also" entry to the method.

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 41 Example of a Class Doc Comment /** * A class representing a window on the screen. * For example: * * Window win = new Window(parent); * win.show(); * Sami Shaio %I%, %G% java.awt.BaseWindow java.awt.Button */ class Window extends BaseWindow {... }

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 42 Example of a Method Doc Comment /** * Returns the character at the specified index. An index * ranges from 0 to length() - 1. * index the index of the desired character. the desired character. StringIndexOutOfRangeException * if the index is not in the range 0 * to length()-1. java.lang.Character#charValue() */ public char charAt(int index) {... }

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 43 Example of a Field Doc Comment  A field comment can contain tags /** * The X-coordinate of the window. * window#1 */ int x = ;

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 44 Example: Specifying a Service in Java /** Office is a physical structure in a building. It is possible to create an instance of a office; add an occupant; get the name and the number of occupants */ public class Office { /** Adds an occupant to the office */ NAME name is a nonempty string */ public void AddOccupant(string name); Returns the name of the office. Requires, that Office has been initialized with a name */ public string GetName();.... }

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 45 Package it all up  Pack up design into discrete physical units that can be edited, compiled, linked, reused  Construct physical modules  Ideally use one package for each subsystem  System decomposition might not be good for implementation.  Two design principles for packaging  Minimize coupling:  Classes in client-supplier relationships are usually loosely coupled  Large number of parameters in some methods mean strong coupling (> 4-5)  Avoid global data  Maximize cohesion:  Classes closely connected by associations => same package

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 46 Packaging Heuristics  Each subsystem service is made available by one or more interface objects within the package  Start with one interface object for each subsystem service  Try to limit the number of interface operations (7+-2)  If the subsystem service has too many operations, reconsider the number of interface objects  If you have too many interface objects, reconsider the number of subsystems  Difference between interface objects and Java interfaces  Interface object : Used during requirements analysis, system design and object design. Denotes a service or API  Java interface: Used during implementation in Java (A Java interface may or may not implement an interface object)

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 47 Summary  Object design closes the gap between the requirements and the machine.  Object design is the process of adding details to the requirements analysis and making implementation decisions  Object design activities include: Identification of Reuse Identification of Inheritance and Delegation opportunities Component selection  Interface specification (next lecture)  Object model restructuring  Object model optimization  Object design is documented in the Object Design Document, which can be automatically generated from a specification using tools such as JavaDoc. Lecture on Mapping Models to Code

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 48 Additional Slides

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 49 ACE Framework

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 50 Web Browser (UI Framework) Web Server HTTP StateProfil A1: Application Server State A2: Application Server Profil Database Server (Database Framework)

Modified from Bruegge & Dutoit’s originals Object-Oriented Software Engineering: Conquering Complex and Changing Systems 51 Reuse Heuristics  Look for existing classes in class libraries  JSAPI, JTAPI,....  Select data structures appropriate to the algorithms  Container classes  Arrays, lists, queues, stacks, sets, trees,...  Define new internal classes and operations only if necessary  Complex operations defined in terms of lower-level operations might need new classes and operations