Download as pdf or txt
Download as pdf or txt
You are on page 1of 54

Object Oriented Concepts

Abstraction
• Is a process of hiding superfluous details and highlighting pertinent
details.
• Car, Chair, Room, Train, Laptop all are examples of abstractions.
• Abstraction has levels e.g. wall is hiding details of bricks, room is
hiding details of walls and building is hiding details of rooms.
Encapsulation
• Is a mechanism which implements abstraction
• E.g. in C++, class provides mechanism to hide superfluous details and
highlight pertinent details. There are access specifiers- private, public
and protected. The details which is to be hidden is written as private
and the details which is to be highlighted is written as public.
• Data members should be private and methods should be public.
Object
Object is anything tangible or non-tangible which has crisply defined
boundary
• Four characteristics
• Unique identification
• Set of attributes
• Set of states
• Set of operations (Behavior)
Class
• Class is a generic specification for all the objects of similar structure
and similar behavior.
• Class is a template that can churn out as many objects as many you
like of similar structure and similar behavior.
Typing
• Strongly typed – Java, Python, C#
• Weakly typed – PHP, JavaScript, C
• Untyped – Assembly, ML
Object Persistence
• Object Persistence in time
• Object persistence in space
• Techniques
• Images (Hibernation)
• Journals (storing events in logs)
• Dirty Writing
• Examples
• History
• Persistent databases
• Persistent OS (survives after crash)– KeyKOS, EROS, Lua os, Phantom
Concurrency
• Concurrency is a property of a system in which several behaviors can
overlap in time – the ability to perform two or more tasks at once.
• The objects in real world are inherently concurrent
• Examples of concurrency
• Multitasking
• Multiprogramming
• Time sharing
• Multithreading
• Multiprocessing
Modularity
• Degree to which a system components can be separated and
recombined, often with the benefit of flexibility and variety in use
• Modularity is the process of decomposing a problem (program) into a
set of modules so as to reduce the overall complexity of the problem
• “Modularity is the property of a system that has been decomposed
into a set of cohesive and loosely coupled modules.
• Modularity enables re-usability and minimizes duplication.
Meta Data
• Data about data
• Is structured information that describes, explains, locates or
otherwise makes it easier to retrieve, use or manage an information
resource.
• Types
• Administrative metadata – management aspect – how file is created, type etc.
• Descriptive metadata – author, language, purpose
• Structural metadata – index of a book, ToC, databases-table, column, keys,
indexes
Abstract/Concrete Class
• Abstract class is used to specify the required behavior (operations) of
a class, without having to provide their actual implementations. An
operation without implementation is called an abstract operation.
• It can not be instantiated
• Must be inherited
• It may have concrete methods
• It may have abstract methods
• Abstract methods of such class must be overridden
Constraints
• Invariants - Invariant is a condition that is supposed to be true all the
time
• Pre-condition - These are conditions that must be true before a
function (or code segment) executes, in order for the code to work
correctly.
• Post-condition - These are conditions that are true after a functions
returns or at the end of a code segment.
Introduction to UML
UML in One Sentence
The UML is a graphical language for
• visualizing
• specifying
• constructing
• documenting
artifacts of a software-intensive system.

14
Unified Means
• across historical methods and notations
• across the development cycles
• across application domains
• across implementation languages and platforms
• across development processes
Language
• UML is a language
• language has vocabulary consisting of nouns, verbs
• there are grammatical rules
Visualizing
• explicit model facilitates communication
• some structures transcend what can be
represented in programming language
• each symbol has well-defined semantics behind it

17
Specifying
The UML addresses the specification of all
important analysis, design, and implementation
decisions.

18
Constructing
• Forward engineering: generation of code from
model into programming language
• Reverse engineering: reconstructing model from
implementation
• Round-trip engineering: going both ways

19
Documenting
Artifacts include:
• deliverables, such as requirements documents,
functional specifications, and test plans
• materials that are critical in controlling,
measuring, and communicating about a system
during development and after deployment

20
Modeling Means
• What is model?
• a model is a representation in a certain medium of something in the
same or another medium. The art of developing model is called as
modeling.
• E.g. globe is model of earth
• Map of territory of India is model of India
• Map of a house is model of house
why do we model?
why do we model?
Concptual Model of UML

Basic Building Blocks

• Things - important modeling concepts - abstractions

• Relationships - tying individual things

• Diagrams - grouping interrelated collections of things


and relationships

24
The UML Things
There are four kinds of things in the UML.

1. Structural Things - nouns/static parts of models


(conceptual/physical).
2. Behavioral Things - verbs/dynamic parts of UML models.
3. Grouping Things - organizational parts of UML models.
4. Annotational Things - explanatory parts of UML models.
Things in UML

Structural Things Behavioral Things Grouping Things Annotational Things

1. Class 1. Interaction 1. Packages 1. Notes

2. Interface 2. State Mechanism

3. Collaboration

4. Use Case

