250 likes | 261 Views
CHAPTER 9. OBJECT ORIENTED APPROACH WITH THE UML. Object Oriented Terms & Concepts. Def : describes an information system by identifying things called objects. An object represents a real person, place, event or transaction.
E N D
CHAPTER 9 OBJECT ORIENTED APPROACH WITH THE UML
Object Oriented Terms & Concepts • Def : describes an information system by identifying things called objects. • An object represents a real person, place, event or transaction. • Sees the system from the viewpoint of the object themselves as they function & interact with the system. • End product is an object model which represents the information system in terms of objects & concepts. • A modular approach saves money & time because the modules can be optimized, tested & reused.
Overview • An object has certain attributes which are the characteristics that describes the object • Ex : car is your object, (brand, model, color are the attributes) • An object also has methods which are the tasks that objects performs when it receives a message/command. • Ex: method= turn on wipers, command = moving proper control. • A class is a group of similar objects • Ex; savvy, saga,gen2 = car
Objects • The UML represents an object as a rectangle with the object name at the top, followed by object attributes & methods. Azim Azfan Age 3 Male CHILD Characteristics that describes the CHILD object Attributes Amelia Jacob Age 4 Female Name Age Sex Samantha Age 3 Female Methods Task that the CHILD object can perform Pick up toys Eat meal Play
Attributes • Attributes are similar to adjective that describe the characteristics of an object. • An objects state is an attribute that indicates the object’s status. BANK ACCOUNT OBJECT State Status Active accounts is open and meets the standards. Inactive account is dormant for some time Closed account was closed
Method • Defines specific tasks that an object can perform. It describes what & how an object does something. • Steps: • Heat oil • Fill fry basket with potato chips • Lower basket into hot oil • Check for readiness • When ready, raise basket and drain oil • Pour fries into warming tray • Add salt. Method: MORE FRIES
Method • When a method creates a new instance of an object it is called a constructor method • A method that changes existing data is called an update method. • A query method is any method that provides information about an objects attributes.
Messages • Def : a command that tells an object to perform a certain method. STUDENT Attributes Name Address Tel No DOB Method ‘add student’ tells the student class to perform all the steps needed to add a student Methods Add student Delete student Change status Change telephone Update record
Messages • The same message to two different objects can produce different results. • The concept that a message gives different meanings to different objects is called polymorphism. Message : GOOD NIGHT PARENT CHILD Causes PARENT object to read bed time stories Causes CHILD object to drink milk
Messages • You may view an object as a black box. • Ex: gas pump is a black box ( when you fill in you tank, you don’t have to think how pump determines the amount, type etc..as long as its done properly) • Black box concept is called encapsulation = all datas & methods are self contained. • Object-oriented designs typically are implemented with object oriented programming languages. • Advantages of O-O design : save time & avoid errors
Classes • Def : an object belongs to a group or category • All objects within a class shares the same attributes & methods. • Objects within a class can be grouped into subclasses which are more specific.
Classes CAR attributes VEHICLE Attributes VAN Brand Model Year Color attributes Common attributes Methods TRUCK Start Stop Park Attributes Load limit CAR Attributes Emergency Exit Common attributes Uncommon attributes
Relationships among objects & classes • Relationships enables objects to communicate & interact as they perform business functions & transactions required by the system. • Describes what object need to know about each other, how object responds to changes & the effects of membership in classes & subclasses. • Types of relationships from weakest to strongest includes; • Dependency • Association • Aggregation • heritance
Relationships among objects & classes • Dependency • Occurs when one object must be informed about another. • SCHOOL BUS object must be informed about the BUS ROUTE object. Changes in BUS ROUTE will effect SCHOOL BUS. • Association • Occurs when certain attributes of one object are determined by its interaction with another object. • If a student enrolls in one or more classes in the REGISTRATION RECORD object, the students status/state in the STUDENT object becomes ‘current’.
Relationships among objects & classes • Aggregation • Exists when an object forms part of another object. • EMPLOYEE object has specific attributes & methods, however an EMPLOYEE object also belongs to a DEPARTMENT object which has its own attributes & methods. • Inheritance • Enables an object to derive one or more of its attributes from another object. • INSTRUCTOR object inherits many traits from the EMPLOYEE object including SOCIAL SECURITY NUMBER, HIRE DATE, TELEPHONE NUMBER
Object Relationship Diagram • Commence with object relationship diagram only after you identify objects, classes and relationships. • You’ll use the model as your guide as you develop additional diagram & documentation. EMPLOYEE MANAGER OFFICE STAFF INSTRUCTOR FITNESS CLASS CLASS SCHEDULE REGISTRATION RECORD STUDENT
OBJECT MODELING THE UML • UML – unified modeling language. • System analyst use the UML to describe object oriented system. • UML consists of various diagrams that use common symbols & notations. This integrated approach makes it easier to create, read & utilize UML diagrams. • UML is used to describe ; • Cases • Case diagrams • Sequence diagrams
Use Case Modeling • A use case represents the steps in specific business function or process. • An external entity is called actor, initiates a use case by requesting the system to perform a function / process. • To create a use cases, you start be reviewing the information that you gathered during the requirements modeling phase. • You objective is to identify the actor and the functions / transactions they initiate. • For each use case, you also create a use case description • Use case description – documents the name of the use case, the actor, a description of the use case, a step by step list of the tasks & actions required for successful completion, preconditions, postconditions & assumptions.
Use Case Modeling Update class roster Add Class STUDENT Change availability Update information INSTRUCTOR
Use Case Diagrams • Def : is a visual summary of several related use cases within a system or subsystem. • The first step when you create a use case diagram, you must identify the system boundary, which is represented by a rectangle. • System boundary – shows what is included in the system(inside the rectangle) and what is not included in the system (outside the rectangle)
Use Case Diagrams Use Case Diagram : Create Bus Route Create requirement forecast initiates notifies notifies STUDENT DRIVER Prepare route plan notifies determines Develop Staffing plan creates DISPATCHER
Sequence Diagram • Def : is a dynamic model of a use case showing the interaction among classes during a specified class period. • Its graphically documents the use case by showing the classes, the messages & timing of the messages. • Includes symbols that represents • classes, • Lifeline • messages • focuses.
Classes & lifeline • A class is identified by a rectangle with the name inside. Classes that send / receives messages are shown at the top of the sequence. • A lifeline is identified by a dashed line. It represents the time during which the object below is able to interact with other objects in the use case. An X marks the end of the lifeline. Class 1 Class 2 Lifeline Lifeline X End of Class 2 lifeline
Messages & Focuses • Message is identified by a line showing the direction that runs between two objects. The labels shows the name of the message and can include additional information about the contents. • Focus is identified by a narrow vertical rectangle that covers the lifeline. It indicates when an object sends / receives a message.
Messages & Focuses STUDENT MANAGER CLASS SCHEDULE REGISTRATION RECORD Request fitness class Check Notify Pay Register X