Why Object Oreiented Analysis Design (OOAD)/Unified Modeling Language (UML)
Object Oriented Technology (OOT) in combination with Object Oriented Analysis and Design (OOAD), provides single paradigm that allow user, system analysts, programmers and testers to tackle the above issues. OOT works on divide and re-unite iterations. Divide to understand and re-unite to build style. Technical benefits lies in loosely coupling makes it closer to real world, iterative and reusability. In OO, coupling becomes dynamic and functional evolution no longer effect the static structure of the software.
Software crises
Software crises means software failure because of following reasons -
- More complex software, because of heterogeneous technology (LAN/WAN/Internet), hardware, software and applications.
- Shorter development cycle because of business commitments
- Needs higher budget
- Higher user's expectations
- Software can only be tested after development is over
- Poor research at System Analysis and Design phase leads to non-usable system such as USA DMV 43 million$ project
- Non-scaleable and non-portable systems
- To cover up the risks such as -
- Attain main objectives from business perspective
- Reach market in time
- Resource risk such as equipment, people and finance
- Fail to manage new technologies
- Architectural risk from implementation angle such as component integration etc.
While analysis and designing the goals should be -
- Achieve the objective
- User should be able to use it effectively
- Maintainable system
- Scalable
- Portable between platforms
- Reusable code
- Deliver in time
- Within budget
OOAD
OOAD is modeling the software intensive system based upon Object Oriented paradigm. It is combination of OOA and OOD. Both overlap with each other. Analysis gets more refined during design phase -
- OOA -
- model based upon user's requirements
- from user’s perspective and close to real world
- processes are “Black Boxes”
- abstracting from the problem domain
- OOA is focused on concise, accurate model of WHAT the desired system should do
- primary classes and objects are discovered such as persistence or inter-process communications
- Though implementation environment not considered, but it must be ascertained whether the model will work in intended implementation environment
- Analysis –
- What to do?
- Domain?
- How?
- What skills?
- OOD -
- adds details and decisions to the model i.e. blue print for development
- from developer’s perspective
- have “White Box” approach
- OOD considers HOW the system will perform it’s functions
- Secondary classes are discovered
Benefits of OOAD -
- Single paradigm for analyst, users, developers, implementers and testers to aspect the same system from different perspective.
- Real World to be more closely modeled
- Easy to understand and maintain
- Inheritance gives re-usability of code and architecture
- Encapsulation gives data security and stability i.e. small changes doesn’t effect the whole system
- Captures the system and documents it, before the development starts
- Different solutions can be explored and evaluated before coding starts
- Different view of the system for different people
- Can be used as a guideline through out the software development process
- Abstraction reduces the underlying complexity of the system and allows the system to be viewed as a whole
Software Architect
Architect based upon OO becomes re-usable and is called pattern. Software Architect = Elements + Pattern (groups of elements) + Mativation (why grouping). A Frame-work can have multiple Patterns. Good tactics for OOAD - Modules should be loosely coupled i.e. independent of each other and can be altered without effecting other modules or system as a whole. For this -
- System should be split in to modules based upon logical functionality
- Modules should be separately compatible, so that if changes need to be made to one of them, the whole system won’t be affected.
- Modules should interact with each other through compact and minimum interfaces, which acts as wrappers to hide the implementation
For OOAD we need a standard notation
Unified Modeling Language (UML). UML is standard visual language to visualize, specifying, constructing and documenting the articraft of a software-intensive system. A graphical notation facilitates portraying the structure of a complex system and also provides consistency throughout the development process. A good notation (notation along with a process is known as method, which is meaningful to everyone) should -
- allow an accurate description of the system
- be as simple as possible, without being oversimplified
- be easy to update
- be easy to communicate with others
UML basic concepts -
- Common elements comprises of -
- Model elements represent abstractions of the system
- Visual elements provide textual or graphical projections that facilitate the manipulation of model elements
- Common mechanisms are –
- Stereotypes permits users to add new model element classes on top of the kernel pre-defined by UML.
- Tagged values (name, value) pair describes the property of a model element.
- Notes are comments attached to one or more model elements.
- Constraint is kind of semantic relationship between model elements. Object Constraint Language (OCL) is preferred language for this.
- Dependencies are unidirectional relationship between source and target model elements.
- Type/instance dichotomies are element with type essence and type/class dichotomies, corresponds to the split between the specifications of an element.
- Data type -
- Boolean enumerates two types True or False.
- Expression scope goes beyond UML.
- Multiplicity is a non-null set of positive integers.
- Name character string that enables the specification of an element.
- Integer is primitive type and an element of the infinite set of positive, negative and whole numbers.
- String is primitive type and is sequence of characters referred to by a name.
- Time is a character string representing absolute or relative duration, whose syntax goes beyond the scope of UML.
- Uninterrupted thing, which’s meaning depends upon the domain and is undefined in UML.
- Package - It provides general mechanism for logical partitioning models and grouping model elements. A package may contain mixture of packages and other model elements, the way as a directory may contain other directories and files.
UML objective was -
- To model complete OO and Relational system
- Coupling of the conceptual and executable articrafts
- Scalability and support both small and large scale analysis and design
- Notations for both people and machines
UML components -
- Standard
- UML notation and processes
- Model - Model tells us the problem and solution to the problem domain in UML notations and is highly self-contained basic unit of development, which is loosely coupled with other models by navigational links. Semantically representation like class, objects and relationships based upon object-oriented concepts. Each model element retains same symbol and meaning in different diagram such as class diagram.
- Diagram - Different combination of Model elements based upon rules. Nine diagrams are -
- Use-case represents the functions of a system from the user's point of view.
- Class represents the static structure in terms of classes and relationships.
- Object represents objects and their relationship, and correspond to simplified collaboration diagram that do not represent message broadcasts.
- State-chart represents the behaviors of a class in terms of states.
- Sequence Interaction (extra information than Collaboration diagram)
- Collaboration Interaction (initial discovery phase because it's close to reality)
- Activity represents the behavior of an operation as a set of actions.
- Component represents the physical components of an application.
- Deployment represents the deployment of components on a particular piece of hardware.
- View - Views are combination of diagrams and provides highest level of abstraction for analyzing the system from various aspects. Taken together, the view of the system provides a picture of the system in it entirety. Five main views are –
- Use-case
- Logical
- Component
- Concurrency
- Deployment
- Non-standard - UML provides mechanisms for adding comments, information, or semantics to diagrams. Customization gives extensibility to UML and it provides mechanisms to adapt or extend itself to a particular method, software system or organization. These are -
- Comments
- Information
- Semantics
Obsolete Waterfall software life-cycle approach -
- Requirements capture - Most of the user’s requirements are captured via simple use-case, class and activity diagrams for users, clients and developers.
- Analysis - Existing use-cases are expanded and new use-cases are defined. Classes are discovered to fulfill use-case functionality and class relationships are defined via class diagrams. State, Sequence, Collaboration and Activity Diagram can document behavior and state. Interface Screens, Windows, Events and Screen Navigation are carried out. Then the members involved do evaluation.
- Design - Considers environment and implementation details. Classes are grouped into functional packages. After this technical classes are developed to implement functional requirements defined in Analysis. These classes should provide mechanism such as persistence, inter-process communication, exception and error handling. Consider available pre-compiled libraries. If table, then map these classes to relational database. Allocate classes to source code component and components to packages via component diagrams. Executable components allocated to processors and devices i.e. nodes and this is done via Deployment diagram. Diagram and specification are translated into syntax of programming language.
- Implementation - Define programming guidelines and start coding. Code review from simplicity, re-usability and maintainability angle. Compilation, linking and debugging. Do unit testing and integration of components. Old diagrams are updated.
- Test - Find and eliminate the errors. Test cases tell a tester as what to input and what results to get against Sequences, Collaboration and Deployment diagrams. Automatic and manual testing via test scripts. Test can be at component level done by the programmers. Integration test checks the interfaces and communication mechanisms. Functionality from specific user's can be checked via use-cases. Test from intended user via use-case collected in Capture phase.
Though UML diagrams can be applied but there are following drawbacks for Waterfall -
- Each phase is isolated in itself because of linear in approach
- Loss of information because each step is managed by different people
- Error are discovered at the end only i.e. Test
- User interaction is not continuous
UML is best suited for a system which is -
- Use-case driven - Series of logical steps in a system to yield results to user and defines the behavior of the system. User is an actor, which can be a machine or man. Can also be used as to test the system.
- Use-cases realized in design model.
- Use-cases are implemented in implementation model.
- Use-case are verified in test model
- Architecture driven - We can visualize, alter and extend system before development starts. This divides the system into packages and sub-systems. Good system has well-defined layers of abstractions and each layer has standard interface to interact with each other. It also considers non-functional elements of a system.
- Incremental and iterative - Iteration refers to problem solving method that uses a series of approximations, each one building on the last, to find a better solution. Each iteration of a system should result in value being added to the model i.e. address problem in previous iteration and add a new functionality. Implementation and testing happens after iteration. This reduces the risk as member involved can evaluate prototype at an early stage.
Iterations -
Each of the above phases is divided into iterations. Each iteration is divided into following consecutive phase - which generates software at the end -
- Inception - Original version of the product is transformed into project. Project access, risk assessment, resource estimation, plan and milestones. At times part of implementation phase carried out here i.e. prototyping or showing user interface or both.
- Elaboration - More analysis i.e. extend and discover new classes and use-cases. Cost and duration should be clearly defined. Rough calculations on size and iteration of the project.
- Construction - Iteration of analysis, design and programming. New articrafts are produced such as documentation from user and technical angles.
- Transition - Delivery to the user and system is put to actual use. Develop plan for packaging, pricing, roll out, support, training, transition strategy, production details and improvisations on documentation. After that each iteration keeps on generating beta release, bug-fix and upgrades. Postmortem analysis is done at the end. In UML these are the following seven phases in the software development cycle -
| # |
Type |
Software life cycle steps |
Inception |
Elaboration |
Construction |
Transaction |
| 1 |
Process |
Requirement capture - objective |
|
|
|
|
| 2 |
Process |
Analysis & Design - user/developer angle |
|
|
|
|
| 3 |
Process |
Implementation - coding |
|
|
|
|
| 4 |
Support |
Supportcomponents test - usecases and over all integrity test |
|
|
|
|
| 5 |
Support |
Management - describes how the process component are emphasized over time |
|
|
|
|
| 6 |
Support |
Environment - how to provide the software development organization with process & tools |
|
|
|
|
| 7 |
Support |
Deployment - release and delivery to the end-user |
|
|
|
|
| |
|
Iterations |
|
|
|
|
| |
|
Approximate efforts |
5% |
20% |
65% |
10% |
| |
|
Approximate duration |
10% |
20% |
50% |
10% |
Avergae allocation of effort in different phases of SLDC -
- Plan 15%
- Analysis 10%
- Architect 15%
- Implemenation 30%
- Maintaince 5%
- Test 15%
- Change Management 10%
Rational objectory -
Rational Rose Corporation’s has devised a tool Rational Rose for creating UML diagrams (notation and process). It is a configurable process for various projects. It’s use-case driven, iterative, incremental and architecture-centric approach.
- Allows new requirement to incorporate in the system
- Early detection of risk elements
- Easy to detect reusable components
- Robust Architecture
- Team is better integrated throughout the software cycle
Elements behind iterative and incremental
- Requirements Managements - Systematic approach to dealing with the changing requirements of a software intensive system
- Change Control - Deals with changes in requirements, design and implementation
- Quality Control part is also a part in Objectory, which covers objective measurement, criteria for all activities and participants in the process. Objectory can be described having two components -
- Time represents dynamic aspects such as cycles, phases, iterations and milestones
- Process components are the static elements such as process components, activities, workflow, articrafts and workers.
History of UML -
- Fragmentations in late 80’s -
- James Rambaugh had Object Management Technology (OMT)
- Grady Booch had Booch methodology focuses on practice of analyzing a system as a series of macro and micro views
- Ivar Jacobson had Object Oriented Software Engineering (OOSE) focuses on the analysis of system behavior. Also it advocates that at each step there should be a check to see that the requirements of the user were being met
- ii) Unification -
- In 1994 OMT joined Booch and made Unified Method
- In 1995 OOSE joined Unified Methods.
- State charts of Erric Gamma and David Harrel were also incorporated and named it UML. It was broken down to notations rather than methods.
- iii) Standardization and Industrialization -
- In 1997, Object Management Group (OMG) standardized the UML ver 1.0. UML standardizes -
- Diagrams
- Syntactic notations
- Semantic models
Benefits of capturing requirement from inception to elaboration phase are -
- Elimination of superfluous elements
- Important elements are not left out
System is meant for -
- System commissioner
- System Manager
- Manager
- Staff
- Clients
- Purchaser
Problem Domain -
After analyzing the alternative solutions, we will arrive at "Problem Domain". Problem Domain is the surroundings on which proposed system will operate. This defines functionalities required to achieve the objective and they the way the functionalities will be used. Consult Domain Expert to define Problem Domain. Since inception and elaboration makes this process iterative and incremental, Domain Expert has to play a continuous role. Problem Statements is used to outline the captured requirements of the system, which shows scope of proposed system.
Use-case diagrams -
Use-cases are descriptions of scenarios (instance of use-case) detailing the events, which occur in common situations in the problem domain. Roughly there should be < 20 use-cases per project, < 10 page per use-case and many scenarios per use-case. Use-case ensures that -
- Designers and users are in agreement about what the system should do
- Speed up the design process
- Both combined i.e. use-case models and problem domain, gives clear picture of the future system, without using any technical jargons and thus more closer to user.
- Use-case is system functionalities from an actor's point of view. Use-case is diagrammatic (i.e. actors as stick-man, relations as line, use-case oval and system boundary as square) along with textual representation of relation between actors, it’s surrounding functionality (complete from start to finish, where finish means an observable result to an actor) and use-cases. Customer, developer and domain expert are responsible for use-case models. Analysis, design and testing teams use same use-case model. They are flexible and can be changed. Scope of use-case should not be too wide otherwise it may take longer to deliver. Instead focus on creating an accurate system architecture that can be added to easily. Steps for use-cases are about -
- Defining system
- Identify Actors
- Identify use-cases
- Defining relationship between (including associations, dependencies and generalization) -
- Actor and use-case
- Among use-cases
- Use-case is realized in either collaboration or sequence i.e. transformation into classes and objects. This means defining classes and objects, and their relationships and operations. Use-case functionality gets assigned to class. Use-case boundaries are determined by the interaction of an actor. This tells developer what system should and should not do, along with the interface. Active actor linked to use-case can initiate use-cases. Also there should be textual description about the use-case functionality. Use-case is represented by an oval and name at the bottom.
- Actor is an external entity (not a part of the system such as person, another system or printer etc.) to the system and becomes an interface of the system. Actor is a role and not an individual user. One person can play a role of many actors. Actor is a class and not an instance of an object. Actor class can have behavior and attributes as well as documentation property that describe the Actor. Actors have a name depending upon its role and not on functionality. Nor the Actor name should represent an instance of a class. Actor can be primary or secondary. An active Actor (Passive Actor merely participates in one or more use-cases) can initiate a use-case but a passive actor only participates in the use-case. Actor is represented by stickman. Since UML is flexible we can choose an actor depending upon the level of abstraction. Progressions through iterations may generate more Actors. An Actor can –
- inputting information
- receiving information
- inputting and receiving information
- Explode different alternate flow along with the exceptions the use-cases with sequence or collaboration diagrams. Along the development use-cases gets enhanced. But use-cases don't tell as how to achieve the functionality? Use-case functionalities are implemented in classes and operations. Use-cases should be written in such a manner that even a non-technical person should be able to understand it.
- Inputs in the use-case development process by -
- Customer
- End users
- Domain Experts
- Developers
- Use-case model represented by the use-case view. This view affects all of the other system views such as logical and physical views, because the functional specifications are implemented in these architectures.
- How to define use-case -
- Find an actor, by exploring what the system should do?
- UML is flexible, so choosing actors often depends on the level of abstraction you want in a use-case.
- Design iterations may add more actors and use-cases.
- Check out what things interact with the system.
- Different functionality will have different Actors, because functionality is isolated to an Actor.
- In case an Actor has a unique behavior, it can be modeled using actor-generalization association with the original actor.
- Content of use-case -
- Unique ID is an intelligent meaningful key for easy tracability
- Name i.e. named against their functionalities along with the verb like RUN PAYROL.
- Goal statement is one line statement regading the aim of use-case i.e. what a system does from a user's angle and not how
- Author is usually a team, along with iterative dates
- Priority and targeted dates for an early completions
- Risk means any uncertainty which can cause an issue
- Actor who is inputting and outputing or both
- Related use-cases
- Assumptions are made by the use-case team and not limitations or constraints
- Pre-conditions describes the conditions that should be met before use-case can be performed
- Post-conditions describes that comditions must be net before the use-case gets finished
- Outstanding issues are issues which needs to be resolved to complete this use-case
- Requirement satisfied can be bulleted list of features
- Scenarios, which is an instance (examples of specific scenario) of a use-case -
- Main flow
- Alternative flow (exception, when system can fail to meet it’s objective)
- How it gets initiated and ends
- Extension point
- Dictonary
- Annexures
- Relationship -
- Generalization
- between Actors
- between two use-cases
- Association from
- an actor to use-case
- use-case to an actor
- Use–case pyramid view -
- Logical
- Process
- Development
- Implimentation
Interaction diagrams -
- Dynamic behavior, i.e. when object exchange messages while executing scenario are shown by interaction diagrams –
- Collaboration focuses on - how (relations) the objects are linked. It has objects as rectangle and o:Object, link as a line, mesage an an arrow, and sequence of steps for each link. Collaboration allows to see -
- The complete set of services an object will have to provide
- Interface
- Linking of object
- Sequence (focuses on sequences i.e. time v/s class object/actor objects).
- Complexity and syntactical details are added in design phase. Interact diagram messages often correspond directly to the operations on class diagram. So a class operation can have the same names as the messages sent or received by its objects. We can use interaction diagrams to discover operations for a class. Object, which sends the message is called client, and object which is receiving the message is called supplier, because it provides services for client. An object can also sends a message to itself, which is called self-delegation.
- UML can represent the following message, which gets mapped to operations of the classes -
- Simple
- Synchronous
- Asynchronous
Objects and Object diagrams -
- These diagrams focus on HOW via Objects. Classes are template for an Object. By encapsulation relationship makes strong internal cohesion, and weak coupling with outside. An object encapsulates a portion of knowledge of the domain in which they evolve. It’s a static structure and has behavior at a given time. Object’s discovery leads to classes. It uses divided rectangle as an object and it’s attribute and links as lines. Object is an instance of a class. Object is an atomic entity in a system, which has -
- Identity - an unambiguous name
- State - dynamic Attributes (instance member variables) are hidden data elements i.e. data is encapsulated by Methods. State evolves with time. Attribute is an essential static part of an object and it represents state of an object. Attributes can be found from –
- Rejected candidate classes noun analysis
- Flow of events
- Problem statement
- Behavior - also called methods/operations and are responsible for action and re-action of an object. Different operations allow Objects to behave and interact with each other objects. An object is interlinked with other objects via links. If object A is sending message to B, then A knows what B is capable off receiving message. Operations are divided into two parts -
- Signature is made up of operation’s name, parameters and it’s type. It tells what (black-box view of class) an operation does. Interfaces are visible (also called published) operations along with attribute definition, which usually allow communication with hidden attributes. Standard interface makes more portable objects such as D-COM/CORBA. Since an Actor is an outside entity, it doesn’t use the operations directly.
- Implementation is made of actual algorithm and code. It tells how an operation will work.
- Encapsulation -
- This pays path for information hiding or encapsulation, which provides security to attributes i.e. data elements of an object. Degree of encapsulation depends upon visibility of its operations and attributes. Three levels of encapsulations -
- (-) Private - has strong encapsulation, which means that this cannot be used by the client class.
- (#) Protected - means that it’s can be used by class and sub-classes.
- (+) Public - has weak encapsulation, which means that it can be used by any class.
- Benefits of encapsulations –
- Data becomes safe and secure
- Class becomes more adaptable
- Client class does not need to know the implementation of server class
- Degree of coupling classes reduces
- Re-usability of class increases
- State and Behavior -
- State and Behavior are linked with each other. Behaviors at any given time depends upon current state and state may be modified by behavior. Object intercommunication means team of object operates and communicates in synergy to implement the functionality of an application.
- Category of behavior -
- Client - Active and is instigator of interactions
- Server - Passive and is target of message
- Agent - Combines the characteristics of Client and Server. Agent dissociate client object from server object by introducing an indirection in the message propagation mechanism.
- Benefits of Objects -
- Manageable
- Extensible
- Complexity
- Real World model
- Implementation constraints -
- Object persistence
- Persistence Object
- Non-persistence or transient or ephemeral Object
- Broadcasting object - broadcasting is cloning of an object from one process to another process
- Proxy object – proxy Objects is an alternative to object broadcasting. Local Proxy object automatically gets synchronized with remote object. Client interacts with proxy object, which hides all communication complexities.
- Message -
- Concept of message - foundation of communication relationship that dynamically/flexibly links the objects that were separated by de-composition process. It is responsible for the delegation of tasks, and guarantees that constraints are satisfied. Message flow can be of two type -
- Control
- Data
- Categories of Message -
- Constructor - Creates an object and fixes it initial stage
- Destructor - Deletes an object
- Selector - Returns a part of state of an object
- Modifier - Changes a part of state of an object
- Iterator - Visit the state of an Object or the content of data structure that includes several objects.
- Message Synchronization -
- Simple - Message from an active to passive object
- Synchronous - Message from sender to recipient and sender is blocked till recipient accepts the message such as Payment. Synchronous message represents that a nested flow of control. This means that the operation that handles the message is completed before the client object regains the focus. Synchronous message is usually implemented as an operation call between two objects on the same thread.
- Rendezvous - Recipient waits till it receives message such as Cashier ready to accept your money.
- Timed - Sender waits for acknowledgement from recipient for it's message for a specified time such as Phone.
- Asynchronous - Sender send the message without waiting for acknowledgement such as Post Mail. Asynchronous message indicates that the object that sends the message retains the focus of control in its thread while the supplier in its own thread is handling the message. Asynchronous messages are most frequently used in real-time system.
- Interaction between objects is depicted by -
- Collaboration
- Sequence Diagram
Class and Class diagram -
- Class and abstraction
- Class diagrams depicts various level of abstractions in a system -
- Single class
- Large group of class
- Relationship between classes
- Class includes objects with similar -
- properties
- behavior
- relationship to other objects
- abstraction - in order to simplify things we use abstraction, which means focus from a specific angle on elements and neglecting others. Concept of abstraction generates Classes. From an analysis angle, it is abstraction of reality and static view from general standpoint.
- Relationship
- Relationships can be defined by following features -
- Reflexive relationship (both association and aggression) - different objects belonging to same class may need to send message to each other. Role names are used instead of associations.
- Qualified associations (one to many, or many to many associations)
- Constraints. It either limits the applicability of an association or gives more detail to its meaning.
- Association classes in many to many relationships.
- Relationship between classes -
- Association is abstractions of object links, which tells us active/passive, role and multiplicity. The navigation direction of an association refers to the class or object that is capable of "knowing about" the other class or that is responsible for the collaboration. Navigation direction is shown by adding an arrowhead to point to the class that is "known about" by the other class. [PayRollManager] writes [PayCheck], which means that PayRollManager creates PayCheck, or PayCheck is created by PayRollManager. Role names can be used instead of association names. Associations are found in the use-case scenarios or sequence or collaboration diagrams. Look at the argument specified in the message.
- Aggression is strong and shows something "master and Salve" relationship and represented by diamond at the end. Initially associations are discovered and later they can be refined to aggression, depending the relationship i.e. strongly coupled. Aggregate object is made up of components and thus the relationship between it’s whole and part is called aggression. Aggregation (“has a”) is a special association that models a whole-part relationship between an aggregate and it’s part. Aggregation can have name, direction, navigation or a role names. It can be of following types -
- Shared
- Composition
- Composition is even stronger type of aggression with filled diamond, which is used in strict parent and child relation.
- Multiplicity can be -
- One to one
- One to many
- Many to many
- Parallels between class and object -
- Since an object is an instance of a class, class may not change during the lifetime of an object.
- Some classes such as abstract class may not be directly initiates.
- Each link is an instance of an association. Link connects objects and association connects classes.
- Link between two objects means that they know each other and may exchange messages.
- Class hierarchy -
- Generalization is transitive abstraction of sub-classes and generates super class. Multiple generalizations refer to multiple-inheritance. Generalization only pertains classes and can’t be instantiated via links – thus doesn’t have multiplicity. Also generalization is non-reflexive relationship such as class can't be derived from itself. Abstract class (opposite to concrete classes, which can instantiate an object) makes it possible to define common structure, relationships and behavior for several sub-classes. That’s why implementation is done sub-class levels. Inheritance depends upon polymorphism to work. Use generalization (super-class derived from the set of common sub-classes, by encapsulating the structure or/and behavior) and specialization (sub-class) to identify opportunities to use inheritance. Generalization and specialization can be used to view abstraction and inheritance respectively. Steps in generalization
- Check out the similarities
- Create supper-class, by encapsulating the shared -
- structure or
- behavior or
- both
- Sub-class from super-class
- Specialization is more close to real world. Steps in specialization -
- Examine candidate objects to determine whether they display specialized structure or behavior.
- Create sub-classes that group the objects together on the basis of their specialization.
- Difficulties of classification - Varies from view of point.
- Generalization is not suitable for Metamorphosis such as stages of order processing. Metamorphosis is change in it’s from, structure, or function, which means object changing the class they belong to. Example is Employe has PayClassification and PayClassification is either Hourly, Salaried and Commissioned.
- Levels in class hierarchy make it more difficult to understand and implement. Refining the hierarchy allows -
- increase re-use
- incorporate implementation classes
- incorporate available class libraries
- Inheritance – also referred as “is a” relationship, such as eagle is a bird. Inheritance is a mechanism to share structure, relationships and behavior between classes i.e. reuse of code. Super-class is inherited and child-class inherits. At times a class can act as both, super and child class. A sub-class can inherit attributes, interface and operations from its parent class. It satisfies two needs classification and construction.
- General principal - inheritance is a technique offered by programming language to construct a class from one or more classes, sharing attributes, operations and sometimes constraints with in a hierarchy of classes.
- Delegation - substitute to inheritance is possible, with selective inheritance, which is done manually.
- Substitution - child class will inherit all the attributes and operations from its parent class. Later constraints can be put on the required operation. This pays path for Polymorphism.
- Multiple inheritance - Multiple inheritance allow a class to inherit from more than one parent i.e. a sub-class has more than two parent super-classes. Inheritance copies the all the methods and attributes from parent to child having multiple inheritance. That’s why Java and ADA doesn’t have direct multiple inheritance. Problems are -
- Complicates the model
- Nonsensical subclass
- Name clashes because of multiple copies of inherited features
- Different concepts and roles with the same name leads to ambiguity
- Code will be less maintainable
- Normal tendency is to use multiple-inheritance, instead of aggregation, which should be avoided. An aggregation tree is composed of object instances that are all part of a composite objects. Where as an inheritance tree is made up of class that describe an object. Example - following objects
- Window
- WindowWithScrollbar
- Scrollbar
- Relationship will be -
- Inheritance - Window “is a” WindowWithScrollbar.
- Aggregation - WindowWithScrollbar “has a” Scrollbar.
- Polymorphism and overloading - Polymorphism means that the implementation of an operation depends on the object’s target type. Principal is that each sub-class inherits the operation specification of its supper class, and sub-class has ability to modify the behavior of these inherited operations locally. Polymorphism ability to trigger different operations in response to the same message. This provides the scalability to child class. Mainly done to ease out maintenance, to reduce the hierarchy and improve dynamism. Not considered in Analysis. Automatic selection of the correct code is the result of dynamic linking. Polymorphism exists when two conditions are met -
- An object from a sub-class acts as an object from a super-class.
- Sub-class redefines one or more of the operations contained in the super-class.
- Other features -
- Advantage of substitution - this also conform substitution, which is good practice.
- Operation overloading – ad hoc polymorphism. It is same operator name with different parameter. Overloading is resolved statically by compiler and has nothing to do with dynamic linking.
- Five key concepts to be considered while making classes -
- Avoid strong coupling (such as inheritance i.e. state, behavior and functionality) creates interdependency, which leads to -
- Difficulty in extending
- Bugs in one can affect others
- Program becomes complex to understand and maintain
- Avoid cohesion. Class, whose members are simply grouped together and have little in common are called coincidentally cohesive. Because elements of such classes don’t cohere to realize a purpose (i.e. one functionality), such classes are --
- Difficult to understand
- Difficult to use
- Too complex to implement
- Have sufficiency, which means class can function effectively.
- Have completeness, which means that interface should have all the behavior of the class.
- Primitiveness means that class should be simple and per the scope.
- Classes can be found in use-cases by looking at entities, boundaries and control classes, which are all UML stereotypes -
- Entities (contains information) - Entity is typically used to model business objects i.e. core concepts (independent and long lived information such as insurance policy) and it gets stored in the system. An entity class may be involved in many use-cases. An entity can be used among many applications. It can be of two type -
- Internal
- External
- Boundaries (presentation and manipulation of information) - Applying the boundary stereotype to a class, means that the class will specialize in interfacing to the outside world such as TCP/IP protocol, Windows and dialogue box etc. The main purpose of a boundary class is to handle communication between the system’s external actors and its use-case i.e. internal workings. Since user-friendliness requirement means different to different people, prototyping and storyboarding should be carried out to clarify any vague requirements. Unlike the entity class, the boundary class is dependent on the system’s surroundings. Two functions are -
- To model the system interface
- To provide the interface to actor
- Control classes (processing of information – when, what and who) - The control stereotype is used to handle a sequence of internal system operations i.e. use-case realization. This stereotype is also used to connect boundary objects with the correct entity objects. They represent dynamics of use-cases such as classes, which executes use-cases. Control classes are application dependent.
- Steps to create class diagrams -
- In use-case analysis, outline scenarios (just identification is sufficient and elaboration is not required) and interactions between the use-cases and the actors. Check out nouns (for candidate entity classes), verbs (for operations on candidate entity classes) and adjectives (for attributes). At this stage avoid computer implementation such as constructs, sub-routines, link-list etc.
- Refinement i.e. dropping of class name - One term can refer to more than one class or several terms can refer to the same class. Filter the unsuitable nouns. Drop candidate class, if it’s name is reflecting a role or is vague. Also consider application requirement and scope. Some nouns will become attributes of other classes such as name, weight and height. If you find that two more classes express the same information, then choose the most descriptive one such as Passenger is more descriptive than Customer. When candidate class name describes an operation, it is usually eliminated. However, is an operation has distinct feature, it can be identified as a class such as telephone call. The last reason for eliminating a candidate class is if it is an implementation construct. Any construct that is not part of the problem domain should be dropped during this early stage of analysis, although it might be needed later, during the design process.
- Identify entity, boundary, and control classes
- Group classes together to form packages by using stereotype of a package. Stereotypes are used to classify model elements - they were created in order to allow analysts to group classes and other model elements together. Classes that are classified with stereotypes belong together, because they share some general purpose. UML provides 40 predefined stereotypes. The main advantage of stereotypes is that, at a glance, they indicate the responsibility and the purpose of the class to which they are attached. Stereotypes name is placed between guillemets (i.e. << >>) or attaching an icon (i.e. graphical symbols).
- Create class diagram
- Document the classes
- Suggested categories are -
- Roles such as engineers
- Events such as requests
- Tangible things such as ATM Machines
- Non-tangible classes such as idea
- Interaction such as meetings
- Organizations
- Places
- Stereotype for classes -
- Actor
- Boundary
- Business Actor
- Business Entity
- Business Worker
- Control
- Domain
- Entity
- Interface
- Table
- View
- Four ways to create messages in UML -
- Interaction diagrams
- Rational Rose Browser
- Class diagrams
- Class specification
- vii) CRC (Class Responsibility Collaborator) cards, an alternative collaborative technique (i.e. business domain experts, analyst, object oriented designer and facilitator and observers - max six people), incremental and iterative technique to discover classes. It’s done after used-case and before object diagrams.
- CRC has three sections -
- Class - Class name
- Responsibility - What class knows or does
- Collaborator - Relationship with other classes
- Agenda for CRC, which is normally focused on one scenario -
- purpose of session
- who will attend and what role
- when and where
- how to prepare for session
Activity diagram -
- i) Object interaction diagrams that models dynamic behavior i.e. activity/process. Activity diagrams are used to model the business process or the flow of events through use-case. They can be used to implementation of an operation or to show how objects are affected by activities. They can also depict the parallel activities. It tells how use-case relates to each other (i.e. use-case workflow), easpecially parallelly.
- ii) Notations -
- (1) Start as filled circle
- (2) Transition as arrow from first to second activity i.e. occurrence of an event(), which can be labeled. Event is shown on first activity and can be –
- (a) A message being sent as a result of an operation call
- (b) A condition being fulfilled
- (c) A specific period of time elapsing
- (d) An error occurring
- (3) [Guard conditions]
- (4) Action expression
- (5) Send clauses (such as Printer.print(doc)) to send message between activities
- (6) Activity as rectangle with rounded corners
- (7) Inbound and outbound synchronization bars (along with description) as thick horizontal bar.
- (8) Iterator as * and description are called multiple triggers, which are mapped in collaboration and sequence diagrams. Multiple triggers are usually associated with synchronization bars.
- (9) Decision diamond
- (10) End point as bulls eye, which is optional
- (11) Dead-ends
- (12) Swim lanes at the end, after tagging is over
State diagrams -
- Event can cause the transition of objects from state to state (i.e. internal behavior of an objects), during the lifetime of an object. We can identify the state of an object by examining -
- Operations
- Value of attributes
- Links to other classes
- An action is best described as a task that takes place within a state. There are four possible actions within a state-
- On entry
- On exit
- Do
- On event
- State diagrams can be used to examine classes (usually boundary and control classes) that display complex behavior and undergo transitions between several states. State diagram shows a great deal of details and thus very time consuming.
- Notations -
- Start as filled circle
- Event/action is shown on all the transitions such as Age=60/Set leaving date/Notify pension department. Here action implies that the operation should take an insignificant amount and should be non-interruptible, which varies from system to system. Event is shown on first activity and can be –
- Conditions becoming true
- Time elapsing
- Error arising
- Message being received
- [Guard conditions]
- Activity as rectangle with rounded corners
- Nested boxes
- End point as bulls eye, which is optional
Model checking
- Since software development is an iterative process, quality needs to be checked at every step. Checking becomes important when we are switching over from analysis to design. A good model should –
- Easy to communicate to the people involved. Use the words used in problem definition
- Capture essential (i.e. core, which is internal to company and stays same in the long run) features of the problem domain. Relevant to problem domain
- Easy to maintain i.e. easy to change and extend
- Have clear purpose
- Easy to verify and validate
- Validation means that model conforms to customer’s expectation
- Verification means that model can be tested. Faults can be isolated and rectified in the model itself.
- Intelligent complex model –
- Top view and refinements i.e. exploded view
- Create sub-models by dividing large models into packages
- Check consistency on an ongoing basis. Proactive measures –
- Have naming guide lines
- Regular meetings
- Examine documentation
- Dedicated cross-section team consisting of at the most 6 people –
- Domain expert
- Programmer
- System designer
- Tester
- Customer
- Ensure model coordination
- Scenario walk-through
- Homogenize the model means that a model may contain classes (usually candidate classes) with no real functionality or a class is handling too many tasks.
- Homogenize means that all classes are –
- Unique
- Cohesive
- Relevant
- Homogenize entails –
- Combining similar classes
- Splitting classes, which have too many functions
- Eliminating classes, which does not have a structure functionality or behavior or is not involved in any scenario
|
|