Chapter 9, Object Design: Specifying Interfaces

Size: px
Start display at page:

Download "Chapter 9, Object Design: Specifying Interfaces"

Transcription

1 Chapter 9, Object Design: Specifying Interfaces Using UML, Patterns, and Java Object-Oriented Software Engineering

2 Specifying Interfaces Requirements analysis activities Identifying attributes and operations without specifying their types or their parameters. Object design: Three activities 1. Add visibility information 2. Add type signature information 3. Add contracts Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 6

3 1. Add Visibility Information UML defines three levels of visibility: Private (Class implementor): A private attribute can be accessed only by the class in which it is defined. A private operation can be invoked only by the class in which it is defined. Private attributes and operations cannot be accessed by subclasses or other classes. Protected (Class extender): A protected attribute or operation can be accessed by the class in which it is defined and on any descendent of the class. Public (Class user): 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

4 Implementation of UML Visibility in Java Tournament - maxnumplayers: int + getmaxnumplayers():int + getplayers(): List + acceptplayer(p:player) + removeplayer(p:player) + isplayeraccepted(p:player):boolean public class Tournament { private int maxnumplayers; public Tournament(League l, int maxnumplayers) public int getmaxnumplayers() { ; public List getplayers() { ; public void acceptplayer(player p) { ; public void removeplayer(player p) { ; public boolean isplayeraccepted (Player p) { ; Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 8

5 Information Hiding Heuristics Carefully define the public interface for classes as well as subsystems (façade) Always apply the Need to know principle. Only if somebody needs to access the information, make it publicly possible, but then only through well defined channels, so you always know the access. The fewer an operation knows the less likely it will be affected by any changes 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

6 Information Hiding Design Principles Only the operations of a class are allowed to manipulate its attributes Access attributes only via operations. Hide external objects at subsystem boundary Define abstract class interfaces which mediate between system and external world as well as between subsystems Do not apply an operation to the result of another operation. Write a new operation that combines the two operations. Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 10

7 2. Add Type Signature Information -numelements:int +put() +get() +remove() +containskey() +size() Hashtable Attributes and operations without type information are acceptable during analysis Hashtable -numelements:int +put(key:object,entry:object) +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

8 3. Add Contracts Contracts on a class enable caller and callee to share the same assumptions about the class. Contracts include three types of constraints: Invariant: A predicate that is always true for all instances of a class. Invariants are constraints associated with classes or interfaces. Precondition: Preconditions are predicates associated with a specific operation and must be true before the operation is invoked. Preconditions are used to specify constraints that a caller must meet before calling an operation. Postcondition: Postconditions are predicates associated with a specific operation and must be true after an operation is invoked. Postconditions are used to specify constraints that the object must ensure after the invocation of the operation. Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 12

9 Expressing constraints in UML Models OCL (Object Constraint Language) OCL allows constraints to be formally specified on single model elements or groups of model elements A constraint is expressed as an OCL expression returning the value true or false. OCL is not a procedural language (cannot constrain control flow). OCL expressions for Hashtable operation put(): Invariant: context Hashtable inv: numelements >= 0 Precondition: Context is a class operation put OCL expression context Hashtable::put(key, entry) pre:!containskey(key) Post-condition: context Hashtable::put(key, entry) post: containskey(key) and get(key) = entry Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 13

10 Expressing Constraints in UML Models A constraint can also be depicted as a note attached to the constrained UML element by a dependency relationship. <<invariant>> numelements >= 0 <<precondition>>!containskey(key) <<precondition>> containskey(key) <<precondition>> containskey(key) numelements:int HashTable put(key,entry:object) get(key):object remove(key:object) containskey(key:object):boolean size():int <<postcondition>> get(key) == entry <<postcondition>>!containskey(key) Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 14

11 Contract for acceptplayer in Tournament context Tournament::acceptPlayer(p) pre: not isplayeraccepted(p) context Tournament::acceptPlayer(p) pre: getnumplayers() < getmaxnumplayers() context Tournament::acceptPlayer(p) post: isplayeraccepted(p) context Tournament::acceptPlayer(p) post: getnumplayers() + 1 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15

12 Contract for removeplayer in Tournament context Tournament::removePlayer(p) pre: isplayeraccepted(p) context Tournament::removePlayer(p) post: not isplayeraccepted(p) context Tournament::removePlayer(p) post: getnumplayers() - 1 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16

13 Annotation of Tournament class public class Tournament { /** The maximum number of players * is positive at all times. maxnumplayers > 0 */ private int maxnumplayers; /** The players List contains * references to Players who are * are registered with the * Tournament. */ private List players; /** Returns the current number of * players in the tournament. */ public int getnumplayers() { /** Returns the maximum number of * players in the tournament. */ public int getmaxnumplayers() { /** The acceptplayer() operation * assumes that the specified * player has not been accepted * in the Tournament yet. getnumplayers()<maxnumplayers isplayeraccepted(p) getnumplayers() = + 1 */ public void acceptplayer (Player p) { /** The removeplayer() operation * assumes that the specified player * is currently in the Tournament. isplayeraccepted(p) getnumplayers() - 1 */ public void removeplayer(player p) { Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 17

14 Exceptions as building blocks for contract violations Many object-oriented languages, including Java do not include built-in support for contracts. However, we can use their exception mechanisms as building blocks for signaling and handling contract violations In Java we use the try-throw-catch mechanism Example: Let us assume the acceptplayer() operation of TournamentControl is invoked with a player who is already part of the Tournament. In this case acceptplayer() should throw an exception of type KnownPlayer. See source code on next slide Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 28

15 The try-throw-catch Mechanism in Java public class TournamentControl { private Tournament tournament; public void addplayer(player p) throws KnownPlayerException { if (tournament.isplayeraccepted(p)) { throw new KnownPlayerException(p); //... Normal addplayer behavior public class TournamentForm { private TournamentControl control; private ArrayList players; public void processplayerapplications() { // Go through all the players for (Iteration i = players.iterator(); i.hasnext();) { try { // Delegate to the control object. control.acceptplayer((player)i.next()); catch (KnownPlayerException e) { // If an exception was caught, log it to Bernd Bruegge the & Allen console H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 29 ErrorConsole log(e getmessage());

16 Implementing a contract For each operation in the contract, do the following Check precondition: Check the precondition before the beginning of the method with a test that raises an exception if the precondition is false. Check postcondition: Check the postcondition at the end of the method and raise an exception if the contract is violoated. If more than one postcondition is not satisfied, raise an exception only for the first violation. Check invariant: Check invariants at the same time as postconditions. Deal with inheritance: Encapsulate the checking code for preconditions and postconditions into separate methods that can be called from subclasses. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 30

17 A complete implementation of the Tournament.addPlayer() contract «invariant» getmaxnumplayers() > 0 «precondition»!isplayeraccepted(p) Tournament -maxnumplayers: int +getnumplayers():int +getmaxnumplayers():int +isplayeraccepted(p:player):boolean +addplayer(p:player) «precondition» getnumplayers() < getmaxnumplayers() «postcondition» isplayeraccepted(p) Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 31

18 The code Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 32

19 Heuristics for Mapping Contracts to Exceptions Be pragmatic, if you don t have enough time. Omit checking code for postconditions and invariants. Usually redundant with the code accomplishing the functionality of the class Not likely to detect many bugs unless written by a separate tester. Omit the checking code for private and protected methods. Focus on components with the longest life Focus on Entity objects, not on boundary objects associated with the user interface. Reuse constraint checking code. Many operations have similar preconditions. Encapsulate constraint checking code into methods so that they can share the same exception classes. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 33

20 Heuristics for mapping contracts to exceptions Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 34

21 Chapter 10, Mapping Models to Code Using UML, Patterns, and Java Object-Oriented Software Engineering

22 Four types of transformations Model transformations operate on object models Refactoring source code transformations Forward Engineering changes in an object (e.g., attributes or associations) map into corresponding changes in source code Reverse Engineering the model space is defined based on existing source code Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 5

23 Model transformations Forward engineering Refactoring Model transformation Reverse engineering Model space Source code space Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 6

24 Model Transformation Example Object design model before transformation LeagueOwner + address Advertiser + address Player + address Object design model after transformation: User + address LeagueOwner Advertiser Player Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7

25 Refactoring by pulling up a field Create a parent class that will hold the field that is factored out Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 8

26 Refactoring Example: Pull Up Field public class Player { private String ; //... public class LeagueOwner { private String ; //... public class Advertiser { private String _address; //... public class User { private String ; public class Player extends User { //... public class LeagueOwner extends User { //... public class Advertiser extends User { //... Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 9

27 Refactoring by pulling up a constructor body Create a parent class that will assign a value to the field in common Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10

28 Refactoring Example: Pull Up Constructor Body public class User { private String ; public class Player extends User { public Player(String ) { this. = ; public class LeagueOwner extends User{ public LeagueOwner(String ) { this. = ; public class Advertiser extendsuser{ public Advertiser(String ) { this. = ; public class User { public User(String ) { this. = ; public class Player extends User { public Player(String ) { super( ); public class LeagueOwner extends User { public LeagueOwner(String ) { super( ); public class Advertiser extends User { public Advertiser(String ) { super( ); Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 11

29 Refactoring by pulling up methods The field and initialization in the constructor have been pulled up to the parent class Now see if any methods associated with can be moved to the parent class Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12

30 Forward Engineering Example Object design model before transformation User + string +notify(msg:string) LeagueOwner +maxnumleagues:int Source code after transformation public class User { private String ; public String get () { return ; public void set (string value){ = value; public void notify(string msg) { //... /* Other methods omitted */ public class LeagueOwner extends User { private int maxnumleagues; public int getmaxnumleagues() { return maxnumleagues; public void setmaxnumleagues (int value) { maxnumleagues = value; /* Other methods omitted */ Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13

31 Transformation principles Each transformation must address a single criteria Each transformation must be local Each transformation must be applied in isolation to other changes Each transformation must be followed by a validation step Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14

32 Some optimizations Avoid frequent repeated association traversals Multiple association traversals can lead to code such as method1().method2().. methodn() The sequence diagram can be used to identify such traversals See if a direct connection is possible to improve efficiency Try to make many associations more efficient Try to use a qualified association to reduce multiplicity to one Try to use ordering or indexing to decrease access time Try to avoid misplaced attributes Inefficient due to the need for get and set methods Try bringing the attribute into the calling class Catch the result of expensive computations Example, statistics in the Arena example are only updated after a match is completed This only has to be calculated once at the end of each match and not repeatedly until another match is completed Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16

33 Collapsing an object without interesting behavior Object design model before transformation Person SocialSecurity number:string Object design model after transformation Person SSN:String Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 17

34 Delaying expensive computations Object design model before transformation Image filename:string data:byte[] paint() Object design model after transformation Image filename:string paint() ImageProxy filename:string paint() image RealImage data:byte[] paint() Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 18

35 Realization of a unidirectional, one-to-one association Object design model before transformation Advertiser 1 1 Account Source code after transformation public class Advertiser { private Account account; public Advertiser() { account = new Account(); public Account getaccount() { return account; Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 20

36 Bidirectional one-to-one association Object design model before transformation Advertiser 1 1 Account Source code after transformation public class Advertiser { /* The account field is initialized * in the constructor and never * modified. */ private Account account; public Advertiser() { account = new Account(this); public Account getaccount() { return account; public class Account { /* The owner field is initialized * during the constructor and * never modified. */ private Advertiser owner; public Account(owner:Advertiser) { this.owner = owner; public Advertiser getowner() { return owner; Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 21

37 Bidirectional, one-to-many association Object design model before transformation 1 Advertiser * Account Source code after transformation public class Advertiser { private Set accounts; public Advertiser() { accounts = new HashSet(); public void addaccount(account a) { accounts.add(a); a.setowner(this); public void removeaccount(account a) { accounts.remove(a); a.setowner(null); public class Account { private Advertiser owner; public void setowner(advertiser newowner) { if (owner!= newowner) { Advertiser old = owner; owner = newowner; if (newowner!= null) newowner.addaccount(this); if (oldowner!= null) old.removeaccount(this); Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 22

38 Bidirectional, many-to-many association Object design model before transformation * {ordered * Tournament Player Source code after transformation public class Tournament { private List players; public Tournament() { players = new ArrayList(); public void addplayer(player p) { if (!players.contains(p)) { players.add(p); p.addtournament(this); public class Player { private List tournaments; public Player() { tournaments = new ArrayList(); public void addtournament(tournament t) { if (!tournaments.contains(t)) { tournaments.add(t); t.addplayer(this); Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 23

39 Bidirectional qualified association Object design model before transformation League * * Player nickname Object design model before forward engineering League nickname * 0..1 Player Source code after forward engineering Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 24

40 Bidirectional qualified association (continued) Source code after forward engineering public class League { private Map players; public class Player { private Map leagues; public void addplayer (String nickname, Player p) { if (!players.containskey(nickname )) { players.put(nickname, p); p.addleague(nickname, this); public void addleague (String nickname, League l) { if (!leagues.containskey(l)) { leagues.put(l, nickname); l.addplayer(nickname, this); Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 25

41 Transformation of an association class Object design model before transformation Statistics +getaveragestat(name) +gettotalstat(name) +updatestats(match) Tournament * * Player Object design model after transformation: 1 class and two binary associations Statistics Tournament +getaveragestat(name) +gettotalstat(name) +updatestats(match) 1 1 * * Player Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 26

42 Mapping an object model to a relational database UML object models can be mapped to relational databases: Some degradation occurs because all UML constructs must be mapped to a single relational database construct - the table. UML mappings Each class is mapped to a table Each class attribute is mapped onto a column in the table An instance of a class represents a row in the table A many-to-many association is mapped into its own table A one-to-many association is implemented as buried foreign key Methods are not mapped Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 36

43 Mapping the User class to a database table User +firstname:string +login:string + string User table id:long firstname:text[25] login:text[8] text[32] Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 37

44 Primary and Foreign Keys Any set of attributes that could be used to uniquely identify any data record in a relational table is called a candidate key. The actual candidate key that is used in the application to identify the records is called the primary key. The primary key of a table is a set of attributes whose values uniquely identify the data records in the table. A foreign key is an attribute (or a set of attributes) that references the primary key of another table. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 38

45 Example for Primary and Foreign Keys User table Primary key firstname alice john bob login am384 js289 bd Candidate key Candidate key League table name tictactoenovice tictactoeexpert chessnovice login am384 am384 js289 Foreign key referencing User table Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 39

46 Buried Association Associations with multiplicity one can be implemented using a foreign key. For one-to-many associations we add a foreign key to the table representing the class on the many end. For all other associations we can select either class at the end of the association. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 40

47 Buried Association Associations with multiplicity one can be implemented using a foreign key. Because the association vanishes in the table, we call this a buried association. For one-to-many associations we add the foreign key to the table representing the class on the many end. For all other associations we can select either class at the end of the association. 1 LeagueOwner * League LeagueOwner table League table id:long... id:long... owner:long Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 41

48 Another Example for Buried Association Transaction transactionid * Foreign Key Portfolio portfolioid... transactionid Transaction Table portfolioid Portfolio Table portfolioid... Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 42

49 Mapping Many-To-Many Associations In this case we need a separate table for the association City cityname * Serves * Airport airportcode airportname Separate table for Serves association Primary Key City Table Airport Table Serves Table cityname Houston Albany Munich Hamburg airportcode IAH HOU ALB MUC HAM airportname Intercontinental Hobby Albany County Munich Airport Hamburg Airport cityname Houston Houston Albany Munich Hamburg airportcode IAH HOU ALB MUC HAM Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 43

50 Mapping the Tournament/Player association as a separate table Tournament * * Player Tournament table id name novice 24 expert TournamentPlayerAssociation table tournament player Player table id name alice 79 john Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 44

51 Realizing Inheritance Relational databases do not support inheritance Two possibilities to map UML inheritance relationships to a database schema With a separate table (vertical mapping) The attributes of the superclass and the subclasses are mapped to different tables By duplicating columns (horizontal mapping) There is no table for the superclass Each subclass is mapped to a table containing the attributes of the subclass and the attributes of the superclass Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 45

52 Realizing inheritance with a separate table name User LeagueOwner maxnumleagues Player credits id User table name... role 56 zoe LeagueOwner 79 john Player LeagueOwner table Player table id maxnumleagues... id credits Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 46

53 Realizing inheritance by duplicating columns name User LeagueOwner maxnumleagues Player credits LeagueOwner table Player table id name maxnumleagues... id name credits zoe john 126 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 47

54 Comparison: Separate Tables vs Duplicated Columns The trade-off is between modifiability and response time How likely is a change of the superclass? What are the performance requirements for queries? Separate table mapping We can add attributes to the superclass easily by adding a column to the superclass table Searching for the attributes of an object requires a join operation. Duplicated columns Modifying the database schema is more complex and error-prone Individual objects are not fragmented across a number of tables, resulting in faster queries Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 48

Chapter 10, Mapping Models to Code

Chapter 10, Mapping Models to Code Chapter 10, Mapping Models to Code Using UML, Patterns, and Java Object-Oriented Software Engineering Overview Object design is situated between system design and implementation. Object design is not very

More information

10. Mapping Models to Code

10. Mapping Models to Code 10. Mapping Models to Code Outline! Overview! Mapping Concepts! Mapping Activities! Case Study 1. Overview! Object design is situated between system design and implementation. Object design is not very

More information

CSSE 490 Model-Based Software Engineering: Introduction to MetaModels

CSSE 490 Model-Based Software Engineering: Introduction to MetaModels CSSE 490 Model-Based Software Engineering: Introduction to MetaModels Shawn Bohner Office: Moench Room F212 Phone: (812) 877-8685 Email: bohner@rose-hulman.edu Learning Outcomes: Transformations Define

More information

Chapter 10, Mapping Models to Relational Schema

Chapter 10, Mapping Models to Relational Schema Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 10, Mapping Models to Relational Schema Lecture Plan Last lecture: Operations on the object model: Optimizations to address performance

More information

Chapter 9 Object Design: Specifying Interfaces

Chapter 9 Object Design: Specifying Interfaces Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9 Object Design: Specifying Interfaces Object Design Object design is the process of adding details to the requirements analysis

More information

9. Object Design: Specifying Interfaces

9. Object Design: Specifying Interfaces 9. Object Design: Specifying Interfaces Outline! An Overview of Object Design! Interface Specification Concepts! Interface Specification Activities 1. An Overview of Object Design Object Design! Object

More information

Chapter 9, Object Design: Specifying Interfaces

Chapter 9, Object Design: Specifying Interfaces Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Specifying Interfaces Lecture Plan Specifying Interfaces (Chapter 9) Object Design Activities Visibilities and

More information

Course "Softwaretechnik" Book Chapters 9, 10 Object Design: Specifying Interfaces, Model-to-implementation mapping

Course Softwaretechnik Book Chapters 9, 10 Object Design: Specifying Interfaces, Model-to-implementation mapping Course "Softwaretechnik" Book Chapters 9, 10 Object Design: Specifying Interfaces, Model-to-implementation mapping Lutz Prechelt, Bernd Bruegge & Allen H. Dutoit Freie Universität Berlin, Institut für

More information

Chapter 8, Object Design: Object Constraint Language

Chapter 8, Object Design: Object Constraint Language Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 8, Object Design: Object Constraint Language Outline of the Lecture OCL Simple predicates Preconditions Postconditions Contracts

More information

Model-Driven Architecture/ Development

Model-Driven Architecture/ Development CSSE 490 Model-Based Software Engineering: Shawn Bohner Model-Driven Architecture/ Development Office: Moench Room F212 Phone: (812) 877-8685 Email: bohner@rose-hulman.edu Learning Outcomes: Transformations

More information

Lecture Notes on. Object Design. Object Design. Bill Scherlis / Bernd Brügge Software Engineering Fall October November 1999

Lecture Notes on. Object Design. Object Design. Bill Scherlis / Bernd Brügge Software Engineering Fall October November 1999 v 8 September 1994 Lecture Notes on Object Design Object Design Bill Scherlis / Bernd Brügge 15-413 Software Engineering Fall 1999 21 October 1999 2 November 1999 Bruegge/Software 15-413 Software Engineering

More information

5C. Examples of OCL in use, especially in "Object Design: Specifying Interfaces"

5C. Examples of OCL in use, especially in Object Design: Specifying Interfaces 5C. Examples of OCL in use, especially in "Object Design: Specifying Interfaces" Note: This section is based heavily on Chapter 9 of the very useful text book Object- Oriented Software Engineering by Bruegge

More information

Chapter 6, System Design Lecture 2

Chapter 6, System Design Lecture 2 Object-Oriented Software Engineering Conquering Complex and Changing Systems Chapter 6, System Design Lecture 2 Preliminaries Guest lectures December 15: Andersen Consulting December 22: Viant January

More information

Software Engineering Fall 2015 (CSC 4350/6350) TR. 5:30 pm 7:15 pm. Rao Casturi 11/03/2015

Software Engineering Fall 2015 (CSC 4350/6350) TR. 5:30 pm 7:15 pm. Rao Casturi 11/03/2015 Software Engineering Fall 2015 (CSC 4350/6350) TR. 5:30 pm 7:15 pm Rao Casturi 11/03/2015 http://cs.gsu.edu/~ncasturi1 Object Design Software Engineering -CSC4350/6350 - Rao Casturi 2 Object Design Close

More information

Software Engineering Fall 2014

Software Engineering Fall 2014 Software Engineering Fall 2014 (CSC 4350/6350) Mon.- Wed. 5:30 pm 7:15 pm ALC : 107 Rao Casturi 11/03/2014 Re Cap - Object Design Close the gap between the application objects and the off-the shelf components.

More information

Final Exam. Final Exam Review. Ch 1: Introduction: Object-oriented analysis, design, implementation. Exam Format

Final Exam. Final Exam Review. Ch 1: Introduction: Object-oriented analysis, design, implementation. Exam Format Final Exam Final Exam Review CS 4354 Fall 2012 Jill Seaman Friday, December 14, 11AM Closed book, closed notes, clean desk Content: Textbook: Chapters 1, 2, 4-10 Java Lectures, GRASP + JUnit 35% of your

More information

Chapter 8, Object Design: Reusing Pattern Solutions

Chapter 8, Object Design: Reusing Pattern Solutions Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 8, Object Design: Reusing Pattern Solutions Application Objects and Solution Objects Application objects, also called domain objects,

More information

Lecture 20: Implementation () / 33

Lecture 20: Implementation () / 33 Lecture 20: Implementation 15.07.2013 () 15.07.2013 1 / 33 Contents Implementation Implementation Principles Example: Eight Queens by Refinement () 15.07.2013 2 / 33 Implementation Input: software architecture,

More information

Chapter 7, System Design: Addressing Design Goals

Chapter 7, System Design: Addressing Design Goals Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 7, System Design: Addressing Design Goals Overview System Design I ü 0. Overview of System Design ü 1. Design Goals ü 2. Subsystem

More information

References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 10/14/2004 1

References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 10/14/2004 1 References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 10/14/2004 1 Assertions Statements about input to a routine or state of a class Have two primary roles As documentation,

More information

Why Design by Contract! CS 619 Introduction to OO Design and Development. Design by Contract. Fall 2012

Why Design by Contract! CS 619 Introduction to OO Design and Development. Design by Contract. Fall 2012 Why Design by Contract What s the difference with Testing? CS 619 Introduction to OO Design and Development Design by Contract Fall 2012 Testing tries to diagnose (and cure) defects after the facts. Design

More information

Assertions. Assertions - Example

Assertions. Assertions - Example References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 11/13/2003 1 Assertions Statements about input to a routine or state of a class Have two primary roles As documentation,

More information

EINDHOVEN UNIVERSITY OF TECHNOLOGY

EINDHOVEN UNIVERSITY OF TECHNOLOGY EINDHOVEN UNIVERSITY OF TECHNOLOGY Department of Mathematics & Computer Science Exam Programming Methods, 2IP15, Wednesday 17 April 2013, 09:00 12:00 TU/e THIS IS THE EXAMINER S COPY WITH (POSSIBLY INCOMPLETE)

More information

Chapter 5, Analysis: Dynamic Modeling

Chapter 5, Analysis: Dynamic Modeling Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 5, Analysis: Dynamic Modeling An overview of OOSE development activities and their products Problem Statement Requirements Elicitation

More information

Introduction to Software Engineering. 5. Modeling Objects and Classes

Introduction to Software Engineering. 5. Modeling Objects and Classes Introduction to Software Engineering 5. Modeling Objects and Classes Roadmap > UML Overview > Classes, attributes and operations > UML Lines and Arrows > Parameterized Classes, Interfaces and Utilities

More information

Assertions, pre/postconditions

Assertions, pre/postconditions Programming as a contract Assertions, pre/postconditions Assertions: Section 4.2 in Savitch (p. 239) Specifying what each method does q Specify it in a comment before method's header Precondition q What

More information

CSE 70 Final Exam Fall 2009

CSE 70 Final Exam Fall 2009 Signature cs70f Name Student ID CSE 70 Final Exam Fall 2009 Page 1 (10 points) Page 2 (16 points) Page 3 (22 points) Page 4 (13 points) Page 5 (15 points) Page 6 (20 points) Page 7 (9 points) Page 8 (15

More information

Outline. iterator review iterator implementation the Java foreach statement testing

Outline. iterator review iterator implementation the Java foreach statement testing Outline iterator review iterator implementation the Java foreach statement testing review: Iterator methods a Java iterator only provides two or three operations: E next(), which returns the next element,

More information

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107 A abbreviations 17 abstract class 105 abstract data types 105 abstract method 105 abstract types 105 abstraction 92, 105 access level 37 package 114 private 115 protected 115 public 115 accessors 24, 105

More information

Top Down Design vs. Modularization

Top Down Design vs. Modularization 6.170 Quiz Review Topics: 1. Decoupling 2. 3. AF & RI 4. Iteration Abstraction & Iterators 5. OMs and Invariants 6. Equality, Copying, Views 7. 8. Design Patterns 9. Subtyping 10. Case Studies Decomposition

More information

Fault, Error, and Failure

Fault, Error, and Failure Fault, Error, and Failure Testing, Quality Assurance, and Maintenance Winter 2018 Prof. Arie Gurfinkel based on slides by Prof. Lin Tan and others Terminology, IEEE 610.12-1990 Fault -- often referred

More information

INTERNAL ASSESSMENT TEST III Answer Schema

INTERNAL ASSESSMENT TEST III Answer Schema INTERNAL ASSESSMENT TEST III Answer Schema Subject& Code: Object-Oriented Modeling and Design (15CS551) Sem: V ISE (A & B) Q. No. Questions Marks 1. a. Ans Explain the steps or iterations involved in object

More information

Chapter 6 Introduction to Defining Classes

Chapter 6 Introduction to Defining Classes Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of

More information

UML class diagrams. Giuseppe Lipari June 8, Scuola Superiore Sant Anna Pisa

UML class diagrams. Giuseppe Lipari  June 8, Scuola Superiore Sant Anna Pisa UML class diagrams Giuseppe Lipari http://retis.sssup.it Scuola Superiore Sant Anna Pisa June 8, 2009 Using UML Goal: Be able to reason about a design i.e., understand designer s intent Critique/improve

More information

Chapter 7, System Design: Addressing Design Goals

Chapter 7, System Design: Addressing Design Goals Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 7, System Design: Addressing Design Goals Overview System Design I ü 0. Overview of System Design ü 1. Design Goals ü 2. Subsystem

More information

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L Inheritance Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 9.4 1 Inheritance Inheritance allows a software developer to derive

More information

Introduction to Software Engineering: Object Design I Reuse & Patterns

Introduction to Software Engineering: Object Design I Reuse & Patterns Introduction to Software Engineering: Object Design I Reuse & Patterns John T. Bell Department of Computer Science University of Illinois, Chicago Based on materials from Bruegge & DuToit 3e, Chapter 8,

More information

Chapter 5, Analysis: Dynamic Modeling

Chapter 5, Analysis: Dynamic Modeling Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 5, Analysis: Dynamic Modeling ü Requirements Elicitation (Ch.4) ü Introduction (Ch 1-3) OOSE- Galaxy ü Nonfunctional Requirements

More information

BCS Higher Education Qualifications. Diploma in IT. Object Oriented Programming Syllabus

BCS Higher Education Qualifications. Diploma in IT. Object Oriented Programming Syllabus BCS Higher Education Qualifications Diploma in IT Object Oriented Programming Syllabus Version 3.0 December 2016 This is a United Kingdom government regulated qualification which is administered and approved

More information

Chapter 7, System Design: Addressing Design Goals

Chapter 7, System Design: Addressing Design Goals Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 7, System Design: Addressing Design Goals Overview System Design I ü 0. Overview of System Design ü 1. Design Goals ü 2. Subsystem

More information

Chapter 7, System Design: II Addressing Design Goals

Chapter 7, System Design: II Addressing Design Goals Chapter 7, System Design: II Addressing Design Goals Overview System Design I 0. Overview of System Design 1. Design Goals 2. Subsystem Decomposition Architectural Styles System Design II 3. Concurrency

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

Chapter 11, Testing. Using UML, Patterns, and Java. Object-Oriented Software Engineering

Chapter 11, Testing. Using UML, Patterns, and Java. Object-Oriented Software Engineering Chapter 11, Testing Using UML, Patterns, and Java Object-Oriented Software Engineering Outline Terminology Types of errors Dealing with errors Quality assurance vs Testing Component Testing! Unit testing!

More information

7. Implementation Phase. 7.1 Architecture Diagrams 7.2 OO Languages: Java 7.3 Constraint Languages: OCL

7. Implementation Phase. 7.1 Architecture Diagrams 7.2 OO Languages: Java 7.3 Constraint Languages: OCL 7. Implementation Phase 7.1 Architecture Diagrams 7.2 OO Languages: Java 7.3 Constraint Languages: OCL Architecture Design Models An architecture model (structure model) is a model of a data processing

More information

Chapter 5, Analysis: Object Modeling

Chapter 5, Analysis: Object Modeling Chapter 5, Analysis: Object Modeling Résumé Maintenant: Modélisation des objets du domaine La partie statique (diagramme de classe) Les activités durant la modélisation des objets L identification des

More information

CO Java SE 8: Fundamentals

CO Java SE 8: Fundamentals CO-83527 Java SE 8: Fundamentals Summary Duration 5 Days Audience Application Developer, Developer, Project Manager, Systems Administrator, Technical Administrator, Technical Consultant and Web Administrator

More information

Design Patterns 2. Page 1. Software Requirements and Design CITS 4401 Lecture 10. Proxy Pattern: Motivation. Proxy Pattern.

Design Patterns 2. Page 1. Software Requirements and Design CITS 4401 Lecture 10. Proxy Pattern: Motivation. Proxy Pattern. Proxy : Motivation Design s 2 It is 3pm. I am sitting at my 10Mbps connection and go to browse a fancy web page from the US, This is prime web time all over the US. So I am getting 100kbps What can you

More information

How We Refactor, and How We Know It

How We Refactor, and How We Know It Emerson Murphy-Hill, Chris Parnin, Andrew P. Black How We Refactor, and How We Know It Urs Fässler 30.03.2010 Urs Fässler () How We Refactor, and How We Know It 30.03.2010 1 / 14 Refactoring Definition

More information

Chapter 4 Requirements Elicitation

Chapter 4 Requirements Elicitation Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 4 Requirements Elicitation Outline Today: Motivation: Software Lifecycle Requirements elicitation challenges Problem statement

More information

Chapter 8, Object Design: Reuse and Patterns

Chapter 8, Object Design: Reuse and Patterns Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Reuse and Patterns Object Design Purpose of object design: Prepare for the implementation of the system model

More information

Fortgeschrittene objektorientierte Programmierung (Advanced Object-Oriented Programming)

Fortgeschrittene objektorientierte Programmierung (Advanced Object-Oriented Programming) 2014-03-07 Preface Fortgeschrittene objektorientierte Programmierung (Advanced Object-Oriented Programming) Coordinates: Lecturer: Web: Studies: Requirements: No. 185.211, VU, 3 ECTS Franz Puntigam http://www.complang.tuwien.ac.at/franz/foop.html

More information

Tutorial notes on. Object relational structural patterns

Tutorial notes on. Object relational structural patterns Tutorial notes on Object relational structural patterns Dr. C. Constantinides, P.Eng. Computer Science and Software Engineering Concordia University Page 1 of 14 Exercise 1. a) Briefly describe what is

More information

More on Inheritance. Interfaces & Abstract Classes

More on Inheritance. Interfaces & Abstract Classes More on Inheritance Interfaces & Abstract Classes Java interfaces A Java interface is used to specify minimal functionality that a client requires of a server. A Java interface contains: method specifications

More information

Reverse engineering UML classes from source files

Reverse engineering UML classes from source files Instant Reverse is a process to produce UML class model from a given input of source code. With instant reverse, you can reverse a snap shot of your code-base to UML classes and form class diagram in further.

More information

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17 List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code

More information

Chapter 11, Testing, Part 2: Integration and System Testing

Chapter 11, Testing, Part 2: Integration and System Testing Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 11, Testing, Part 2: Integration and System Testing Overview Integration testing Big bang Bottom up Top down Sandwich System testing

More information

UC Santa Barbara. CS189A - Capstone. Christopher Kruegel Department of Computer Science UC Santa Barbara

UC Santa Barbara. CS189A - Capstone. Christopher Kruegel Department of Computer Science UC Santa Barbara CS189A - Capstone Christopher Kruegel Department of Computer Science http://www.cs.ucsb.edu/~chris/ Design by Contract Design by Contract and the language that implements the Design by Contract principles

More information

Chapter 11, Testing, Part 2: Integration and System Testing

Chapter 11, Testing, Part 2: Integration and System Testing Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 11, Testing, Part 2: Integration and System Testing Overview Integration testing Big bang Bottom up Top down Sandwich System testing

More information

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models CS 494 Object-Oriented Analysis & Design UML Class Models Overview How class models are used? Perspectives Classes: attributes and operations Associations Multiplicity Generalization and Inheritance Aggregation

More information

Review sheet for Final Exam (List of objectives for this course)

Review sheet for Final Exam (List of objectives for this course) Review sheet for Final Exam (List of objectives for this course) Please be sure to see other review sheets for this semester Please be sure to review tests from this semester Week 1 Introduction Chapter

More information

Chapter 11: Data Management Layer Design

Chapter 11: Data Management Layer Design Systems Analysis and Design With UML 2.0 An Object-Oriented Oriented Approach, Second Edition Chapter 11: Data Management Layer Design Alan Dennis, Barbara Wixom, and David Tegarden 2005 John Wiley & Sons,

More information

Chapter 5, Object Modeling

Chapter 5, Object Modeling Chapter 5, Object Modeling Using UML, Patterns, and Java Object-Oriented Software Engineering Where we are, where we are going problem statement Requirements elicitation Requirements Specification nonfunctional

More information

n Specifying what each method does q Specify it in a comment before method's header n Precondition q Caller obligation n Postcondition

n Specifying what each method does q Specify it in a comment before method's header n Precondition q Caller obligation n Postcondition Programming as a contract Assertions, pre/postconditions and invariants Assertions: Section 4.2 in Savitch (p. 239) Loop invariants: Section 4.5 in Rosen Specifying what each method does q Specify it in

More information

COURSE 2 DESIGN PATTERNS

COURSE 2 DESIGN PATTERNS COURSE 2 DESIGN PATTERNS CONTENT Fundamental principles of OOP Encapsulation Inheritance Abstractisation Polymorphism [Exception Handling] Fundamental Patterns Inheritance Delegation Interface Abstract

More information

Object-Oriented Software Engineering Practical Software Development using UML and Java

Object-Oriented Software Engineering Practical Software Development using UML and Java Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes Lecture 5 5.1 What is UML? The Unified Modelling Language is a standard graphical

More information

UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED

UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED EXERCISE 11.1 1. static public final int DEFAULT_NUM_SCORES = 3; 2. Java allocates a separate set of memory cells in each instance

More information

Classes, interfaces, & documentation. Review of basic building blocks

Classes, interfaces, & documentation. Review of basic building blocks Classes, interfaces, & documentation Review of basic building blocks Objects Data structures literally, storage containers for data constitute object knowledge or state Operations an object can perform

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation

More information

Prelim 1 SOLUTION. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants. Recursion OO Short answer

Prelim 1 SOLUTION. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants. Recursion OO Short answer Prelim 1 SOLUTION CS 2110, September 29, 2016, 7:30 PM 0 1 2 3 4 5 Total Question Name Loop invariants Recursion OO Short answer Exception handling Max 1 15 15 25 34 10 100 Score Grader 0. Name (1 point)

More information

CS61BL Summer 2013 Midterm 2

CS61BL Summer 2013 Midterm 2 CS61BL Summer 2013 Midterm 2 Sample Solutions + Common Mistakes Question 0: Each of the following cost you.5 on this problem: you earned some credit on a problem and did not put your five digit on the

More information

Implementing a List in Java. CSE 143 Java. Just an Illusion? List Interface (review) Using an Array to Implement a List.

Implementing a List in Java. CSE 143 Java. Just an Illusion? List Interface (review) Using an Array to Implement a List. Implementing a List in Java CSE 143 Java List Implementation Using Arrays Reading: Ch. 13 Two implementation approaches are most commonly used for simple lists: Arrays Linked list Java Interface List concrete

More information

Software Engineering (CSC 4350/6350) Rao Casturi

Software Engineering (CSC 4350/6350) Rao Casturi Software Engineering (CSC 4350/6350) Rao Casturi Testing Software Engineering -CSC4350/6350 - Rao Casturi 2 Testing What is testing? Process of finding the divergence between the expected behavior of the

More information

Array Based Lists. Collections

Array Based Lists. Collections Array Based Lists Reading: RS Chapter 15 1 Collections Data structures stores elements in a manner that makes it easy for a client to work with the elements Specific collections are specialized for particular

More information

OO Design Principles

OO Design Principles OO Design Principles Software Architecture VO (706.706) Roman Kern Institute for Interactive Systems and Data Science, TU Graz 2018-10-10 Roman Kern (ISDS, TU Graz) OO Design Principles 2018-10-10 1 /

More information

Object Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance

Object Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance CS257 Computer Science I Kevin Sahr, PhD Lecture 10: Inheritance 1 Object Oriented Features For a programming language to be called object oriented it should support the following features: 1. objects:

More information

Object-oriented basics. Object Class vs object Inheritance Overloading Interface

Object-oriented basics. Object Class vs object Inheritance Overloading Interface Object-oriented basics Object Class vs object Inheritance Overloading Interface 1 The object concept Object Encapsulation abstraction Entity with state and behaviour state -> variables behaviour -> methods

More information

Object- Oriented Analysis, Design and Programming

Object- Oriented Analysis, Design and Programming Object- Oriented Analysis, Design and Programming Medialogy, Semester 4 Monday 19 April 2010 9.00 12.00 You have 3 hours to complete this examination. Neither written material nor electronic equipment

More information

Chapter 5, Analysis: Dynamic Modeling

Chapter 5, Analysis: Dynamic Modeling Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 5, Analysis: Dynamic Modeling ü Requirements Elicitation (Ch.4) ü Introduction (Ch 1-3) OOSE- Galaxy ü Nonfunctional Requirements

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Outline. Subtype Polymorphism, Subtyping vs. Subclassing, Liskov Substitution Principle. Benefits of Subtype Polymorphism. Subtype Polymorphism

Outline. Subtype Polymorphism, Subtyping vs. Subclassing, Liskov Substitution Principle. Benefits of Subtype Polymorphism. Subtype Polymorphism Subtype, Subtyping vs. Subclassing, Liskov Substitution Principle Outline Subtype polymorphism Subtyping vs. subclassing Liskov Substitution Principle (LSP) Function subtyping Java subtyping Composition:

More information

SOFTWARE ENGINEERING SOFTWARE EVOLUTION. Saulius Ragaišis.

SOFTWARE ENGINEERING SOFTWARE EVOLUTION. Saulius Ragaišis. SOFTWARE ENGINEERING SOFTWARE EVOLUTION Saulius Ragaišis saulius.ragaisis@mif.vu.lt CSC2008 SE Software Evolution Learning Objectives: Identify the principal issues associated with software evolution and

More information

In this Lecture you will Learn: Object Design. Information Sources for Object Design. Class Specification: Attributes

In this Lecture you will Learn: Object Design. Information Sources for Object Design. Class Specification: Attributes In this Lecture you will Learn: Object Design Chapter 14 How to apply criteria for good design How to design associations The impact of integrity constraints on design How to design operations The role

More information

2/12/15. Template Method. Design Patterns. In Swing s JComponent. Template Method. Where do template methods come from? Making Template Methods

2/12/15. Template Method. Design Patterns. In Swing s JComponent. Template Method. Where do template methods come from? Making Template Methods Design Patterns Template Method Problem: Some classes have a similar algorithm, but it is a little different for each class. Solution: Define the skeleton of the algorithm as a method in a superclass,

More information

n HW5 out, due Tuesday October 30 th n Part 1: Questions on material we ll cover today n Part 2: BFS using your graph from HW4

n HW5 out, due Tuesday October 30 th n Part 1: Questions on material we ll cover today n Part 2: BFS using your graph from HW4 Subtype, Subtyping vs. Subclassing, Liskov Substitution Principle Announcements n HW5 out, due Tuesday October 30 th n Part 1: Questions on material we ll cover today n Part 2: BFS using your graph from

More information

Objects and Classes. Basic OO Principles. Classes in Java. Mark Allen Weiss Copyright 2000

Objects and Classes. Basic OO Principles. Classes in Java. Mark Allen Weiss Copyright 2000 Objects and Classes Mark Allen Weiss Copyright 2000 8/30/00 1 Basic OO Principles Objects are entities that have structure and state. Each object defines operations that may access or manipulate that state.

More information

Goals of design. satisfies problem requirements, usable error free, resistant to incorrect input. readable, not purposefully cryptic.

Goals of design. satisfies problem requirements, usable error free, resistant to incorrect input. readable, not purposefully cryptic. OOP design revisited design revisited 1 Goals of design usable software robust implementable understandable reusable generalizable extendable solves the problem, satisfies problem requirements, usable

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation

More information

Page 1. Chapter 8, Object Design: Design Patterns II. Recall: Why reusable Designs? Definitions. A Taxonomy of Design Patterns

Page 1. Chapter 8, Object Design: Design Patterns II. Recall: Why reusable Designs? Definitions. A Taxonomy of Design Patterns Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 8, Object Design: Design Patterns II Recall: Why reusable Designs? A design enables flexibility to change (reusability) minimizes

More information

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 5: Modelling with Classes

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 5: Modelling with Classes Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes 5.1 What is UML? The Unified Modelling Language is a standard graphical language

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Chapter 4.!Data Abstraction: The Walls! 2011 Pearson Addison-Wesley. All rights reserved 4-1

Chapter 4.!Data Abstraction: The Walls! 2011 Pearson Addison-Wesley. All rights reserved 4-1 Chapter 4!Data Abstraction: The Walls! 2011 Pearson Addison-Wesley. All rights reserved 4-1 2015-09-29 11:44:25 1/45 Chapter-04.pdf (#4) bubblesort(int[] a) { int last = a.length - 1; while (last > 0)

More information

Chief Reader Report on Student Responses:

Chief Reader Report on Student Responses: Chief Reader Report on Student Responses: 2017 AP Computer Science A Free-Response Questions Number of Students Scored 60,519 Number of Readers 308 Score Distribution Exam Score N %At Global Mean 3.15

More information

Chapter 2, lecture 2 Modeling with UML

Chapter 2, lecture 2 Modeling with UML Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 2, lecture 2 Modeling with UML Overview: More detail on modeling with UML Use case diagrams Class diagrams Sequence diagrams Activity

More information

17. Assertions. Outline. Built-in tests. Built-in tests 3/29/11. Jelle Slowack, Bart Smets, Glenn Van Loon, Tom Verheyen

17. Assertions. Outline. Built-in tests. Built-in tests 3/29/11. Jelle Slowack, Bart Smets, Glenn Van Loon, Tom Verheyen 17. Assertions Jelle Slowack, Bart Smets, Glenn Van Loon, Tom Verheyen Outline Introduction (BIT, assertion, executable assertion, why?) Implementation-based vs responsability-based assertions Implementation

More information

Chapter 8, Design Patterns Visitor

Chapter 8, Design Patterns Visitor Chapter 8, Design Patterns Visitor Using UML, Patterns, and Java Object-Oriented Software Engineering Pattern A Pattern Taxonomy Structural Pattern Behavioral Pattern Creational Pattern Composite Decorator

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

17. Assertions. Jelle Slowack, Bart Smets, Glenn Van Loon, Tom Verheyen

17. Assertions. Jelle Slowack, Bart Smets, Glenn Van Loon, Tom Verheyen 17. Assertions Jelle Slowack, Bart Smets, Glenn Van Loon, Tom Verheyen Outline Introduction (BIT, assertion, executable assertion, why?) Implementation-based vs responsability-based assertions Implementation

More information

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass

More information

Assertions & Design-by-Contract using JML Erik Poll University of Nijmegen

Assertions & Design-by-Contract using JML Erik Poll University of Nijmegen Assertions & Design-by-Contract using JML Erik Poll University of Nijmegen Erik Poll - JML p.1/39 Overview Assertions Design-by-Contract for Java using JML Contracts and Inheritance Tools for JML Demo

More information