2. Software Complexity
• Why software is inherently complex ?
– The complexity of problem domain
• “Impedance mismatch” between users and developers: each
group lacks of expertise in the domain of the other
• Software requirements often change during development
– The difficulty of managing the development process
• Software engineers have to “engineer the illusion of
simplicity”
– Flexibility through software
• Software is a reflection of a mental product, it allows any kind
of abstraction imaginable by its creator
4. Attacking Complexity
• “Divide et impera” principle → decomposition
– Breaking a complex problem into smaller and manageable parts
– The size of a subpart must not exceed the capacity of human
cognition
• Algorithmic decomposition
– Decomposition is based on process
• A module denotes an activity
• Smaller parts compose a larger process
• Object-oriented decomposition
– Decomposition is based on key abstractions in the problem
domain
– The world is viewed as a set of autonomous agents that
collaborate to perform some higher level behaviour
7. The Object Model
• Characteristics of object-orientation
– Abstraction
– Encapsulation
– Modularity
– Hierarchy
8. The Object Model
• Abstraction
– Denotes the essential characteristics of an object that distinguish
it from all other kinds of objects
– Provides crisp definition of conceptual boundaries, relative to the
perspective of the viewer
– Focuses on the outside view of an object, separating its
essential behaviour from its implementation
– The most important issue in design is to decide upon the right
set of abstractions for a given problem domain
10. The Object Model
• Encapsulation
– The process of hiding all details of an object that do not
contribute to its essential characteristics
– Abstraction and encapsulation are complementary
• Abstraction focuses on the outside view
• Encapsulation prevents clients from seeing its inside view
where the behaviour of the abstraction is implemented
– Encapsulation provides explicit barriers among different
abstractions → limiting the size of cognitive entities
12. The Object Model
• Modularity
– Modularity packages abstractions into discrete units
– Modularity is the property of a system that has been
decomposed into a set of cohesive and loosely coupled modules
• How modules are defined, i.e., how a system is partitioned
• How a module sees another module
– In design, we strive for high cohesive modules and low coupling
between modules
14. The Object Model
• Hierarchy
– Hierarchy is a ranking or ordering of abstractions
– Two important hierarchies: the “kind-of” (class hierarchy) and
“part-of” (object hierarchy) relationships
16. Objects
• The nature of an object
– A tangible and/or visible thing, or may be
perceived intellectually
– Has three essential properties
• State
• Behaviour
• Identity
18. Object State
• The state of an object encompasses:
– The (static) properties of the object
– Current (dynamic) values of each of these properties
• A property is an inherent or distinctive characteristics or feature that
contributes to making an object unique
• A value could be simple or denote another object
– Simple values are non-temporal, unchangeable, and non-
instantiated
– Object values exist in time, are changeable, instantiated, and
can be created, destroyed, and shared
19. Object State
• Example of object stateclass Circle {
int radius;
Color color;
Circle(int r, Color c) {
radius = r; color = c;
}
public setRadius(int r) {
radius = r;
}
public setColor(Color c) {
color = c;
}
}
Circle circle = new(10,blue);
circle.setColor(red);
20. Object Behaviour
• No objects live in isolation
– Objects are acted upon, and they act upon other objects
• Behaviour is how an object acts and reacts, in terms of state
changes and message passing
– Behaviour of an object is completely defined by its actions
– At the programming level, behaviour is implemen-ted by
methods or member functions
21. Object Behaviour
• Different kinds of operations
– Modifier: alters the state of an object
– Selector: accesses, but does not alter, the state of an
object
– Iterator: permits all parts of an object to be accessed
in a well-defined order
– Constructor: creates an object and initializes its state
– Destructor: frees the state of an object and destroys
the object
23. Object Identity
• Identity is a property of an object which distinguishes it from all other
objects
• It denotes a reference associated with the object it identifies
– Identity is a property that shows that an object “exists”
• in real world (as an abstraction)
• in memory (computer representation)
– An identity exists as long as the object it represents exists
• Object creation always creates an identity
• Object deletion destroys its identity
24. Object Identity
class Circle {
int radius;
Color color;
Circle(int r, Color c) {
radius = r; color = c;
}
public setRadius(int r) {
radius = r;
}
public setColor(Color c) {
color = c;
}
}
Circle circle1 = new(15,green);
Circle circle2 = new(10,red);
Circle circle3 = new(5,blue);
circle3
circle2
circle1
25. Relationships Among Objects
• Types of relationships
– “Using” relationship
– “Containing” relationship
• “Using” relationship
– Two objects have equal position in a hierarchy
– Unidirectional message passing
– Each object may play one of the following roles
• Actor: an object that can access other objects, but cannot be
accessed by other objects
• Server: an object that can only be accessed by other objects
• Agent: an object that can both access or be accessed by
other objects
– Example: see the Sensor and Tank object