1 / 11

Object Oriented System Design From Design to Code

Object Oriented System Design From Design to Code. Marc Conrad D104 (Park Square Building) Email: Marc.Conrad@luton.ac.uk This week new: Implementation Issues Or: How to get the things running. Rational Rose can be used to generate code automatically (and vice versa) .

keiran
Download Presentation

Object Oriented System Design From Design to Code

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object Oriented System DesignFrom Design to Code • Marc Conrad • D104 (Park Square Building) • Email: Marc.Conrad@luton.ac.uk • This week new: • Implementation Issues • Or: How to get the things running Marc Conrad - University of Luton

  2. Rational Rose can be used to generate code automatically (and vice versa). Example: produces the following Java code ... Automatic Code Generation Marc Conrad - University of Luton

  3. public class Car { public Driver theDriver; /** * @roseuid 3EAFF17E035B */ public Car() { } } public class Driver { /** * @roseuid 3EAFF53F02FD */ public Driver() { } } Marc Conrad - University of Luton

  4. public class Car { public Driver theDriver; /** * @roseuid 3EAFF17E035B */ public Car() { } } public class Driver { /** * @roseuid 3EAFF53F02FD */ public Driver() { } } • Associations are implemented as reference attributes. • As there is no explicit role name defined in the class, Rational Rose adds automatically a role name to the code: theDriver Marc Conrad - University of Luton

  5. public class Car { public Driver bernhard; /** * @roseuid 3EAFF17E035B */ public Car() { } } public class Driver { /** * @roseuid 3EAFF53F02FD */ public Driver() { } } bernhard public class Car { public Driver theDriver; /** * @roseuid 3EAFF17E035B */ public Car() { } } • Associations are implemented as reference attributes. • An explicite role name already gives the name of the variable of type Driver. Marc Conrad - University of Luton

  6. public class Car { public Driver theDriver; /** * @roseuid 3EAFF17E035B */ public Car() { } } public class Driver { /** * @roseuid 3EAFF53F02FD */ public Driver() { } } • Templates for the default constructors are provided. • (Similar for methods when given in the class diagram.) What's that? Marc Conrad - University of Luton

  7. Order of Implementation and Testing. • When an association or dependency is implemented the class where the arrow points to should be implemented first (here the Driver class). • Note that the Driver class can be tested without having the Car class. Marc Conrad - University of Luton

  8. The Order of Implementation:Start with the least coupled object! 5th 6th 4th 2nd 1st Question: Are there alternativecourses? 3rd Marc Conrad - University of Luton

  9. ??? 1 Here There Implementing an Association • The class where the arrow starts has a reference implemented to an object where the arrow points to. • The reference can be • a (reference) variable of type There, • an array of There objects, • other possibilities depending on the language. Marc Conrad - University of Luton

  10. 1 1 Here There 0..* 1 Here There Code Generation and Testing.Example: Java • One-to-Many relationship. public class Here { public There theThere; /* ... */ } public class Here { public There[] theThere; /* ... */ } • One-to-One relationship. Marc Conrad - University of Luton

  11. Implementation issues - summary • Rational Rose has automatic code generation. • It is also possible to produce diagrams from code (reverse engineering). • The least coupled class should be implemented and tested first. • One-to-One relationships are implemented as (reference) attributes. • One-to-Many relationships are implemented as arrays. Marc Conrad - University of Luton

More Related