Introduction to Software Engineering (CEN-4010)

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.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns (Lecture I)
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 7, Object Design.
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
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns I.
Chapter 7, Object Design.
Creating Architectural Descriptions. Outline Standardizing architectural descriptions: The IEEE has published, “Recommended Practice for Architectural.
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.
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.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns I.
Software Engineering Muhammad Fahad Khan
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Detailed Design Overview and Mid-Level Class Modeling.
An Introduction to Software Architecture
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
SOFTWARE DESIGN (SWD) Instructor: Dr. Hany H. Ammar
Systems Analysis and Design in a Changing World, 3rd Edition
Chapter 8 Object Design Reuse and Patterns. Object Design Object design is the process of adding details to the requirements analysis and making implementation.
Design Model Lecture p6 T120B pavasario sem.
Lecture 18: Object-Oriented Design
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.
February 8, 2006copyright Thomas Pole , all rights reserved 1 Lecture 3: Reusable Software Packaging: Source Code and Text Chapter 2: Dealing.
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.
Why is Design so Difficult? Analysis: Focuses on the application domain Design: Focuses on the solution domain –The solution domain is changing very rapidly.
Engineering, 7th edition. Chapter 8 Slide 1 System models.
Software Reuse. Objectives l To explain the benefits of software reuse and some reuse problems l To discuss several different ways to implement software.
Examples (D. Schmidt et al)
Design Patterns: MORE Examples
CompSci 280 S Introduction to Software Development
Chapter 8 Object Design: Reuse and Patterns 1.
SOFTWARE DESIGN AND ARCHITECTURE
Systems Analysis and Design With UML 2
Unified Modeling Language
Software Reuse ©Ian Sommerville 2006.
Distribution and components
Part 3 Design What does design mean in different fields?
Abstract descriptions of systems whose requirements are being analysed
TIM 58 Chapter 8: Class and Method Design
CIS 375 Bruce R. Maxim UM-Dearborn
Object-Oriented Design
Component-Level Design
Chapter 5 Designing the Architecture Shari L. Pfleeger Joanne M. Atlee
Object-Oriented Design
Chapter 8, Object Design: Reuse and Patterns
Object oriented analysis and design
An Introduction to Software Architecture
Review CSE116 2/21/2019 B.Ramamurthy.
CS 8532: Advanced Software Engineering
Presented By: Darlene Banta
Chapter 8, Object Design: Reuse and Patterns
Chapter 8, Object Design: Reuse and Patterns I
Design Yaodong Bi.
Chapter 8, Design Patterns Introduction
Software Development Process Using UML Recap
From Use Cases to Implementation
Presentation transcript:

Introduction to Software Engineering (CEN-4010) Object Design: Reuse and Patterns I Spring 2005 Instructor: Masoud Sadjadi http://www.cs.fiu.edu/~sadjadi/Classes/CEN-4010/

Acknowledgements Dr. Bernd Bruegge Dr. Allen Dutoit Overview: Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Agenda Overview of Object Design Reuse Concepts Inheritance and Delegation Components, Frameworks, and Libraries System and Object Design Document JavaDoc and Packaging Summary Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Object Design Object design Requirements Analysis: Object Design: Overview: 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 Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Object Design: Closing the Gap Overview: Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

App. vs. Solution Domain Objects Overview: 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. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Example Requirements Analysis (Language of Application Domain) Overview: Overview Reuse Concepts Requirements Analysis (Language of Application Domain) Object Design (Language of Solution Domain) Inher., Deleg. Comp., FW, Lib Incident ReportForm Documentation JavaDoc & Pack. Incident Report Summary Text box Menu Scrollbar

