Object Oriented Technic Notes(Unit2)

Embed Size (px)

Citation preview

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    1/16

    1

    Structural Modeling:Structural Modeling:Structural Modeling:Structural Modeling:

    Structural modeling is a view of a system that shows the structure of the objects,

    including their classifiers, relationships, attributes and operations.

    Structural Model represents the framework of the system and this framework is theplace where all other components exist.

    Class diagram, component diagram, and deployment diagrams are the part of structural

    modeling.

    Structural model never describes the dynamic behavior of the system.

    Structural modeling consist of the following

    Class Diagram

    Object Diagram

    Deployment Diagram

    Package Diagram

    Composite structure Diagram

    Component Diagram

    Links,Links,Links,Links, associationassociationassociationassociation and otherand otherand otherand other concepts:concepts:concepts:concepts:

    Links:Links:Links:Links:

    A Link is a physical or conceptual connection among objects

    Used in object diagram and class diagram

    Type of Links:

    1. One to one

    2. One to many

    3. Many to One

    4. Many to Many

    Association:Association:Association:Association:

    It can be shown by a line and defines relationship between two or more classifiers that

    involves connections among their objects.

    An association can be named, and the ends of an association can be adorned with role

    names, ownership indicators, multiplicity, visibility, and other properties.

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    2/16

    2

    Types of associationTypes of associationTypes of associationTypes of association

    1. AAAA Unary associationUnary associationUnary associationUnary association if a class associated with itself

    2. A Binary associationBinary associationBinary associationBinary association exist between 2 classes appears as a straight line

    3. TernaryTernaryTernaryTernary AssociationAssociationAssociationAssociation

    3.3.3.3. Quarternary AssociationQuarternary AssociationQuarternary AssociationQuarternary Association

    MultiplicityMultiplicityMultiplicityMultiplicity::::

    The association relationship indicates that (at least) one of the two related classes

    makes reference to the other.

    The UML representation of an association is a line with an optional arrowhead

    indicating the roleof the object(s) in the relationship, and an optional notation

    at each end indicating the multiplicityof instances of that entity (the number of

    objects that participate in the association).

    0..10..10..10..1 No instances, or one instance (optional, may)

    1111 Exactly one instance

    0..*0..*0..*0..* or **** Zero or more instances

    1..*1..*1..*1..* One or more instances (at least one)

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    3/16

    3

    Many(zero or more)

    Optional(zero or one)

    Exactly One

    1+ One or more

    Realization:Realization:Realization:Realization:

    A realization relationship is a relationship between two model elements, in which one

    model element (the client) realizes (implements or executes) the behavior that the othermodel element (the supplier) specifies. A realization is indicated by a dashed line with

    an unfilled arrowhead towards the supplier.

    Realizations can only be shown on class or component diagrams.

    A realization is a relationship between classes, interfaces, components, and packages

    that connects a client element with a supplier element

    Generalization:Generalization:Generalization:Generalization:

    A Generalization appears as a line with an open Triangle at one end.

    Generalization refers to a relationship between a general class(parent class) and a more

    specific version of that class(child class)

    The generalization relationship is also known as the inheritanceor "is a"relationship.

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    4/16

    4

    Role Name:Role Name:Role Name:Role Name: Role name is a name that uniquely identifies one end of an association.

    Ordering:Ordering:Ordering:Ordering:defines order in { }

    Qualification:Qualification:Qualification:Qualification: A Qualified association relates two object classes and a qualifiers.

    The qualifier is a special attribute that reduces the effective multiplicity of an association.

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    5/16

    5

    ClassClassClassClass diagramdiagramdiagramdiagram

    A class diagramclass diagramclass diagramclass diagram in the UML is a type of static structure diagram that describes the

    structure of a system by showing the classes of system, their attributes, operations (or

    methods), and the relationships among the classes. These static aspects represents those parts of a diagram which forms the main structure

    Class diagrams are used in modeling of object oriented system because they are the only

    UML diagrams which can be mapped directly with object oriented language.

    A class with three sections.

    The upper part holds the name of the class

    The middle part contains the attributes of the class

    The bottom part gives the methods or operations of the class

    Purpose of Class Diagram:Purpose of Class Diagram:Purpose of Class Diagram:Purpose of Class Diagram:

    Analysis and design of the static view of the system.

    Describe responsibilities of a system

    Shows the collaboration among the elements of a system

    Base for component and deployment diagram.

    Creating a Class Diagram:Creating a Class Diagram:Creating a Class Diagram:Creating a Class Diagram:

    For creating a class diagram we need Classes, responsibilities, association,

    inheritance, interface, and composition.

    Core ElementsCore ElementsCore ElementsCore Elements

    Class:Class:Class:Class: a description of a set of objects that share the same attributes, operations, methods,

    relationships and semantics.

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    6/16

    6

    Interface:Interface:Interface:Interface: a named set of operations that characterize the behavior of an element.

    Component:Component:Component:Component: a physical, replaceable part of a system that packages implementation andprovides the realization of a set of interfaces.

    NNNNodeodeodeode can be defined as a physical element that exists at run time .It is a run-time physical

    object that represents a computational resource, generally having at least some memory and,

    often, processing capability

    Core Relationships:Core Relationships:Core Relationships:Core Relationships:

    AssociationAssociationAssociationAssociation:

    It can be shown by a line and defines relationship between two or more classifiers that

    involves connections among their objects.

    An association can be named, and the ends of an association can be adorned with rolenames, ownership indicators, multiplicity, visibility, and other properties.

    It can be bi-directional, uni-directional etc.

    Aggregation:Aggregation:Aggregation:Aggregation:

    An aggregation appears as a line with an open diamond at one end.

    A special form of association that specifies a whole-part or part-of relationshipbetween the aggregate (whole) and the component part.

    It is more specific than association.

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    7/16

    7

    Generalization:Generalization:Generalization:Generalization:

    A Generalization appears as a line with an open Triangle at one end.

    Generalization refers to a relationship between a general class(parent class) and a more

    specific version of that class(child class)

    The generalization relationship is also known as the inheritance or "is a"relationship.

    Dependency:Dependency:Dependency:Dependency: A relationship between two modeling elements, in which a change to one

    modeling element (the independent element) will affect the other modeling element ( the

    dependent element).

    Object Diagram:Object Diagram:Object Diagram:Object Diagram:

    Object diagrams are derived from class diagrams.

    It shows a set of objects and their relationships just like class diagram and also represent

    the static view of the system.

    Static view is a snapshot of the system at a particular moment.

    It is a diagram that shows a complete or partial view of the structure of a modeled

    system at a specific time.

    The usage of object diagram is similar to class diagrams but they are used to build

    prototype of a system.

    Object diagrams are more concrete than class diagrams, and are often used to provide

    examples, or act as test cases for the class diagrams.

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    8/16

    8

    Only those aspects of a model that are of current interest need be shown on an object

    diagram.

    To create a object in UML we use a box with an object name followed by a colon (:) and then

    the class name;

    Object diagram focus on set of objects, attributes, and relationship between the objects.

    Ex:Ex:Ex:Ex:---- Class DiagramClass DiagramClass DiagramClass Diagram Object DiagramObject DiagramObject DiagramObject Diagram

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    9/16

    9

    Collaboration DiagramCollaboration DiagramCollaboration DiagramCollaboration Diagram:::: A collaboration diagrams focus on the relationships between objects.

    It allows the designer to specify the sequence of messages sent between objects in

    collaboration, this diagram does not show the life time of the objects.

    In it the event/method call sequence is indicated by sequence number preceding

    messages. The number indicates how the methods are called one after another.

    The method calls are similar to sequence diagram but the difference is that the sequence

    diagram does not describe the object organization whereas the collaboration diagram

    shows the object definition.

    In this the sequence of events are indicated by numbering.

    Also known as interaction diagram.

    It requires use case, system operation contracts, and domain model to already exist.

    They are composed of three elements.1. Objects

    2. Associations

    3. Messages

    Placement of colon indicate either a objectName:,objectName:,objectName:,objectName:, or a :className:className:className:className.

    Order management systemOrder management systemOrder management systemOrder management system

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    10/16

    10

    Sequence diagram:Sequence diagram:Sequence diagram:Sequence diagram: Sequence diagrams contain the same information as Collaboration diagrams, but

    emphasize the sequence of the messages instead of the relationships between the

    objects.

    Sequence diagrams focus on the order in which the messages are sent. It shows how the

    objects communicate with each other in terms of sequence of messages

    It shows a set of objects and the messages sent and received by those objects.

    An object in a sequence diagram is rendered as a box with a dashed line descending

    from it.The line is called the object lifeline, and it represents the existence of an object

    over a period of time.

    Messages are rendered as horizontal arrows being passed from object to object.

    Conditions such as check=true indicate when a message gets passed.

    Type of Message:Type of Message:Type of Message:Type of Message:

    Synchronous MessageSynchronous MessageSynchronous MessageSynchronous Message is a message sanded by sender to receiver and sender object waits

    until the receiver object finish its processing of message, shown by a solid line with an

    open arrowhead

    Asynchronous messageAsynchronous messageAsynchronous messageAsynchronous message sender object does not wait for receiver object to finish its

    processing of message. All messages maintains a message queue and sanded according

    to its priority,

    Return messageReturn messageReturn messageReturn message uses a dashed line with an open arrowheadLost messageLost messageLost messageLost message that does not reach its destination, shown by a solid line with an open

    arrowhead with a black dot

    Found messageFound messageFound messageFound message (a message whose sender is not found) that originate at an endpoint

    symbol (black dot)

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    11/16

    11

    Component DiagramsComponent DiagramsComponent DiagramsComponent Diagrams

    Component Diagrams show the types of software components in the system, their

    interfaces and dependencies.

    Component diagrams address the static design implementation view of a system

    They are important for building large systems from smaller parts.

    It provides a physical view of a system.

    Main purpose of component diagram is to show the dependencies of the components in

    the system.

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    12/16

    12

    Basic Behavioral Modeling:Basic Behavioral Modeling:Basic Behavioral Modeling:Basic Behavioral Modeling:

    Any system can have two aspects, static and dynamic. So a model is considered as

    complete when both the aspects are covered fully.

    Behavioral model basically capture the dynamic aspect of a system. Dynamic aspect can

    be further described as the changing/moving part of a system.

    Behavioral model describes the behavior or functionality of the system.

    Basic behavioral models are

    1. Use case diagram

    2. Activity diagram

    3. State chart diagram

    Use CaseUse CaseUse CaseUse Case Diagram:Diagram:Diagram:Diagram:

    Use case diagrams are set of use cases, actors and their relationships.

    Use case represents a particular functionality of a system.

    So use case diagram is used to describe the relationships among the functionality

    and their internal/external controller. These controllers are known as actors.

    Actor is an external user of the system.

    Use case describes action between actor and software system.

    Helps to achieve the goal of the system. The symbols used to create use case diagram are

    1. ActorsActorsActorsActors (stick men) are anything outside the system that

    interacts with the system.

    2. Use Cases (ovals) are the procedures by which the actors interact

    with the system.

    3. Solid lines indicate which actors interact with the system as part of

    which procedures.

    4. Dashed lines show dependencies between use cases, where one use

    case is 'included' in or 'extends' another.

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    13/16

    13

    EX:EX:EX:EX:----Use case diagram for vending machineUse case diagram for vending machineUse case diagram for vending machineUse case diagram for vending machine

    Activity Diagram:Activity Diagram:Activity Diagram:Activity Diagram:

    Active diagram describes the flow of control in a system. So it contains of activities and

    links.

    The flow can be sequential, concurrent etc.

    Activities are nothing but the functions of a system.

    Numbers of activity diagrams are prepared to capture the entire flow in a system.

    This is prepared to have an idea of how the system will work when executed.

    Activity diagram focus on operations rather than objects.

    Different terms in activity diagramDifferent terms in activity diagramDifferent terms in activity diagramDifferent terms in activity diagram:

    1. Active statesActive statesActive statesActive states - oblongs with rounded corners which describe what is done or executionof an action

    2. TransitionsTransitionsTransitionsTransitions when an action or activity of a state complete.

    3. ConditionsConditionsConditionsConditions ---- (in square brackets) which qualify the transitions, or shows the decision

    point

    4. Branch:Branch:Branch:Branch: shows the path

    5. Concurrent activity:Concurrent activity:Concurrent activity:Concurrent activity: When two or more activities are performed parallel.

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    14/16

    14

    ExampleExampleExampleExample :::: Activity diagram for the process of stock trade order

    State chart Diagram:State chart Diagram:State chart Diagram:State chart Diagram:

    Any real time system is expected to be reacted by some kind of internal/external events.

    These events are responsible for some change of the system.

    State chart diagram is used to represent the event driven state change of a system.

    It basically describes the state change of a class, interface etc.

    State chart diagram is used to visualize the reaction of a system by internal/external

    factors.

    o Initial state

    o Final state

    State

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    15/16

    15

    TransitionsTransitionsTransitionsTransitions - the solid arrows which show possible changes of state.

    Events - the text on the transitions before the '/' showing the incoming call to the

    object interface which causes the change of state.

    ConditionsConditionsConditionsConditions - a boolean statement in square brackets which qualifies the event.

    ActionsActionsActionsActions - the text after the '/' which defines the objects response to the transition

    between states.

    Extra syntax which defines state-centric functionality

    Ex: motor systemEx: motor systemEx: motor systemEx: motor system

  • 7/30/2019 Object Oriented Technic Notes(Unit2)

    16/16

    16

    Package Diagram:Package Diagram:Package Diagram:Package Diagram:

    Package diagram in UML can be shown as dependencies between the packages that

    make a model. There are 2 type of dependencies b/w package

    1. Package import

    2. Package merge

    By default dependencies b/w two packages is implement as the package import

    relationship.

    A package merge relationship shows the contents of two packages are combined.

    It is similar to generalization.

    EX:EX:EX:EX:

    Package