Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 10, Mapping Models to Code

Similar presentations


Presentation on theme: "Chapter 10, Mapping Models to Code"— Presentation transcript:

1 Chapter 10, Mapping Models to Code

2 Lecture Plan Part 1 Part 2 Operations on the object model:
Optimizations to address performance requirements Implementation of class model components: Realization of associations Realization of operation contracts Part 2 Realizing entity objects based on selected storage strategy Mapping the object model to a storage schema Mapping class diagrams to tables Object design is situated between system design and implementation. Object design is not very well understood and if not well done, leads to a bad system implementation. In this lecture, we describe a selection of transformations to illustrate a disciplined approach to implementation to avoid system degradation

3 Problems with implementing an Object Design Model
Programming languages do not support the concept of UML associations The associations of the object model must be transformed into collections of object references Many programming languages do not support contracts (invariants, pre and post conditions) Developers must therefore manually transform contract specification into source code for detecting and handling contract violations The client changes the requirements during object design The developer must change the contracts in which the classes are involved All these object design activities cause problems, because they need to be done manually.

4 Let us get a handle on these problems
To do this we distinguish two kinds of spaces the model space and the source code space and 4 different types of transformations Model transformation Forward engineering Reverse engineering Refactoring.

5 4 Different Types of Transformations
Program (in Java) Yet Another System Model Another System Model Forward engineering Model space Source code space Refactoring Model transformation Another Program Reverse engineering System Model (in UML)

6 Model Transformation Takes as input a model conforming to a meta model (for example the MOF metamodel) and produces as output another model conforming to the metamodel Model transformations are used in MDA (Model Driven Architecture).

7 Model Transformation Example
Object design model before transformation: LeagueOwner - Address Advertiser - Address Player - Address Object design model after transformation: Player Advertiser LeagueOwner User + Address

8 Model space Source code space Forward engineering Refactoring
Program (in Java) Yet Another System Model Another System Model Forward engineering Model space Source code space Refactoring Model transformation Another Program Reverse engineering System Model (in UML)

9 Refactoring : 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 { }.