Refining App. Domain Objects Overview: 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 Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Examples of Object Design Activities Overview: 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 Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Object Design Activities (1) Overview: 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 Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Object Design Activities (1) Overview: Collapsing classes Restructuring Optimization Revisiting inheritance Optimizing access paths Caching complex computations Delaying complex Check Use Cases Realizing associations Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Where are we? Object Design Mapping Models to Code Object Design Overview: Today Object Design Reuse: Identification of existing solutions Use of inheritance Off-the-shelf components and additional solution objects Design patterns Interface specification Describes precisely each class interface Mapping Models to Code Object model restructuring Transforms the object design model to improve its understandability and extensibility Object model optimization Transforms the object design model to address performance criteria such as response time or memory utilization. Object Design Reuse: Identification of existing solutions Use of inheritance Off-the-shelf components and additional solution objects Design patterns Interface specification Describes precisely each class interface Mapping Models to Code Object model restructuring Transforms the object design model to improve its understandability and extensibility Object model optimization Transforms the object design model to address performance criteria such as response time or memory utilization. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Agenda Overview of Object Design Reuse Concepts Inheritance and Delegation Components, Frameworks, and Libraries System and Object Design Document JavaDoc and Packaging Summary Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Reuse Motivation Overview: Observation about Modeling of the Real World in [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. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Reuse Heuristics Look for existing classes in class libraries Overview: 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 Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Reuse Main goal: Inheritance Delegation Overview: Main goal: Reuse knowledge and functionality from previous experience to current problem. Approaches: Inheritance and Delegation Inheritance Interface inheritance Used for concept classifications  type hierarchies Implementation inheritance Used for code reuse. Delegation An alternative to implementation inheritance. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Agenda Overview of Object Design Reuse Concepts Inheritance and Delegation Components, Frameworks, and Libraries System and Object Design Document JavaDoc and Packaging Summary Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Metamodel for Inheritance Overview: Inheritance is used to achieve two different goals: Taxonomies and Reuse. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Inheritance Interface Implementation for Reuse Taxonomy Inheritance detected by generalization by specialization Analysis activity Object Design Documentation JavaDoc & Pack. Summary

Taxonomy Example Mammal Tiger Wolf Wale Overview: Overview Reuse Concepts Mammal Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary Tiger Wolf Wale

Implementation Inheritance Overview: A very similar class is already implemented that does almost the same as the desired class implementation. 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()? Overview “Already implemented” Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary List Add () Remove() Stack Push () Pop() Top()

Problems Problem with implementation inheritance: Overview: Problem with implementation inheritance: Some of the inherited operations might exhibit unwanted behavior. What happens if the Stack user calls Remove() instead of Pop()? What happens if the superclass implementation is modified? The subclass developer is exposed to internal information about the superclass and this may result in tight coupling of subclass to superclass. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Impl. vs Interface Inheritance Overview: Implementation inheritance Also called class inheritance Goal: Extend an application’s functionality by reusing functionality in parent class Inherit from an existing class with some or all operations already implemented Interface inheritance Also called subtyping Inherit from an abstract class with all operations specified, but not yet implemented Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Delegation Delegation Overview: Delegation is an alternative to implementation inheritance. is as powerful as implementation 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. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary Delegate Client Receiver calls Delegates to

Delegation vs. Impl. Inheritance Overview: 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? Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary +Add() +Remove() List Stack +Push() +Pop() +Top() +Push() +Pop() +Top() Stack Add() Remove() List

Comparison Delegation Inheritance Pro: Con: Overview: 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 Straightforward to use Supported by many programming languages Easy to implement new functionality 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) Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Heads-up on Design Patterns Overview: Lecture on Design Patterns Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary Many design patterns use a combination of inheritance and delegation

Agenda Overview of Object Design Reuse Concepts Inheritance and Delegation Components, Frameworks, and Libraries System and Object Design Document JavaDoc and Packaging Summary Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Reuse Code Select existing code Overview: Select existing code class libraries frameworks 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 What are the differences among class libraries, frameworks, and components? They are all composed of a set of related classes. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Frameworks Overview: 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. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Key Benefits Reusability Extensibility Overview: 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. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Classification of Frameworks Overview: White-Box 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. Black-Box 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. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Another Classification of Frameworks Overview: Infrastructure frameworks aim to simplify the software development process System infrastructure frameworks are used internally within a software project and are usually not delivered to a client. Middleware frameworks are used to integrate existing distributed applications and components. Examples: MFC, DCOM, Java RMI, WebObjects, WebSphere, WebLogic Enterprise Application [BEA]. Enterprise application frameworks are application specific and focus on domains Example domains: telecommunications, avionics, environmental modeling, manufacturing, financial engineering, enterprise business activities. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Class libraries and Frameworks Overview: 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…. ) Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Components and Frameworks Overview: Components Self-contained instances of classes. Plugged together to form complete applications. Defines a cohesive set of operations Can be used based on the syntax and semantics of the interface. Components may 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 black-box frameworks. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Agenda Overview of Object Design Reuse Concepts Inheritance and Delegation Components, Frameworks, and Libraries System and Object Design Document JavaDoc and Packaging Summary Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Documenting the System Design Overview: Purpose System design is documented in the System Design Document (SDD). It describes design goals set by the project, subsystem decomposition (with UML class diagrams), hardware/software mapping (with UML deployment diagrams), data management, access control, control flow mechanisms, and boundary conditions. The SDD is used to define interfaces between teams of developers and serve as a reference when architecture-level decisions need to be revisited. Audience The audience for the SDD includes the project management, the system architects (i.e., the developers who participate in the system design), and the developers who design and implement each subsystem. Template http://wwwbruegge.in.tum.de/OOSE/SystemDesignDocumentTemplate Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

