Presentation is loading. Please wait.

Presentation is loading. Please wait.

UML (U NIFIED M ODELING LANGUAGE ) Prepared by Miss Simab Shahid Lecturer computer Science and Software Engineering department, University.

Similar presentations


Presentation on theme: "UML (U NIFIED M ODELING LANGUAGE ) Prepared by Miss Simab Shahid Lecturer computer Science and Software Engineering department, University."— Presentation transcript:

1 UML (U NIFIED M ODELING LANGUAGE ) Prepared by Miss Simab Shahid (s.shahid@uoh.edu.sa) Lecturer computer Science and Software Engineering department, University of Hail

2 I NTRODUCTION TO UML AND P ATTERNS Software design is a process of problem solving and planning for software solution. There are different designing tools are available for software designing. UML and patterns are two software design tools that can be used within the context of any OOP (Object-Oriented programming) language. UML (Unified Modeling Language) is a graphical language used for designing and documenting OOP software. A pattern in programming is a kind of template or outline of a software task. 2 Simab Shahid UOH, Girls Branch

3 UML ( UNIFIED M ODELING L ANGUAGE ) o Pseudocode is a way of representing a program in a linear and algebraic manner.  It simplifies design by eliminating the details of programming language syntax. o Graphical representation systems for program design have also been used:  Flowcharts and structure diagrams for example. o Unified Modeling Language ( UML ) is yet another graphical representation formalism.  UML is designed to reflect and be used with the OOP philosophy. 3 Simab Shahid UOH, Girls Branch

4 UML C LASS D IAGRAM Classes are central to OOP(Object Oriented Programming), and the class diagram is the easiest of the UML graphical representations to understand and use. o A class diagram is divided up into three sections: 1. The top section contains the class name. 2. The middle section contains the data specification for the class. 3. The bottom section contains the actions or methods of the class. 4 Simab Shahid UOH, Girls Branch

5 UML C LASS D IAGRAM (TEMPLATE) 5 Simab Shahid UOH, Girls Branch Class NAME will come here Class VARIABLES will come here Class FUNCTIONS& constructors will come here

6 UML C LASS D IAGRAM o The data specification for each piece of data in a UML diagram consists of its name, followed by a colon, followed by its type. o Each name is preceded by a character that specifies its access type:  A minus sign (-) indicates private access  A plus sign (+) indicates public access  A sharp (#) indicates protected access  A tilde (~) indicates package access 6 Simab Shahid UOH, Girls Branch

7 UML C LASS D IAGRAM o Each method in a UML diagram is indicated by the name of the method, followed by its parameter list, a colon (:), and its returned type. o The access type of each method is indicated in the same way as for data. o A class diagram need not give a complete description of the class. o If a given analysis does not require that all the class members be represented, then those members are not listed in the class diagram. o Missing members are indicated with an ellipsis (three dots). 7 Simab Shahid UOH, Girls Branch

8 UML C LASS DIAGRAM ( EXAMPLE ) 8 Simab Shahid UOH, Girls Branch Square - Side : double - xCoordinate : double -yCoordinate : double … + resize (newSide: double ) : void + move (double newx, double newy ) : void # erase ( ) : void … Class Data Specification Class member functions Class Name

9 UML C LASS D IAGRAM (EXAMPLE) 9 Simab Shahid UOH, Girls Branch class Point { public int XCoord; public int YCoord; public Point( ) { XCoord=0; YCoord=0; } public void display() { System.out.println(“X Coordinate = “+ XCoord); System.out.println(“Y Coordinate = “+ YCoord); } Java code for Point class UML class Diagram for Point class Point + XCoord : int + YCoord : int + display() : void + Point()

10 A CTIVITY 01 10 Simab Shahid UOH, Girls Branch public class Cube { int length; int breadth; int height; public Cube() { length = 0; breadth = 0; height= 0; } public int getVolum ( ) { return(length*breadth *height); } UML class Diagram Cube length : int breadth : int height : int + getVolum( ) : int + Cube ()

11 A CTIVITY 02 11 Simab Shahid UOH, Girls Branch class Employee { public String name; public int id; private float salary; public Employee( String Name, int Id, float Salary) { name = Name; id = Id; salary = Salary; } public void setSalary( float s) { salary = s; } public float getSalary( ) { return salary; }

12 A CTIVITY 04 12 Simab Shahid UOH, Girls Branch Point + display() : void + Point() Is this a valid class diagram ? Point + XCoord : int + YCoord : int Is this a valid class diagram ? Java Code class Point{ public Point(){ } public void display(){ } } Java Code class Point{ public int XCoord ; public int YCoord ; }

13 A CTIVITY 05 13 Simab Shahid UOH, Girls Branch Point + display() : void + Point() + XCoord : int + YCoord : int Is this a valid class diagram ?

14 C LASS I NTERACTIONS o Rather than show just the interface of a class, class diagrams are primarily designed to show the interactions among classes. o UML has various ways to indicate the information flow from one class object to another using different sorts of annotated arrows. o UML has annotations for class groupings into packages, for inheritance, and for other interactions. o In addition to these established annotations, UML is extensible. 14 Simab Shahid UOH, Girls Branch

15 I NHERITANCE D IAGRAMS o An inheritance diagram shows the relationship between a base class and its derived class(es).  Normally, only as much of the class diagram is shown as is needed.  Note that each derived class may serve as the base class of its derived class(es). o Each base class is drawn above its derived class(es)  An upward pointing arrow is drawn between them to indicate the inheritance relationship. 15 Simab Shahid UOH, Girls Branch

16 A C LASS H IERARCHY IN UML N OTATION 16 Simab Shahid UOH, Girls Branch Student Employee Staff UndergraduateGraduate Faculty Person

17 I NHERITANCE D IAGRAM o The arrows also help in locating method definitions. o To look for a method definition for a class:  Examine the class definition first.  If the method is not found, the path of connecting arrows will show the order and direction in which to search.  Examine the parent class indicated by the connecting arrow.  If the method is still not found, then examine this parent's parent class indicated by the connecting arrow.  Continue until the method is found, or until the top base class is reached. 17 Simab Shahid UOH, Girls Branch

18 S OME DETAILS OF C LASS H IERARCHY 18 Simab Shahid UOH, Girls Branch + setName(String newName): void + getName( ): String + toString( ): String + sameName(Person otherPerson): boolean - name: String Person + set(String newName, int newStudentNumber): void + getStudentNumber( ): int + setStudentNumber(int newStudentNumber ): void + toString( ): String + equals(Object otherObject): boolean - studentNumber: int Student


Download ppt "UML (U NIFIED M ODELING LANGUAGE ) Prepared by Miss Simab Shahid Lecturer computer Science and Software Engineering department, University."

Similar presentations


Ads by Google