10 Refactoring Example: Pull Up Constructor Body
public class User { public User(String ) { this. = ; } public class User { private String ; } public class Player extends User { public Player(String ) { this. = ; public class LeagueOwner extends User{ public LeagueOwner(String ) { public class Advertiser extends User{ public Advertiser(String ) { public class Player extends User { public Player(String ) { super( ); } public class LeagueOwner extends User { public LeagueOwner(String ) { public class Advertiser extends User { public Advertiser(String ) { }.

11 4 Different Types of Transformations
Program (in Java) Yet Another System Model Another System Model Forward engineering Model space Source code space Refactoring Model transformation Another Program Reverse engineering System Model (in UML)

12 Forward Engineering Example
Object design model before transformation: LeagueOwner -maxNumLeagues:int +getMaxNumLeagues():int +setMaxNumLeagues(n:int) User - String +get ():String +set (e:String) +notify(msg:String) Source code after transformation: public class User { private String ; public String get () { return ; } public void set (String e){ = e; public void notify(String msg) { // .... public class LeagueOwner extends User { private int maxNumLeagues; public int getMaxNumLeagues() { return maxNumLeagues; } public void setMaxNumLeagues(int n) { maxNumLeagues = n;

13 More Forward Engineering Examples
Model Transformations Goal: Optimizing the object design model Collapsing objects Delaying expensive computations Forward Engineering Goal: Implementing the object design model in a programming language Mapping inheritance Mapping associations Mapping contracts to exceptions Mapping object models to tables

14 Collapsing Objects Object design model before transformation:
Person SocialSecurity number:String Object design model after transformation: Person SSN:String Turning an object into an attribute of another object is usually done, if the object does not have any interesting dynamic behavior (only get and set operations).

15 Examples of Model Transformations and Forward Engineering
Goal: Optimizing the object design model Collapsing objects Delaying expensive computations Forward Engineering Goal: Implementing the object design model in a programming language Mapping inheritance Mapping associations Mapping contracts to exceptions Mapping object models to tables

16 Delaying expensive operations
Object design model before transformation: Image filename:String paint() data:byte[] Question: Which pattern is being used here? Answer: The proxy pattern! Why: Image is an analysis domain object, the proxy pattern subclasses Imageproxy and RealImage are solution domain objects! Object design model after transformation: Image filename:String RealImage data:byte[] ImageProxy image 1 0..1 paint() Proxy Pattern

17 Examples of Model Transformations and Forward Engineering
Goal: Optimizing the object design model Collapsing objects Delaying expensive computations Forward Engineering Goal: Implementing the object design model in a programming language Mapping inheritance Mapping associations Mapping contracts to exceptions Mapping object models to tables

18 Forward Engineering: Mapping a UML Model into Source Code
Goal: We have a UML-Model with inheritance. We want to translate it into source code Question: Which mechanisms in the programming language can be used? Let’s focus on Java Java provides the following mechanisms: Overwriting of methods (default in Java) Final classes Final methods Abstract methods Abstract classes Interfaces. For each of these mechanisms a project manager can specify heuristics to use them properly

19 Realizing Inheritance in Java
Realisation of specialization and generalization Definition of subclasses Java keyword: extends Realisation of simple inheritance Overwriting of methods is not allowed Java keyword: final Realisation of implementation inheritance Overwriting of methods No keyword necessary: Overwriting of methods is default in Java Realisation of specification inheritance Specification of an interface Java keywords: abstract, interface. Java offers several techniques to realize the different types of inheritance: Realisation of simple inheritance also called strict inheritance

20 Examples of Model Transformations and Forward Engineering
Goal: Optimizing the object design model Collapsing objects Delaying expensive computations Forward Engineering Goal: Implementing the object design model in a programming language Mapping inheritance Mapping associations Mapping contracts to exceptions Mapping object models to tables

21 Mapping Associations Unidirectional one-to-one association
Bidirectional one-to-one association Bidirectional one-to-many association Bidirectional many-to-many association Bidirectional qualified association.

22 Unidirectional one-to-one association
Object design model before transformation: 1 1 Advertiser Account Source code after transformation: public class Advertiser { private Account account; public Advertiser() { account = new Account(); } If Advertiser accesses only Account, but not vice versa, the class Account can be made a local attribute in the Advertiser class

23 Bidirectional one-to-one association
Object design model before transformation: Advertiser 1 1 Account + getAcount (): Account + getOwner (): Advertiser Source code after transformation: public class Advertiser { /* account 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 { /* owner is initialized * in the constructor and * never modified. */ private Advertiser owner; public Account(Advertiser owner) { this.owner = owner; } public Advertiser getOwner() { return owner;

24 Bidirectional one-to-many association
Object design model before transformation: 1 * Advertiser Account + addAcount (a: Account) + setOwner (Advertiser: NewOwner) + removeAcount (a: 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); } HastSet implements the Set interface, backed by a hash table (actually a HashMap instance (see It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time. This class permits the null element.This class offers constant time performance for the basic operations (add, remove, contains and size), assuming the hash function disperses the elements properly among the buckets. Iterating over this set requires time proportional to the sum of the HashSet instance's size (the number of elements) plus the "capacity" of the backing HashMap instance (the number of buckets). Thus, it's very important not to set the initial capacity too high (or the load factor too low) if iteration performance is important.

25 Bidirectional many-to-many association
Object design model before transformation Tournament * {ordered} * Player * +addTournament(t: Tournament) + addPlayer(p: 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);

26 Examples of Model Transformations and Forward Engineering
Goal: Optimizing the object design model Collapsing objects Delaying expensive computations Forward Engineering Goal: Implementing the object design model in a programming language Mapping inheritance Mapping associations Mapping contracts to exceptions Mapping object models to tables Moved to Exercise Session on Testing Next!

27 Summary Strategy for implementing associations:
Be as uniform as possible Individual decision for each association Example of uniform implementation 1-to-1 association: Role names are treated like attributes in the classes and translate to references 1-to-many association: "Ordered many" : Translate to Vector "Unordered many" : Translate to Set Qualified association: Translate to Hash table Not covered in Fall 91 class

28 Additional Slides

29 Heuristics for Transformations
For any given transformation always use the same tool Keep the contracts in the source code, not in the object design model Use the same names for the same objects Have a style guide for transformations (Martin Fowler) For a given transformation use the same tool If you are using a CASE tool to map associations to code, use the tool to change association multiplicities. Keep the contracts in the source code, not in the object design model By keeping the specification as a source code comment, they are more likely to be updated when the source code changes. Use the same names for the same objects If the name is changed in the model, change the name in the code and or in the database schema. Provides traceability among the models Have a style guide for transformations By making transformations explicit in a manual, all developers can apply the transformation in the same way.

30 Generalization: Finding the super class
You need to prepare or modify your classes for generalization All operations must have the same signature but often the signatures do not match Superclasses are desirable. They increase modularity, extensibility and reusability improve configuration management Many design patterns use superclasses Try to retrofit an existing model to allow the use of a design pattern. You need to prepare or modify your classes for generalization. All operations must have the same signature but often the signatures do not match: Some operations have fewer arguments than others: Use overloading (Possible in Java) Similar attributes in the classes have different names: Rename attribute and change all the operations. Operations defined in one class but no in the other: Use virtual functions and class function overriding. Superclasses are desirable. They increase modularity, extensibility and reusability improve configuration management Many design patterns use superclasses Try to retrofit an existing model to allow the use of a design pattern

31 Object Design Areas 1. Service specification 2. Component selection
Describes precisely each class interface 2. Component selection Identify off-the-shelf components and additional solution objects 3. Object model restructuring Transforms the object design model to improve its understandability and extensibility 4. Object model optimization Transforms the object design model to address performance criteria such as response time or memory utilization.

32 Design Optimizations Design optimizations are an important part of the object design phase: The requirements analysis model is semantically correct but often too inefficient if directly implemented Optimization activities during object design: 1. Add redundant associations to minimize access cost 2. Rearrange computations for greater efficiency 3. Store derived attributes to save computation time As an object designer you must strike a balance between efficiency and clarity Optimizations will make your models more obscure. Not covered in Fall 91 class

33 Object Design Optimization Activities
1. Add redundant associations: What are the most frequent operations? ( Sensor data lookup?) How often is the operation called? (30 times a month, every 50 milliseconds) 2. Rearrange execution order Eliminate dead paths as early as possible (Use knowledge of distributions, frequency of path traversals) Narrow search as soon as possible Check if execution order of loop should be reversed 3. Turn classes into attributes. Not covered in Fall 91 class

34 Object Design Optimizations (continued)
Store derived attributes Example: Define new classes to store information locally (database cache, proxy pattern) Problem with derived attributes: Derived attributes must be updated when base values change There are 3 ways to deal with the update problem: Explicit code: Implementor determines affected derived attributes (push) Periodic computation: Recompute derived attribute occasionally (pull) Active value: An attribute can designate set of dependent values which are automatically updated when the active value is changed (observer pattern, data trigger).

35 Increase Inheritance Rearrange and adjust classes and operations to prepare for inheritance Generalization: Finding the base class first, then the sub classes Specialization: Finding the the sub classes first, then the base class Generalization is a common modeling activity. It allows to abstract common behavior out of a group of classes If a set of operations or attributes are repeated in 2 classes the classes might be special instances of a more general class Always check if it is possible to change a subsystem (collection of classes) into a superclass in an inheritance hierarchy.

36 Heuristics for Implementing Associations
Two strategies for implementing associations: 1. Be as uniform as possible 2. Make an individual decision for each association Example of a uniform implementation (often used by CASE tools) 1-to-1 association: Role names are always treated like attributes in the classes and translated into references 1-to-many association: Always translated into a Vector Qualified association: Always translated into to a Hash table. Not covered in Fall 91 class

37 Model-Driven Engineering
Model-driven engineering refers to a range of development approaches that are based on the use of software modeling as a primary form of expression. Sometimes models are constructed to a certain level of detail, and then code is written by hand in a separate step. Sometimes complete models are built including executable actions. Code can be generated from the models, ranging from system skeletons to complete, deployable products. With the introduction of the Unified Modeling Language (UML), MDE has become very popular today with a wide body of practitioners and supporting tools. More advanced types of MDE have expanded to permit industry standards which allow for consistent application and results. The continued evolution of MDE has added an increased focus on architecture and automation. MDE technologies with a greater focus on architecture and corresponding automation yield higher levels of abstraction in software development. This abstraction promotes simpler models with a greater focus on problem space. Combined with executable semantics this elevates the total level of automation possible. The Object Management Group (OMG) has developed a set of standards called model-driven architecture (MDA), building a foundation for this advanced architecture-focused approach.

38 A Historical View on MDE
The first tools to support MDE were the Computer-Aided Software Engineering (CASE) tools developed in the 1980s Companies like Integrated Development Environments (IDE - StP), Higher Order Software (now Hamilton Technologies, Inc., HTI), Cadre Technologies, Bachman Information Systems, and Logicworks (BP-Win and ER-Win) were pioneers in the field. Except for HTI's 001AXES Universal Systems Language (USL) and its associated automation (001), The government got involved in the modeling definitions creating the IDEF specifications. Several modeling languages appeared (Grady Booch, Jim Rumbaugh, Iva Jacobson, Ganes, Sarson, Harel, Shlaer, Mellor, and many others) leading eventually to the Unified Modeling Language (UML). Rational Rose was the first dominant product for UML implementation developed by Rational Corporation which was acquired by IBM in 2002. CASE had the same problem that the current MDA/MDE tools have today: the model gets out of sync with the source code. To be continued

39 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 2 binary associations Tournament Player * 1 Statistics + getAverageStat(name) getTotalStat(name) updateStats(match)

40 Review: Terminology Roundtrip Engineering Reengineering
Forward Engineering + reverse engineering Inventory analysis: Determine the Delta between Object Model and Code Together-J and Rationale provide tools for reverse engineering Reengineering Used in the context of project management: Provding new functionality (customer dreams up new stuff) in the context of new technology (technology enablers)

41 Specifying Interfaces
The players in object design: Class User Class Implementor Class Extender Object design: Activities Adding visibility information Adding type signature information Adding contracts Detailed view on Design patterns Combination of delegation and inheritance

42 Statistics as a product in the Game Abstract Factory
Tournament Game createStatistics() TicTacToeGame ChessGame Statistics update() getStat() TTTStatistics ChessStatistics DefaultStatistics

43 N-ary association class Statistics
Statistics relates League, Tournament, and Player Statistics 1 * 1 1 0..1 0..1 0..1 0..1 Game League Tournament Player

44 Realisation of the Statistics Association
TournamentControl StatisticsView StatisticsVault Statistics update(match) update(match,player) getStatNames(game) getStatNames() getStat(name) getStat(name,game,player) getStat(name,league,player) getStat(name,tournament,player) Game createStatistics()

45 StatisticsVault as a Facade
TournamentControl StatisticsView StatisticsVault Statistics update(match) update(match,player) getStatNames(game) getStatNames() getStat(name) getStat(name,game,player) getStat(name,league,player) Game getStat(name,tournament,player) createStatistics()

46 Public interface of the StatisticsVault class
public class StatisticsVault { public void update(Match m) throws InvalidMatch, MatchNotCompleted {...} public List getStatNames() {...} public double getStat(String name, Game g, Player p) throws UnknownStatistic, InvalidScope {...} public double getStat(String name, League l, Player p) public double getStat(String name, Tournament t, Player p) }

47 Database schema for the Statistics Association
Statistics table id:long scope:long scopetype:long player:long StatisticCounters table id:long name:text[25] value:double Game table League table T ournament table id:long ... id:long ... id:long ...

48 Restructuring Activities
Realizing associations Revisiting inheritance to increase reuse Revising inheritance to remove implementation dependencies

49 Unidirectional 1-to-1 Association
Object design model before transformation ZoomInAction MapArea Object design model after transformation ZoomInAction MapArea -zoomIn:ZoomInAction +getZoomInAction() +setZoomInAction(action)

50 Bidirectional 1-to-1 Association
Object design model before transformation ZoomInAction MapArea 1 1 Object design model after transformation ZoomInAction MapArea -targetMap:MapArea -zoomIn:ZoomInAction +getTargetMap() +setTargetMap(map) +getZoomInAction() +setZoomInAction(action)

51 1-to-Many Association Object design model before transformation
Layer LayerElement 1 * Object design model after transformation Layer -layerElements:Set +elements() +addElement(le) +removeElement(le) LayerElement -containedIn:Layer +getLayer() +setLayer(l)

52 Qualification Object design model before transformation
Scenario * 0..1 SimulationRun simname Object design model after transformation Scenario SimulationRun -runs:Hashtable -scenarios:Vector +elements() +addRun(simname,sr:SimulationRun) +removeRun(simname,sr:SimulationRun) +elements() +addScenario(s:Scenario) +removeScenario(s:Scenario)

53 Increase Inheritance Rearrange and adjust classes and operations to prepare for inheritance Abstract common behavior out of groups of classes If a set of operations or attributes are repeated in 2 classes the classes might be special instances of a more general class. Be prepared to change a subsystem (collection of classes) into a superclass in an inheritance hierarchy.

54 Building a super class from several classes
Prepare for inheritance. All operations must have the same signature but often the signatures do not match Abstract out the common behavior (set of operations with same signature) and create a superclass out of it. Superclasses are desirable. They increase modularity, extensibility and reusability improve configuration management Turn the superclass into an abstract interface if possible Use Bridge pattern. Prepare for inheritance. All operations must have the same signature but often the signatures do not match: Some operations have fewer arguments than others: Use overloading (Possible in Java) Similar attributes in the classes have different names: Rename attribute and change all the operations. Operations defined in one class but no in the other: Use virtual functions and class function overriding. Abstract out the common behavior (set of operations with same signature) and create a superclass out of it. Superclasses are desirable. They increase modularity, extensibility and reusability improve configuration management Turn the superclass into an abstract interface if possible Use Bridge pattern

55 Exercise Session: Implementing Contract Violations
Many object-oriented languages do not have built-in support for contracts However, if they support exceptions, we can use their exception mechanisms 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 UML model (see slide 35) In this case acceptPlayer() in TournamentControl should throw an exception of type KnownPlayer Java Source code (see slide 36).

56 Implementing Contract Violations
Many object-oriented languages do not have built-in support for contracts However, if they support exceptions, we can use their exception mechanisms for signaling and handling contract violations In Java we use the try-throw-catch mechanism See exercise next week

57 UML Model for Contract Violation Example
TournamentControl Player players * Tournament 1 +applyForTournament() Match +playMove(p,m) +getScore():Map matches +start:Date +status:MatchStatus -maNumPlayers:String +end:Date TournamentForm +acceptPlayer(p) +removePlayer(p) +isPlayerAccepted(p) Advertiser sponsors +selectSponsors(advertisers):List +advertizeTournament() +announceTournament() +isPlayerOverbooked():boolean

58 Implementation in Java
TournamentControl Player players * Tournament 1 +applyForTournament() Match +playMove(p,m) +getScore():Map matches +start:Date +status:MatchStatus -maNumPlayers:String +end:Date TournamentForm +acceptPlayer(p) +removePlayer(p) +isPlayerAccepted(p) Advertiser sponsors +selectSponsors(advertisers):List +advertizeTournament() +announceTournament() +isPlayerOverbooked():boolean public class TournamentForm { private TournamentControl control; private ArrayList players; public void processPlayerApplications() { for (Iteration i = players.iterator(); i.hasNext();) { try { control.acceptPlayer((Player)i.next()); } catch (KnownPlayerException e) { // If exception was caught, log it to console ErrorConsole.log(e.getMessage()); Example of exception handling in Java. TournamentForm catches exceptions raised by Tournament and TournamentControl and logs them into an error console for display to the user. 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 the console ErrorConsole.log(e.getMessage());

59 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() { for (Iteration i = players.iterator(); i.hasNext();) { try { control.acceptPlayer((Player)i.next()); } catch (KnownPlayerException e) { // If exception was caught, log it to console ErrorConsole.log(e.getMessage()); Example of exception handling in Java. TournamentForm catches exceptions raised by Tournament and TournamentControl and logs them into an error console for display to the user. 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 the console ErrorConsole.log(e.getMessage());

60 TournamentControl Player players * Tournament 1 +applyForTournament() Match +playMove(p,m) +getScore():Map matches +start:Date +status:MatchStatus -maNumPlayers:String +end:Date TournamentForm +acceptPlayer(p) +removePlayer(p) +isPlayerAccepted(p) Advertiser sponsors +selectSponsors(advertisers):List +advertizeTournament() +announceTournament() +isPlayerOverbooked():boolean

61 Implementing a Contract
Check each precondition: Before the beginning of the method with a test to check the precondition for that method Raise an exception if the precondition evaluates to false Check each postcondition: At the end of the method write a test to check the postcondition Raise an exception if the postcondition evaluates to false. If more than one postcondition is not satisfied, raise an exception only for the first violation. Check each invariant: Check invariants at the same time when checking preconditions and when checking postconditions Deal with inheritance: Add the checking code for preconditions and postconditions also into methods that can be called from the class. 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.

62 A complete implementation of the Tournament.addPlayer() contract
«invariant» getMaxNumPlayers() > 0 Tournament +isPlayerAccepted(p:Player):boolean +addPlayer(p:Player) +getMaxNumPlayers():int -maxNumPlayers: int +getNumPlayers():int «precondition» !isPlayerAccepted(p) «precondition» getNumPlayers() < getMaxNumPlayers() «postcondition» isPlayerAccepted(p)

63 Heuristics: Mapping Contracts to Exceptions
Executing checking code slows down your program If it is too slow, omit the checking code for private and protected methods If it is still too slow, focus on components with the longest life Omit checking code for postconditions and invariants for all other components. Be pragmatic, if you don’t have enough time, change your tests in the following order: Omit checking code for postconditions and invariants. Often redundant, if you are confident that the code accomplishes the functionality of the method 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.


Download ppt "Chapter 10, Mapping Models to Code"

Similar presentations


Ads by Google