SDD Template Overview: Outline Introduction     1.1 Purpose of the system     1.2 Design goals     1.3 Definitions, acronyms, and abbreviations     1.4 References     1.5 Overview Current software architecture Proposed software architecture Overview Subsystem decomposition Hardware/software mapping Persistent data management Access control and security Global software control Boundary conditions Subsystem services Glossary Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Documenting the Object Design Overview: Purpose Object design is documented in the Object Design Document (ODD). It describes object design trade-offs made by developers, guidelines they followed for subsystem interfaces, the decomposition of subsystems into packages and classes, and the class interfaces. The ODD is used to exchange interface information among teams and as a reference during testing. Audience The audience for the ODD includes system architects (i.e., the developers who participate in the system design), developers who implement each subsystem, and testers. Template http://wwwbruegge.in.tum.de/OOSE/ObjectDesignDocumentTemplate Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

ODD Template (1) Outline Introduction Packages Class interfaces Overview: Outline Introduction Object design trade-offs e.g., buy vs. build, memory space vs. response time Interface documentation guidelines e.g., naming conventions, boundary cases, exception handling mechanisms Definitions, acronyms, and abbreviation References Packages describes the decomposition of subsystems into packages and the file organization of the code. This includes an overview of each package, its dependencies with other packages, and its expected usage.3. Class interfaces Glossary Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Alternative Approaches for ODD Overview: Self-Contained ODD generated from model Write and maintain a UML model and generate the document automatically con: redundancy with the RAD and source code, hard to maintain consistency. ODD as extension of the RAD The set of application objects augmented with solution objects. pro: easier to maintain consistency with the RAD. con: polluting the RAD with irrelevant information for the user and client, also it may not be possible. ODD embedded into source code represent the ODD using a modeling tool. Once it becomes stable, generate class stubs. Complete the source code and comments. Generate the ODD using a tool such as JavaDoc. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Embedded ODD approach Overview: Overview Reuse Concepts Inher., Deleg. Analysis Overview Reuse Concepts Analysis model Document analysis RAD Inher., Deleg. Comp., FW, Lib System design Documentation JavaDoc & Pack. Subsystem Design goals decomposition Summary Object design Initial object design model Generate class stubs Initial class stubs Implementation Commented code Document object design ODD

Agenda Overview of Object Design Reuse Concepts Inheritance and Delegation Components, Frameworks, and Libraries System and Object Design Document JavaDoc and Packaging Summary Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

JavaDoc Add documentation comments to the source code. Overview: 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 <b> doc </b> comment */ Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

More on JavaDoc Overview: 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 <h1> and <h2>, 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 Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Class and Interface Doc Tags Overview: @author name-text Creates an “Author” entry. @version version-text Creates a “Version” entry. @see classname Creates a hyperlink “See Also classname” @since 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 “since-text” @deprecated deprecated-text Adds a comment that this method can no longer be used. Convention is to describe method that serves as replacement Example: @deprecated Replaced by setBounds(int, int, int, int). Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Constructor and Method Doc Tags Overview: Can contain @see tag, @since tag, @deprecated as well as: @param parameter-name description Adds a parameter to the "Parameters" section. The description may be continued on the next line. @return description Adds a "Returns" section, which contains the description of the return value. @exception 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 documentation. @see classname Adds a hyperlink "See Also" entry to the method. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Example of a Class Doc Comment Overview: /** * A class representing a window on the screen. * For example: * <pre> * Window win = new Window(parent); * win.show(); * </pre> * * @author Sami Shaio * @version %I%, %G% * @see java.awt.BaseWindow * @see java.awt.Button */ class Window extends BaseWindow { ... Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Example of a Method Doc Comment Overview: /** * Returns the character at the specified index. An index * ranges from <code>0</code> to <code>length() - 1</code>. * * @param index the index of the desired character. * @return the desired character. * @exception StringIndexOutOfRangeException * if the index is not in the range <code>0</code> * to <code>length()-1</code>. * @see java.lang.Character#charValue() */ public char charAt(int index) { ... } Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Example of a Field Doc Comment Overview: A field comment can contain only the @see, @since and @deprecated tags /** * The X-coordinate of the window. * * @see window#1 */ int x = 1263732; Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Example: Specifying a Service Overview: /** 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 */ * @param NAME name is a nonempty string */ public void AddOccupant(string name); /** @Return Returns the name of the office. Requires, that Office has been initialized with a name */ public string GetName(); .... } Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Package it all up Overview: 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 Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Packaging Heuristics Overview: 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) Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Agenda Overview of Object Design Reuse Concepts Inheritance and Delegation Components, Frameworks, and Libraries System and Object Design Document JavaDoc and Packaging Summary Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary

Summary Overview: 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 Select existing code 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. Overview Reuse Concepts Inher., Deleg. Comp., FW, Lib Documentation JavaDoc & Pack. Summary