cl diag

Upload: rahul-sharma

Post on 04-Apr-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 cl Diag

    1/4

    Class Diagrams

    Classes:A class is a description of a set of objects that share the same attributes, operations, relationships,

    and semantics.Graphically, a class is rendered as a rectangle, usually including its name,attributes,and operations in separate,designated compartments.

    Interface:

    An interface is a named set of operations that specifies the behavior of objects without showing

    their inner structure. It can be rendered in the model by a one- or two-compartment rectangle, with

    the stereotype above the interface name.

    Class diagram:

    We use class diagrams to describe the structure of the system. Classes are abstractions thatspecify the common structure and behavior of a set of objects. Objects are instances of classesthat are created, modified, and destroyed during the execution of the system. Objects have state

    that includes the values of its attributes and its relationships with other objects.

    Class diagrams describe the system in terms of objects, classes, attributes, operations, andtheir associations

    A class diagram is a diagram that shows a set of classes, interfaces, and collaborations and

    their relationships. Graphically a class diagram is a set of vertices and arcs.

    Class diagram commonly contain the following things

    1. Classes2. Interfaces3. Collaborations4. Dependency, generalization, and association relationships

    Like all other diagrams, class diagram may contain notes and constraints. Class diagram may also

    contain packages or subsystems, both of which are used to group elements of model into life

    chunks.

    Common uses:

    We use class diagram to model the static design view of a system. This view primarily supports the

    functional requirements of a system, the services the system should provide to the end users.

    When we model the design view of a system, well typically use the class diagram in one of three

    ways.

  • 7/31/2019 cl Diag

    2/4

    1. To model the vocabulary of the system: Modeling the vocabulary of a system involvesmaking a decision about which abstractions are a part of the system under considerations

    and which fall outside in boundaries. We use class diagram to specify these abstractions and

    their responsibilities.

    2. To model simple collaborations: A Collaboration is a society of classes, interfaces, andother elements that work together to provide some cooperative behavior thats biggerthan

    the sum of all the elements.

    3. To model a logical database schema: Think of a schema as the blueprint for theconceptual design of a database. In many domains, we want to store persistent information

    in a relational database or in an object oriented database. You can model schemas for these

    databases using class diagrams.

    Common Modeling Techniques

    Modeling Simple Collaborations

    No class stands alone. Rather it works in collaboration with others to carry out some semantics

    greater than each individual. Therefore, in addition to capturing the vocabulary of the system, it also

    helps in visualizing, specifying, constructing and documenting the various ways these things in

    vocabulary work together.

    When we create a class diagram, we just model a part of the things and relationships that make up

    your systems design view. For these reason, each class diagram should focus on one collaborations

    at a time.

    To model a collaboration

    1. Identify the mechanisms that we have to model. A mechanism represents some function orbehavior of the part of the system we are modeling that results from the interactions of a

    society of classes, interfaces, and other things.

    2. For each mechanism, identify the classes, interfaces, and other collaborations thatparticipate in this collaboration. Identify the relationships among these collaborations as

    well.

    3. Use scenarios to walk through these things. Along the way, we will discover parts of themodel that were missing and parts that were just plain semantically wrong.

    4. Be sure to populate these elements with their contents. For classes, start with getting a goodbalance of responsibilities. Then over time turn these into concrete attributes and operations.

    Modeling a logical database schema

    Many of the systems will have persistent objects, which mean that they can be stored in a database

    for later retrieval. The UML is well suited to model logical database schemas as well as physical

    database schemas. The UMLs class diagram are a superset of entity relationships diagrams, a

  • 7/31/2019 cl Diag

    3/4

    common modeling tool for logical database schema. Whereas classical ER diagram focus only on

    data, class diagram go to a step further by permitting the modeling behavior as well.

    To model a schema

    1.

    Identify those classes in the model whose state must transcend the lifetime of theirapplications.

    2. Create a class diagram that contains these classes and mark them as persistent (as standardtagged value). We can also define our own set of tagged values to address database specific

    values.

    3. Expand the structural details of these classes. In general, this means specifying the details oftheir attributes and focusing on the associations and their cardinalities that structure these

    classes.

    4. Watch for the common pattern that complicates physical database design such as cyclicassociations, one to one associations, and n-ary associations. Where necessary create

    intermediate abstractions to simplify your logical structure.5. Consider also the behavior of these classes by expanding operations that are important for

    data access and data integrity.

    Relationship :

    A relationship is a connection among things. In object oriented modeling, the four most important

    relationships are dependencies, generalizations, associations, and realizations.

    Dependency: A dependency is a using relationship, specifying that a change in the specification of

    one thing may affect another thing that uses it but not necessarily the reverse. Graphically, a

    dependency is rendered as a dashed line, directed to the thing that is depended on.

    Generalization:Generalization is the relationship between a general class and one or more

    specializedclasses. Generalization enables us to describe all the attributes and operations that are common

    to a set of classesWith a generalization relationship from the child to the parent, the child will

    inherit all the structure and behavior of the parent. The child may even add new structure behavior

    or itmay modify the behavior of the parent.

  • 7/31/2019 cl Diag

    4/4

    AssociationAn association represents a family of links. Binary associations (with two ends) are

    normally represented as a line. An association can be named, and the ends of an association can be

    adorned with role names, ownership indicators, multiplicity, visibility, and other properties.

    There are four different types of association: bi-directional, uni-directional, Aggregation (includes

    Composition aggregation) and Reflexive. Bi-directional and uni-directional associations are the

    most common ones.

    For instance, a flight class is associated with a plane class bi-directionally. Association represents

    the static relationship shared among the objects of two classes. Example: "department offers

    courses", is an association relation..

    Realization: In UML modeling, 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 other model 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. A realization relationship between classes and interfaces

    and between components and interfaces shows that the class realizes the operations offered by the

    interface.

    Aggregation:

    Associations are used to represent a wide range of connections among a set of objects. Inpractice, a special case of association occurs frequently: composition. For example, a State

    contains many Counties, which in turn contains many Townships. A PoliceStation is

    composed of PoliceOfficers. Another example is a Directory that contains a number ofFiles. Such relationships could be modeled using a one-to-many association. Instead, Uml provides

    the concept of an aggregation to denote composition.

    http://en.wikipedia.org/wiki/Association_(object-oriented_programming)http://en.wikipedia.org/wiki/Association_(object-oriented_programming)