Software Construction: Software Complexity Why Object Oriented? Object Oriented Methodology
Software Construction: Software Complexity Why Object Oriented? Object Oriented Methodology
Lecture 2
Software Complexity
Why Object Oriented?
Object Oriented Methodology
1
Software Engineering: Definition
Software Engineering is a collection of techniques,
methodologies and tools that help
with the production of
Source: http://en.wikipedia.org/wiki/Source_lines_of_code
How Big is a Million Lines of Code?
• For 50,000,000 (50 Millions) lines of code
• If you were to try to count that high, and could actually say the
names of the numbers between one and fifty million at a steady
rate of one per second
• It would take you more than 1.5 years to count that high without
pausing to eat, drink, sleep, or even draw a very deep breath
6
source: http://www.informationisbeautiful.net/visualizations/million-lines-of-code/
The inherent complexity of
software
• It is extremely difficult for the individual developer to
comprehend all the details of its design
• The complexity of such systems exceeds the human
intellectual capacity
• This complexity seems to be an essential property of all
large software systems
• Essential means that we may master this complexity, but we
can never make it go away
7
Why Software Is Inherently Complex?
• Brooks suggests
“The complexity of software is an essential property, not an
accidental one” [Brooks. No Silver Bullet]
8
Elements of the inherent
complexity
• The complexity of the problem domain
• Requirements for the electronic system of a multiengine aircraft, or an
autonomous robot
• Effects of nonfunctional requirements
• Communication gap between the users and developers
• Change requirements during development
• Systems tend to evolve over time - software maintenance
• maintenance - when we correct errors
• evolution when we respond to changing requirements
• preservation when we continue to use extraordinary means to
keep an ancient and decaying piece of software in operation.
9
Elements of the inherent
complexity
• The difficulty of managing the development process
• Software development cannot be managed as a set of steps in linear fashion
• Requirements Specification, followed by System Design followed by Implementation
followed by Testing and Delivery
• Software Development is highly nonlinear
• The flexibility possible through software
• It is possible for a developer to express almost any kind of abstraction
• It forces the developer to craft virtually all the primitive building blocks on
which these higher-level abstractions stand
• The problems of characterizing the behavior of discrete systems
• Within a large application, there may be hundreds or even thousands of
variables/states 10
Four Design Principles
These principles help to deal with complexity and
create better object oriented models
1.Abstraction
2.Encapsulation
3.Decomposition
4.Generalization
11
1. Abstraction
• Inherent human limitation to deal with complexity
• The 7 +- 2 phenomena
12
1. Abstraction
• The essential characteristics of an abstraction can be
understood in two ways:
(1) through basic attributes and (2) through basic behaviors
or responsibilities.
• Basic attributes are characteristics that do not disappear over
time. Although their values may change, the attributes
themselves do not.
• Example
• The concept of a lion may have an age attribute. value of age
may change, but the lion always has an age attribute.
• A lion may have behaviors such as hunting, eating, and
sleeping. These are also responsibilities that the lion 13
abstraction does for its purpose of living
2. Encapsulation
• This principle involves a concept that allows something to be
contained in a capsule, some of which you can access from the
outside and some of which you cannot.
• There are three ideas behind encapsulation.
1.The ability to “bundle” attribute values (or data) and behaviors
(or functions) that manipulate those values, into a self-
contained object.
2.The ability to “expose” certain data and functions of that
object, which can be accessed from other objects.
3.The ability to “restrict” access to certain data and functions to
only within the object.
14
3. Decomposition
• It consists of taking a whole thing, and dividing it into different parts.
Red White
17
4. Generalization
• Generalization helps reduce redundancy when solving problems.
• In coding, algorithmic behaviors are often modelled as methods.
• A method allows a programmer to generalize a behavior, so the
behavior can be applied to different input data.
• This generality reduces the need to have identical code throughout a
program.
• In object-oriented modelling, generalization is a main design principle,
but beyond creating a method that can be applied to different data,
object-oriented modelling achieves generalization by classes through
inheritance.
• In generalization we take repeated, common, or shared characteristics
between two or more classes and factor them out into another class.
18
4. Generalization
• It is achieved through inheritance
• Two kinds of classes: a parent class, and a child class.
• Parent classes capture general ideas and generally have broader
application.
• Repeated, common, or shared characteristics
• Child classes inherit attributes and behaviors of parent classes.
• It is possible for multiple child classes to inherit from a single parent
class.
• Multiple child classes will all receive these common attributes and
behaviors, child class can have additional attributes and behaviors
that allow them to be more specialized in what they can do.
• Parent class - superclass and child class - subclass.
• Inheritance allows a superclass to form a generalization and for its
19
subclasses to be more specialized
Generalization Example
• Concepts: Cat & Dog
20
What is a Model?
• A hypothetical representation/description of a complex
entity or process (Abstraction of reality)
• A description of static and/or dynamic characteristics of a
subject area
• Model organizes & communicates the important details of
the real world problem & system to build
• Visualized with views – visual projections of model (e.g.
UML diagrams)
21
Models are used to provide
abstractions
• Object Model: What is the structure of the system? What are the
objects and how are they related? (static model)
class... Reverse
class... Code Engineering
Functional class...
Model 22
Dynamic Model
Why Do We Model?
• To deal with complexity
• Recall Windows example
• This amount of code is not easily understandable by developers
• Need simpler representations for complex systems
• To understand why a software system is needed, what it should do, and
how it should do it
• To communicate our understanding of why, what and how
• To detect commonalities and differences in the perceptions of various
parties involved
• To detect misunderstandings and miscommunications
23
Why Object-Oriented?
• Provides two strong weapons to deal with complexity
24
Why Object-Oriented?
Programming Paradigms
Imperative Procedures & Algorithms
Function-oriented Mathematical functions
Logic-oriented Goals, Predicate logic
Object-oriented Classes & Objects
25
Object Oriented Analysis & Design (OOAD)
27
Software Lifecycle Activities
...and their models
Implemented
Expressed in By
Structured By Realized By
Terms Of Verified
By
class...
class...
class... ?
class.... ?
Use Case Application Solution
Domain Subsystems Source Test
Model Domain
Objects Code Cases 28
Objects
Various Concepts
29
Application and Solution Domain
• Application Domain (Requirements Analysis)
• The environment in which the system is operating
30
Some benefits of object oriented methodology
• Reusability
– classes can be reused or inherited
• Stability
– over time, classes become more stable
• Easier Design
– black box concept
• Faster Design
– create applications from existing components
31
Questions???
32