page 1
play

Page 1 1. Add Visibility Information Implementation of UML - PDF document

Object Design Object-Oriented Software Engineering ! 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


  1. Object Design Object-Oriented Software Engineering ! 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 Using UML, Patterns, and Java Chapter 9, execution time, memory and other measures of cost. " Requirements Analysis: The functional model and the dynamic Object Design: model deliver operations for the object model Specifying Interfaces " Object Design: We decide on where to put these operations in the object model ! Object design serves as the basis of implementation Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 2 Object Design: Closing the Gap Developers play different Roles during Object Design Problem System Application objects Requir ements gap Call Class Class User Solution objects Custom objects Object design gap Realize Class Developer Class Implementor Off-the-shelf components Refine Class Class Extender System design gap Machine Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 3 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 4 Class user versus Class Extender Specifying Interfaces Developers responsible for Developers responsible for the implementation of Game are Requirements analysis activities ! the implementation of League are class implementors class users of Game " Identifying attributes and operations without specifying their types or their parameters. ! Object design: Three activities League Game 1. Add visibility information 1 2. Add type signature information 3. Add contracts * TicTacToe Chess Tournament The developer responsible for the implementation of TicTacToe is a class extender of Game Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 5 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 6 Page 1

  2. 1. Add Visibility Information Implementation of UML Visibility in Java Tournament UML defines three levels of visibility: - maxNumPlayers: int ! Private (Class implementor): " A private attribute can be accessed only by the class in which it is + getMaxNumPlayers():int + getPlayers(): List defined. + acceptPlayer(p:Player) " A private operation can be invoked only by the class in which it is + removePlayer(p:Player) defined. + isPlayerAccepted(p:Player):boolean " Private attributes and operations cannot be accessed by subclasses public class Tournament { or other classes. private int maxNumPlayers; ! Protected (Class extender): public Tournament(League l, int maxNumPlayers) " A protected attribute or operation can be accessed by the class in public int getMaxNumPlayers() {…}; which it is defined and on any descendent of the class. public List getPlayers() {…}; public void acceptPlayer(Player p) {…}; ! Public (Class user): public void removePlayer(Player p) {…}; public boolean isPlayerAccepted(Player p) {…}; " A public attribute or operation can be accessed by any class. Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 7 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 8 Information Hiding Heuristics Information Hiding Design Principles ! Carefully define the public interface for classes as well as ! Only the operations of a class are allowed to manipulate its subsystems (façade) attributes " Access attributes only via operations. ! Always apply the “Need to know” principle. " Only if somebody needs to access the information, make it publicly ! Hide external objects at subsystem boundary possible, but then only through well defined channels, so you always " Define abstract class interfaces which mediate between system and know the access. external world as well as between subsystems ! The fewer an operation knows ! Do not apply an operation to the result of another operation. " the less likely it will be affected by any changes " Write a new operation that combines the two operations. " the easier the class can be changed ! Trade-off: Information hiding vs efficiency " Accessing a private attribute might be too slow (for example in real- time systems or games) Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 9 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 10 Team Activity: Visibility and Signatures 2. Add Type Signature Information ♦ Description: Select one of your classes. Complete the visibility and signature for that class. Hashtable -numElements:int ♦ Process: +put() " Work in teams +get() +remove() " You have about 10 minutes. +containsKey() +size() Hashtable Attributes and operations -numElements:int without type information +put(key:Object,entry:Object) are acceptable during analysis +get(key:Object):Object +remove(key:Object) +containsKey(key:Object):boolean +size():int Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 11 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12 Page 2

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend