Unit 1
Unit 1
•Object orientation
•Object Identity
•Generosity
•Importance of Modelling-Principles
•Architecture
•Object Orientation
•Object-oriented analysis and design (OOAD) is a technical approach for
analyzing and designing an application, system, or business by applying object-
oriented programming, as well as using visual modelling throughout the software
development process to guide stakeholder communication and product quality.
•What does Object-oriented mean?
•Object-oriented refers to a programming language, system or software methodology that is built
on the concepts of logical objects.
•It works through the creation, utilization and manipulation of reusable objects to perform a
specific task, process or objective.
•The essence of object-oriented is that each of the created objects can be reused in the same and
other programs and applications.
•The object-oriented approach, however, focuses on objects that represent abstract or concrete
things in the real world. These objects are first defined by their character and their properties,
which are represented by their internal structure and their attributes (data). The behavior of these
objects is described by methods (functions).
•Objects form a capsule, which combines the characteristics with behavior.
•Objects are intended to enable programmers to map a real problem and its proposed software
solution on a one-to-one basis.
•Object Oriented Programming
•Object Oriented programming (OOP) is a programming paradigm that
relies on the concept of classes and objects.
•It is used to structure a software program into simple, reusable pieces
of code blueprints (usually called classes), which are used to create
individual instances of objects.
•There are many object-oriented programming languages including
JavaScript, C++, Java, and Python.
•A class is an abstract blueprint used to create more specific, concrete
objects. Classes often
•For example, say we created a class car, to contain all the properties a
car must have, color, brand and model. We then create an instance of a
car type object, mica to represent my specific car.
•We could then set the value of the properties defined in the class to
describe my car, without affecting other objects or the class template.
•We can then reuse this class to represent any number of cars.
•Our car class may have a method repaint that changes the colour
attribute of our car. This function is only helpful to objects of type car, so
we declare it within the car class thus making it a method.
•Class templates are used as a blueprint to create individual objects.
These represent specific examples of the abstract class, like mica or
golden retriever. Each object can have unique values to the properties
defined in the class.
Class car{
String model, color, brand;
String repaint(colorchange)
{
color=colorchange;
Return color;
}
Func {}
}
main()
{
Car obj()
obj.model=xyz;
obj.color=blue;
obj.brand=hyundai;
Car obj1;
obj1.model=xyz;
obj1.color=blue;
obj1.brand=hyundai;
Obj.repaint(red);
}
•Uses of Object Orientation
•classes are essentially user defined data types. Classes are where we
create a blueprint for the structure of methods and attributes. Individual
objects are instantiated, or created from this blueprint.
•Classes contain fields for attributes, and methods for behaviours and
represent broad categories, like car or dog that share attributes.
•These classes define what attributes an instance of this type will have,
like color, but not the value of those attributes for a specific object.
•Classes can also contain functions, called methods available only to
objects of that type. These functions are defined within the class and
perform some action helpful to that specific type of object.
Objects
When individual objects are instantiated, these objects can call the
methods defined in the class.
• # class attribute
• String species = “bird"
•
• # instance attribute
• def __init__(self, name, age):
• self.name = name
• self.age = age# instantiate the Parrot class
•blu = Parrot("Blu", 10)
•print("Blu is a {}".format(blu.__class__.species))
•Specifically, consider that the final software system is the lowest level of
abstraction. All of the software's design details are present at this level.
Information hiding allows us to hide information unnecessary to a
particular level of abstraction within the final software system, allowing
for software engineers to better understand, develop and maintain the
software.
•We use software modules to implement information hiding: the
information contained in the modules should be hidden from those the
rest of the software system outside of the module, and access to this
hidden information should be carefully controlled. This allows us to
maintain a higher level of abstraction in our software, making our
•If information hiding is done well, changes made to the hidden portions
of a module should not affect anything outside of the module. This
allows the software engineers to more readily manage change
(including changes in the requirements).
•For example, a calculation producing a given result may be hidden. It
follows a model of functionality that can be described as a type of
information hiding.
•One advantage of information hiding is yielding flexibility, such as
allowing a programmer to more readily modify a program. This also may
be done by placing source code within modules for easy access in the
future, as the program develops and evolves.
•"Abstraction and encapsulation are complementary concepts:
abstraction focuses on the observable behavior of an
object...encapsulation focuses on the implementation that gives rise
to this behavior”
•an abstraction relates to how an object and its behaviors are
presented to the user and encapsulation is a methodology that helps
create that experience.
•Think about the interface of your mobile phone. Whether you use an
Android operating system or iOS, you don't interact directly with the
code that allows your phone to connect to the internet, send a text
message or play a video game. Instead, you interact with the code
through a user interface that is designed to streamline your
experience and make it easy to access the functions and methods you
need to complete a task. In this case, the interface is abstracted away
from the actual implementation of the code.
•Inheritance
•Inheritance allows classes to inherit features of other classes.
•If basic attributes and behaviors are defined in a parent class, child
classes can be created extending the functionality of the parent class,
and adding additional attributes and behaviors.
•The benefits of inheritance are programs can create a generic parent
class, and then create more specific child classes as needed. This
simplifies overall programming, because instead of recreating the
structure of the class multiple times, child classes automatically gain
access to functionalities within their parent class.
•Types of Inheritance
✦Single Inheritance − A subclass derives from a single super-class.
✦Hierarchical Inheritance − A class has a number of subclasses each of which may have
subsequent subclasses, continuing for a number of levels, so as to form a tree structure.
◦ value: A data value is used for identity (e.g., the primary key of a
tuple in a relational database).
◦ name: A user-supplied name is used for identity (e.g., file name in
a file system).
◦ built-in: A notion of identity is built-into the data model or
programming languages, and no user-supplied identifier is
required (e.g., in OO systems).
•Object identity is typically implemented via a unique, system-
generated OID. The value of the OID is not visible to the external
user, but is used internally by the system to identify each object
uniquely and to create and manage inter-object references.
•The object identity of two objects of the same type is the same, if
every change to either object is also a change to the other object.
Modelling
•Model is a simplification of reality.
1. Classes diagrams
2. Objects diagrams
3. Deployment diagrams
4. Package diagrams
5. Composite structure diagram
6. Component diagram
• This model represents the framework for the system and all the components exist here.
• It represents the elements and the mechanism to assemble them.
• It never describes the dynamic behavior of the system.
2. Behavioral modeling
• It describes the interaction within the system.
1. Activity diagrams
2. Interaction diagrams
• The structural and the behaviour elements of the system are there in
this system.
• It is defined as the blue print for the entire system.
✓The right models will simplify even the most wicked problem, offering
insights that couldn’t have been gained otherwise.
The wrong models will mislead us, causing to focus on irrelevant issues.
• Principle 2: Every model maybe expressed at different levels of
abstraction.
• Help the stakeholders visualise the look and feel of system.
•
• Principle 4: No single model is sufficient, a set of models is needed to solve any non-trivial
system
• To understand the architecture of such a system, we need several complementary and
interlocking views:
A design view (capturing the vocabulary of the problem space and solution space).
An interaction view (showing interaction among parts of the system and between
the system and environment).
•In analysis phase, OO models are used to fill the gap between problem
and solution. It performs well in situation where systems are
undergoing continuous design, adaption, and maintenance. It identifies
the objects in problem domain, classifying them in terms of data and
behavior.
•The OO model is beneficial in the following ways −
•Abstraction
•Relationships
•Inheritance
•Polymorphism
Elements of Object-Oriented System
• Objects − An object is something that is exists within problem domain and
can be identified by data (attribute) or behavior. All tangible entities
(student, patient) and some intangible entities (bank account) are modeled
as object.
• Attributes − They describe information about the object.
• Behavior − It specifies what the object can do. It defines the operation
performed on objects.
• Class − A class encapsulates the data and its behavior. Objects with similar
meaning and purpose grouped together as class.
• Methods − Methods determine the behavior of a class. They are nothing
more than an action that an object can perform.
• Message − A message is a function or procedure call from one object to
another. They are information sent to objects to trigger methods. Essentially,
a message is a function or procedure call from one object to another.