0% found this document useful (0 votes)
12 views17 pages

OOSD Module 5

Uploaded by

Saurabh Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views17 pages

OOSD Module 5

Uploaded by

Saurabh Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 17

Mapping Designs to Code

Chapter 20
Applying UML and Patterns
-Craig Larman

1
Mapping Designs to Code
 Process: Write source code for
• Class and interface definitions
• Method definitions

2
Design Class Diagrams
 DCDs contain class or interface names,
classes, method and simple attributes.
 These are sufficient for basic class

definitions.
 Elaborate from associations to add

reference attributes.

3
Reference Attributes
An attribute that refers to
another complex objects.

 Reference Attributes are


suggested by associations and
navigability in a class diagram.

 Example: A product
specification reference on a
Sales Line Item. So here we
can use product spec as a
complex reference attribute to
sales line item class.

4
Role Names
 Each end of an
association is a role.
Reference Attributes
are often suggested by
role names.
(use role names as
the names of
reference attributes).

5
Creating methods from Interaction
Diagrams
 Interaction Diagrams
are used to specify
methods.
 They give most of the
details for what the
method does.

6
Containers and Collections
 Where an object must
maintain visibility to a
group of other objects,
such as a group of Sales
Line Items in a Sale,
object-oriented
languages often use an
intermediate container or
collection.
 These will be suggested
by a multiplicity value
greater than one on a
class diagram.

7
Working Example: PM

8
PM: Use Case Diagram

9
PM: Class Diagram

10
PM: Class to Code
 class WorkPackage;
 class Project;
 class Activity;
 class Task;
 class WorkProduct;
 class Resource;
 class Skill;
 class ResourceXSkill;

11
PM: Class to Code
class WorkPackage
{ // Details omitted };
class Project : public WorkPackage
{ private: CollectionByVal<Activity> theActivity; };
class Activity : public WorkPackage
{ private: Project *theProject;
CollectionByVal<Task> theTask;
CollectionByRef<WorkProduct>
theWorkProduct; };
12
PM: DCD Mapping

13
PM: DCD Code
class Project Date getStartDate (void);
{ private: void addActivity (const Activity
char *Name; &theActivity);
char *Descr; CollectionByRef<Activity>
Date StartDate; getAllAcitivities (void);
static int NumberOfProjects; static int getNumberOfProjects
public: (void);
Project (char *Name); void save (void);
Project (void); ~Project (void); void load (char *Name);
char *getName (void); protected:
void setName (char *theName);
bool hasActivities (void); };
void setDescr (char *Descr);
char *getDescr (void);
void setStartDate (Date int Project::NumberOfProjects = 0;
theStartDate);

14
PM: Sequence Diagram

15
PM: Sequence to Main
void main (void)
{ char *Name; char *Descr;
Date StartDate; Project aProject;
// provide project Name, descr, and startdate
aProject.setName (Name);
aProject.setDescr (Descr);
aProject.setStartDate (StartDate);
aProject.save (); }

16
Other References

 http://www.martinig.ch/mt/index.html

 http://www.sparxsystems.com.au/

UML_Tutorial.htm
 http://archive.devx.com/free/mgznarch/vcdj/

1999/jun99/uml1.asp

17

You might also like