Professional Documents
Culture Documents
ii) In the phase of OOD, the questions typically start with How…? Like, “How will the
class handle its responsibilities?”, “How to ensure that this class knows all the
information it needs?”,” How will classes in the design communicate”?
- The OOD phase deals with finding a conceptual solution to the problem. It is about
fulfilling the requirements, but nit about implementation the solution.
1.1.1 OOA (Object oriented Analysis)
- It determined the system requirements, recognized the class and relationship between the
classes.
- During software requirement phase, requirement analysis and object analysis. it is the
method of analysis that examines requirements from the perspective of classes and
objects as related to the problem domain.
- OOA emphasis the building of real-world using the object oriented view of the world.
- The main purpose of OOA is to recognized application domain and specification
requirements of the system.
There are three different techniques of OOA:
1) Object Modeling
- It developed the static structure of the system regarding to object.
- It recognizes the objects, relationship between objects and classes in which objects
or groups.
2) Dynamic Modeling
- Explain how single objects responds to event.
- The main aim is examining the behavior of the objects regarding time and external
changes.
3) Functional Modeling
- It shows the processes executed in an object how the data change while it moves
between methods.
The process of functional modeling:
1. All inputs and outputs are recognized.
2. Create a data flow diagram to show functional dependencies.
3. Identify every function.
4. Identify the constraints.
5. Describe the optimization criteria.
During OOD, there is an emphasis on define software objects and how they are collaborating to
fulfill the requirements.
- During user requirements phase: OOD involves understanding of the application domain
and build an object model.
- Identify Objects: It is a method of design showing process of object-oriented
decomposition.
OOD is a method of design encompassing the process of object oriented decomposition and a
notation for depicting logical and physical as well as static and dynamic model of the system
under design.
For example: In the library system a book software object may hive title attribute and a
getChapter method.
B. Class
- The class represents a collection of objects having same characteristics properties that
exhibit common behavior.
- It gives the blueprint or description of the objects that can be created from it.
- Creation of an object as a member of a class is called instantiation.
The constituents of a class are:
- A set of attributes for the objects that are to be instantiated from the class. Generally,
different object of a class has some difference in the value of the attribute.
- A set of operation that portray the behavior of the objects of the class. Operations are also
referred as functions or method.
Data Hiding
- Typically, a class is designed such that its data or attribute can be accessed only by its
class methods and insulated from direct outside access.
- This process of insulating (creating a barrier) an object data is called data hiding or
information hiding.
D. Polymorphism
- Polymorphism allows objects with different internal structures to have a common
external interface.
- Polymorphism is particularly effective while implementing inheritance.
- I object-oriented paradigm, polymorphism implies using operations in different ways,
depending upon the instance they are operating.
E. Abstraction
Abstraction is a dependency relationship that relates two elements or set of elements
repressing the same concept but at different levels of abstraction or from different
viewpoints.
F. Inheritance
- Inheritance is the mechanism that permits new classes to be created out of existing
classed by extending and refining it capabilities.
- The existing classes are called the base classes/parent classes/super-classes, and the new
classes are called the derived classes/child class/subclasses.
- The subclass can inherit or derive the attributes and methods of the superclass provided
that the superclass allows so.
Types of Inheritance:
1. Single inheritance: A subclass derives from the single super-class.
2. Multiple Inheritance: A subclass derives from more than one-super classes.
3. Multilevel Inheritance: A subclass derives from a super-class which is turn in
derived from another class and so on.
4. Hierarchical Inheritance: A class has a number of subclaess each of which may
have subsequent classes, continuing for a number if levels, so as to form a tree
structure.
5. Hybrid Inheritance: A combination of multipe classes.
Student
student
Student
Student
G. Hierarchy:
Hierarchy is the ranking or ordering of abstraction. Through hierarchy, a system can be
made up of interrelated subsystem, which can have their own subsystem and so on until
the smallest level components are reached. It uses the principle of divide.
H. Modularity:
I. Object Interaction:
J. Interface Implementation:
1. How object interaction and Interface implement are implemented in OOAD? Write the
example in programming language.
2. Difference between OOA, OOD and OOP.
OOA OOD OOP
3. Why encapsulation and polymorphism are used in OOAD? Explain with Your own view
with example.
4. What is the difference between object and class?
5. Explain OOD, OOA and OOP?
6. What is analysis and design?
7. Define class diagram and object diagram?
8. Describe hierarchical method and inheritance methods in detail.
Chapter TWO:
2.1 Unified Modeling Language (UML)
- The unified modeling language is a graphical language for OOAD that gives standard
way to write a software system’s blueprint.
- It helps to visualize, specify, construct, and document the artifact of an object-oriented
system.
- It used to depict the structure and the relationship in a complex system.
- The goal of UML is to provide a standard notation that can be used by all object-oriented
methods and to select and integrate the best elements of precursor notations.
History
- It was developed 1990s as an amalgamation of several techniques, prominently OOAD
technique by Grady Booch, OMT (object modeling technique) by James Rumbaugh and
OOSE (object oriented software engineering) by Ivar Jacobson.
- UML attempted to standardize semantic models, syntactic notations, and diagrams of
OOAD.
1. Object Modeling technique OMT [ James Rumbaugh 1991] was best for analysis and
data intensive information system.
2. Booch [Grady Booch 1994] – was excellent for design and implementation. Grady
Booch had worked extensively with the ADA language, and had been a major player in
the development of object oriented techniques for the language. Although, the Booch
method was strong, the notation was less well received.
3. OOSE [Object-oriented software Engineering Ivar Jacobson 1992]- featured a model
known as use cases. Use cases are a powerful technique for understanding the behavior
an entire system.
2. Object Notation
- The object is represented in the same way as the class.
- The only difference is the name which is underlined.
3. Interface Notation
- Interface is represented by a circle.
- Interface is used to describe the functionality without implementation. Interface is just
like a template, where you define functions.
- When a class implements the interface, it also implements the functionality as per
requirements.
4. Collaboration Notation
- Use case is represented by a dotted eclipse.
- Generally, responsibilities are in a group.
8. Final notation
- Final state is used to show the end of the process. This notation is also used in almost all
diagrams to describe the end.
- The usage of Final notation is to show the termination point of a process.
Behavioral Things
- Dynamic parts are one of the most important elements in
UML. UML has a set of powerful features to represent the dynamic part of software and
1. Interaction notation
- Interaction is basically a message exchange between two UML components.
- Interaction notation is used to represent the communication among the components of a
system.
There are 14 UML diagrams types to help you model the system behavior. There are two
main categories; Structure diagrams and behavioral diagrams.
Structure Diagram
1) Class diagram
2) Component Diagram
3) Deployment Diagram
4) Object Diagram
5) Package Diagram
6) Profile Diagram
7) Composite structure Diagram
Behavioral Diagram
1) Use case Diagram
2) Activity Diagram
3) State Machine Diagram
4) Sequence Diagram
5) Communication Diagram
6) Interaction Diagram
7) Timing Diagram
2.4 Extend, Generalization, Specification
2.4.1 Extend relationship
- In UML modeling, we can use an extend relationship to specify that one use case
(Extension) extends the behavior of another use case (Base). This type of relationship
reveals details about a system or application that are typically hidden in a use case.
- The extend relationship specifies that the incorporation of the extension use case is
dependent on what happens when the base use case executes.
- While the base use case is defined independently and is meaningful by itself, the
extension use case is not meaningful on its own.
For example:
You are developing an e-commerce system in which you have a base use case called
PlaceOnlineOrder that has an extending use case called specify shipping instructions.
An extend relationship point from the specify shipping instructions use case to the
PlaceOnlineOrder use case to indicate that the behaviors in the specify shipping
instructions use care are optional and only occur in certain circumstances.
2.4.2 Generalization
- In UML modeling, a generalization relationship that implements the concept of object
oriented called inheritance.
- The generalization relationship occurs between two entities or objects, such that one
entity is the parent, and the other one is the child. The child inherits the functionality of
its parent and can access as well as updated it.
- Generalization relationships is utilized in class, component, deployment and use case
diagrams to specify that the child inherits actions, characteristics, and relationship from
its parent.
- The generalization relationship is incorporated to record attributes, operations, and
relationships in a parent model element so that it can be inherited in one or more child
model elements.
2.4.3 Instance of Specification in UML
- In UML models, instance specification are elements that represent an instance in the
modeled system.
- When you instantiate a classifier model, the instance specification that you create
represents an entity in the modeled system at a point in time, similar to a snapshot of the
entity.
- Instance specification can include the following information about the entity:
o The classification of the entity by one or more classifiers of which the entity is an
instance.
o The kind of instance, based on its classifier; for example, an instance specification
whose classifier is a class describes an object of that class, while an instance
specification whose classifier is an association describes a link of that association.
o Specific values of the structural features of the entity, which are represented by
slots.
2.5 Object-oriented Development Life cycle (Iterative and Incremental Life cycle)
(VVI)
2.5.1: Iterative Model:
- In the iterative model, iterative process starts with a simple implementation of small set
of the software requirements and iteratively enhances the evolving versions until the
complete system is implemented and ready to deploy.
- An iterative life cycle model does not attempt to start with a full specification
requirement. Instead, development beings by specifying and implementing just part of
the software, which is reviewed to identify further requirements.
- this process is then repeated, producing a new version of the software at the end of each
iteration of the model.
Applications:
- Requirements of the complete system are clearly defined and understood.
- Major requirements must be defined, however, some functionalities or requested
enhancements may evolve with time.
- There is a time to the market constraint.
- A new technology is being used and is being learnt by the development team while
working on the project.
- Resources with needed skill sets are not available and are planned to be used on
contract basis for specific iterations.
- There are some high risk features and goals which may change in the future.
Advantage and Disadvantage:
Advantage:
1) Some working functionality can be developed quickly and early in the life cycle.
2) Results are obtained early and periodically.
3) Parallel development can be planned.
4) Progress can be measured.
5) Less costly to change the scope/requirement.
6) Testing and debugging during smaller iteration is easy.
7) Manage Risk
8) Operational product delivered.
9) Risk analysis is better.
Disadvantage
1. More resources may be required.
2. Cost if change is lesser but it is not very suitable for changing requirement.
3. More management attention is required.
4. Not suitable for smaller projects.
5. Management complexity high.
- The system is put into production when the first increment is delivered. The fist
increment is often a core product where the basic requirements are addressed, and
supplementary features are added in the next increments.
- Once the core product is analyzed by the client, there is plan development for the next
increment.
Characteristics:
- System development is broken down into many mini development projects.
- High priority requirement is tackled first.
- Once the requirement is developed, requirements for that increment are frozen.
- Produce a final total system.
When to use Incremental models?
- Requirements of the system are clearly understood.
- When demand for an early release of a product arises.
- When software engineering team are not very well skilled or trained.
- High risk features and goals are involved.
- Such methodology is more in user for web application and product based companies.
Advantages and Disadvantages
Advantage:
1) The software will be generated quickly during the software life cycle.
2) Flexible and less expensive to change requirements and scope.
3) Development stages changes can be done.
4) Less costly compared to others.
5) A customer can respond to each building.
6) Errors are easy to identified.
Disadvantage:
- It requires a good planning designing.
- Problems might cause due to system architecture as such not all requirements collected
up front for the entire software cycle.
- Does not overlap each other while incremental phase is rigid.
- All the units consume a lot of time.
Assignment
Chapter Three
Object Oriented Analysis
2) State model
- State model describes those aspects of objects concerned with time and the sequencing
of operations, events that mark changes, states that define the context for events, and
the organization of events and states.
- Actions and events in a state diagram becomes operations on objects in the class model.
- State diagram describes the state model.
3) Interaction model
Interaction model is used to show the various interactions between objects, how the
object collaborates to achieve the behavior of the system as a whole.
The following diagrams are used to show the interaction model:
- use case diagram
- sequence diagram
- Activity diagram
Conceptual Classes
- The domain model illustrates conceptual classes or vocabulary in the
domain. Informally, a conceptual class is an idea, things, or object. But
More formally, a conceptual class may be considered in terms of its symbol,
Intension and extension.
- Symbol: - Words or images representing a conceptual class.
- Intension: - the definition of a conceptual class.
- Extension- the set of examples to which the conceptual class applies.
For example, consider the conceptual class for the event of a purchase
transaction. I may choose to name it by the (English) symbol sale.
The intension of a sale may state that it “represent the event of a purchase
transaction, and has a date and time.”
The extension of Sale is all the examples of sales; in other words, the set of all
sale instances in the universe.
2..8
plays Contain
owns Is-on
Player Piece Square
3.2 Define Attributes
It is useful to identify those attributes of conceptual classes that are needed
to satisfy the information requirements of the current scenarios under
development.
An attribute is a logical data value of an object.
When to show Attributes?
Include attributes that the requirements suggest or imply a need to
remember information.
For example, a receipt (which reports the information of a sale) in the
Process Sale use case normally includes a date and time, the store name
and address, cashier ID, among many other things.
Therefore,
Sale needs a dataTime attribute
Store needs a name and address
Cashier needs an ID.
Attribute Notation in UML
The full syntax for an attribute in the UML is:
Derived
attribute
What are suitable attribute types?
Focus on Data Type attributes in the domain model
Assignment
1. Draw a use case diagram for a bank ATM.
2. Relationship between sequence diagrams and use cases
3. Relationship between class diagram and use cases
4. Benefits of software model
5. Importance of model building
CHAPTER 4 OBJECT ORIENTED DESIGN
4.1 Introduction Object Oriented Design (OOD)
4.1.1 Introduction:
o OOD transforms the analysis model created using OOA into a design
model that serves as a blueprint for software construction.
o OOD results in a design that achieves a number of different levels of
modularity.
o Subsystem: major system components.
o Objects: Data and the operations.
o Four important software design concept:
Abstraction
Information Hiding
Functional independence
Modularity
o As stated earlier, analysis is the practice of studying a problem
domain, leading a specification of externally observable behavior.
o Building on this, design is the practice of taking a specification of
externally observable behavior and adding details needed for actual
computer system implementation.
o Analysis is what or the problem phase. Design is the how or the
solution phase.
o OOD consists mainly of expanding the requirements model to
account for the complexities introduced in selecting a particular
implementation.
Human interaction.
Data management
Other implementations area.
4.1.2 OOD Goals:
- To design classes identified during analysis phase and user interface.
- Identify additional objects and classes that support implementation of
requirements.
o E.g. add objects for user interface to system (data entry window,
browser windows)
- Can be intertwined with analysis phase
o Highly incremental, e.g. can start with OOA, model it, create OOD,
then do some more of each again and again, gradually refining and
completing models of system.
- Activities and focus of OO analysis and OO design are intertwined.
4.1.3 OOD steps:
Board
How does create pattern lead to this partial sequence diagram?
- How does Create Patten develop this Design class diagram (DCD)?
Need all SalesLineItem instance and their subtotals. Only sakes know this so
Sale is the information expert.
Hence.
Hence responsibilities assigned to the three classes are as follows:
Class Responsibility
Sale Knows sale total
SalesLineItem Knows line item subtotal
ProductSpecification Know product price
c)Low coupling
- How strongly the objects are connected to each other?
- Coupling: Object depending on the other object.
- When depended upon element change, it affects the dependent also.
- Low coupling: how can we reduce the impact of change in depended upon
elements on dependent elements.
- Assign responsibilities so that coupling remain low.
- Minimizes the dependency hence making system maintainable, efficient
and code reusable.
- Two elements are coupled, if
o One element has aggregation/composition association with another
element.
o One element implements/extends other element.
Example:
- VideoStore and Video class are coupled, and RentVideo is coupled with
VideoStore. Thus providing low coupling.
d)
Controller
- Deals
with how to
delegate
the
request
from the UI
layer
objects to domain layer objects.
- When a request comes from UI layer objects, Controller pattern helps us in
determining what is that first object that receive the message from the UI
layer Objects.
- This object is called controller object which receives request from UI layer
object and then controls/coordinates with other object of the domain layer
to fulfill the request.
- It delegates the work to other class and coordinates the overall activities.
We can make an object as controller, if
- Object represents the overall system.
- Object represent a use case, handling a sequence of operation (session
controller).
Benefits
- Can reuse this controller class.
- Can use to maintain the state of the use case.
- Can control the sequence of the activities.
Example:
e) High Cohesion
- How are the operations of any element are functionally related?
o Related responsibilities in to one manageable unit.
o Prefer high cohesion
o Clearly defines the purpose of elements.
Benefits:
- Easily understandable and maintainable.
- Code reuse
- Low coupling
Low cohesion
High Cohesion
4.2.2 Applying GoF design Patterns: adapter, singleton, factory and observer
patterns
- The GoF design patterns are broken into three categories:
Types of Visibility
There are four common ways that visibility can be achieved from object A
to object B.
1. Attribute Visibility: B is an attribute of A.
2. Parameter Visibility: B is a parameter of a method of A.
3. Local Visibility: B is a local object in a method of A.
4. Global Visibility: B is in some way globally visible.
1. Attribute Visibility:
Attribute visibility from A to B exists when B is an attribute of A. It is a
relatively permanent visibility because it persists as long as A and B
exists. This is a very common form of visibility in Object-oriented
system.
For example, a class definition statements and method creating
statement as below:
class Profile:
def __init__(self,name,add):
self.name = name
self.add = add
class Info(Profile):
def __init__(self,name,add,sal):
Profile. __init__(self,name,add)
self.sal = sal
def info(self):
print (f"Hello my name is {self.name} and I am from {self.add} My
Salary is {self.sal}")
obj = Info('Ram',"Kathmandu",10000)
obj.info ()
Output: Hello my name is Ram and I am from Kathmandu My Salary is 10000
2. Parameter Visibility:
Parameter visibility from A to B exists when B is passed as a parameter
to a method of A. It is a relatively temporary visibility because it persists
only within the scope of the method.
In this collaboration diagram, the makeLineItem message is sent to a
Sale Instance, passing a ProductSpecifiction instance as a parameter.
Within the scope of the makeLineItem method, the sale has parameter
visibility to a ProductSpecification.
{
makeLineItem (ProductSpecification spec, int, qty)
{
…
Sl = newSaleLineItem (Spec, qty)
….
}
}
It is common to transform parameter visibility into attribute visibility.
For example, when the sale creates a nesSaleLIneItem, it passes a
PrdouctSpecification into its initializing method. Within the initializing
method, the parameter is assigned to an attribute, thus establishing
attribute visibility.
Class Name
Responsibilities Collaborations
Example: Create a CRC model for a simple shipping/inventory control
system.
Order
Order Number Oder Item
Date Ordered Customer
Date Shipped
Order Items
Calculate order total
Print invoice
Cancel Order Item
Inventory
QuantityItem Inventory
Customer
Inventory
Item numberItem Item
Name Surface Calculate total
Name
Phone Number address Description
Customer Number Unit Price
Mark Order Give Price
Cancel Order
Make a payment
Surface address
Street
City
State
Zip
Print label
Fig: A CRC model for a simple/inventory control system.
Assignment
4.5 UML state diagrams and modeling
ATM PIN verification
Category of Exception
1. Checked exception
- It is the exception that cannot be foreseen by the programmer.
File Not Found Exception
2. Runtime exception
- It is the exception that could be avoided by the programmer.
- It is ignored at the time of compilation.
3. Error
- They are the problems beyond the control of user and programmer.
Exception Handling Process:
- In OOPL, there is a mechanism to handle exceptions in a proper manner.
- Try, throw and catch are the basic exception handling paradigms used.
- The general code is put in try block. It means try to execute the code.
- If the system succeeds to execute the code, execution flows in general or
normal order.
- If something goes wrong while executing the try block, this code throws an
exception objects and stops executing code of try block.
- The error handler catches the exception object and make necessary actions
needed.
- Execution continues with the next instructions following the catch block.
Exception Hierarchy
User Defined Exceptions
- All the exceptions must inherit Throwable class.
- For runtime exception, extend RuntimeException class.
- For checked exception, extend exception class.
b) Reverse engineering
- Reverse engineering is the process of extracting knowledge or design
information from the code.
- It includes disassembling of a computer program and analyze its
components and working in details.
- It transforms code into a model through mapping from a specific
implementation language.
- It is generally incomplete as the model cannot be completely recreated due
to information loss during forward engineering process.
c) Roundtrip engineering
- Roundtrip engineering is a functionality that synchronizes two or more
software artifacts like source code, models and so on.
- It is necessary when same information is present in multiple artifacts and
needed to be updated.
- It has ability to synchronize existing artifacts that evolved concurrently by
incrementally updating each artificats to reflect changes made to other
artifacts.
d) Interface
- Interface is a concept of abstraction and encapsulation.
- It defines a set of methods, that an instance of a class that has that
interface.
- It declares the non-private method.
- It does not show the method implementation.
- It describes the actions that an object can do.
- No variables are allowed to be declared.
- All the functions listed must be public.
- The function description is not mentioned.
Example
public interface vehicle
{
function start_engine();
}
public class car implements vehicle
{
{
Function start_engine()
{
…….
}
}
5.5 Activity
diagram
and Swim
Lanes
- Draw activity diagram to withdraw money from ATM.
Course Complete
Questions
Submitted date: 8th August 2021
1. Draw the use case diagram for withdraw cash of Banking system.
2. Explain the types of OOAD models and describe the role of constraint
specification in a diagram.
3. Explain forward engineering and reverse engineering with its advantage.
4. What is CRC? Explain with the diagram.
5. Difference between OOD and OOA.
6. Construct a system sequence diagram for customer from a “Food ordering
system” of a very busy restaurant where seating and ordering is regulated
by seating manager.
7. Illustrate how can you create classes from design class diagram and
methods from interaction diagrams.
8. Explain development process with suitable example. How can you map
design into code?
9. What is framework? How design pattern is useful? Explain any one pattern
in details with suitable example.
10. Read the following case study carefully and answer the given questions:
Ministry of Health and population is willing to computerize the system. This
new system will be able to tell the population of the country, zone and
district and even of the word of specific place. The system will update its
data in monthly basis so that the birth rate and death rate can be easily
seen. The home page is displayed when a person enters to the system.
Administrators can enter to the admin panel by logging in with an ID and
Password. He/She has privileges to enter and modify the data into the
database. On the other hand, normal users can view the data but not
modify them. They can also visualize the data in graphical form with
animated charts, maps as well as in tabular form based on their selection of
data. Besides, they can also view the forecasted data. (Make your
assumptions if necessary)
Draw the collaboration diagram and use case diagram.
11. PU is willing to develop a system for the student result management of its
BCA program. Now, prepare the problem statement from the side of
examination control division. What are the building blocks of UML? Explain
with suitable examples and notations.
12. Explain object oriented system with reference to class, object,
encapsulation, abstraction message, inheritance, interface and
polymorphism with suitable examples.
13.Write short notes
a. Sequence diagram
b. Swim lanes
c. Polymorphic signal
14. Draw a state diagram for the clock control unit.
15.Explain four different types of relationships that we model in object-
oriented analysis, which exists between two different classes.
a. Dependency
b. Association
c. Realization
d. Generalization