5. Active Class

6. Components

7. Nodes
Class
Interface
• interface is a collection of operations that specify as a service of a
class or component

• interfaces are model elements that define sets of operations that


other model elements, such as classes, or components must
implement.
Interface
Component
• Component is a physical and repeatable part of a system that
conforms to and provides realization of a set of interfaces.

• "it is a module of classes that represent independent systems or


subsystems with the ability to interface with the rest of the system”.
Component
Collaboration

• it defines an interaction and is a society of roles and other elements


that work together to provide some cooperative behaviour that's
bigger than the sum of all the elements.
Collaboration is represented by a dotted eclipse
as shown in the following figure. It has a name
written inside the eclipse.
Use case
• it is a description of set of sequence of actions that a system performs
that yields an observable result of value to a particular actor.
• Use case is used to capture high level functionalities of a system.
Use Case
Node
• it is a physical element that exists at runtime and represents a
computational resource having some memory and computational
capability.
• Node is used to represent the physical part of a system such as the
server, network, etc.
Node
active class
• Active Classes
• Active classes initiate and control the flow of activity, while passive
classes store data and serve other classes. Illustrate active classes
with a thicker border.
Active Class
Principles of Modeling
• choice of models to create very influential as far as
how to attack problem and shape solution
• every model may be expressed at different levels
of precision
• best models connected to reality
• no single model is sufficient

41
Behavioral Things in UML
• Verbs
• Dynamic parts of UML models
• Usually connected to structural things.

• Two primary kinds of behavioral things:


• Interaction
a set of objects exchanging messages, to accomplish a specific purpose.

• State Machine
specifies the sequence of states an object or an interaction goes through during its
lifetime in response to events.

42
Grouping Things in UML: Packages
- For organizing elements (structural/behavioral) into groups.
- Purely conceptual; only exists at development time.
- Can be nested.
- Variations of packages are: Frameworks, models, & subsystems.

University Administration

Course Manager Course Manager Student Admission

-Student
+Department

Annotational Things in UML: Note


- Explanatory/Comment parts of UML models - usually called adornments
- Expressed in informal or formal text.

operation()
flexible {for all g in children
drop-out dates g.operation()
43
}
Diagrams in UML
A Diagram is the graphical presentation of a set of
elements, most often rendered as a connected graph of
things and relationships. UML includes 9 such diagrams.
1. Class Diagram.
2. Object Diagram.
3. Use Case Diagram.
4. Sequence Diagram.
5. Collaboration Diagram.
6. State Chart Diagram.
7. Activity Diagram.
9. Deployment Diagram.
Rules of the UML
• The UML has semantic rules for
• Names – wt u can call things, relationships & diagrams
• Scope – the context that gives specific meaning to a name
• Visibility – how those names can be seen and used by others
• Integrity – how things properly and consistently relate to one another
• Execution – wt it means to run or simulate a dynamic model
Rules of the UML…
• A well-formed UML model is one that is semantically self-consistent &
in harmony with all its related models
• Models evolve over time… so it can be
• Elided: certain elements are hidden to simplify the view
• Incomplete: certain elements may be missing
• Inconsistent – integrity of the model is not guaranteed
Common Mechanisms in UML
• Specifications
• Adornments
• Common divisions
• Extensibility mechanisms
Specifications
• UML models have two dimensions – graphical dimension + textual
dimension
• Specifications are textual descriptions of the semantics of an element
 semantic backplane
Specifications…
Adornments
• Visibility of attributes/operations
• - private
• + public
• # protected
• / derived attributes

• Abstract/concrete
Common divisions
• Specifications/Implementation
• Class/Instance
• Interface/class
Extensibility mechanisms
• Stereotypes: (<< >>) extends the vocabulary of UML allowing u to
create new kind of building blocks that are derived from existing one
but that are specific to your problem
• Tagged value: extends the properties of a UML building block,
allowing u to create new information in that element
• Constraints: extends the semantic of a UML building block, allowing u
to add new rule or modify existing one
UML Views of a System
• The architecture of a system is the fundamental
organization of the system as a whole.
• The five UML Views:
● Use Case View: focuses on scenarios
● Design View: focuses on the vocabulary
● Process View: focuses on timing & control
● Implementation View: focuses on physical system
● Deployment View: focuses on geographic distribution.
References
1. Grady Booch, James Rumbaugh, Ivar Jacobson, The Unified Modeling
Language User Guide, Pearson Education
2. Michael Blaha, James Rumbaugh: Object-Oriented Modeling and
Design with UML, 2nd Edition, Pearson Education, 2005.
3. J. Rumbaugh, M. Blaha, W. Premerlani, F. Eddy, W. Lorensen, Object-
Oriented Modeling and Design, Prentice Hall of India

4. Satzinger, Jackson, Burd, Object-Oriented Analysis & Design with the


Unified Process, Thomson.

5. Grady Booch, Object Oriented Analysis & Design, Pearson Education

You might also like