Title: Programming
1Programming At Its Infancy
- A program is a single block of procedural code
- Disadvantages
- Reusability is practically nil.
- Programming Complexity is high.
- Software cannot not evolve gracefully as changes
in one part of the software can have unwanted
side-effects.
2Programming The Structured Approach
- Top-down design followed by bottom-up programming
- Top-down decomposition driven by functional
criteria - Architecture reflects system functions
3The Structured Approach Advantages
- Modularization implies
- Reduction in software complexity
- Increased reusability
- Reduction in unwanted side-effects as much of the
effect is confined to the module being changed.
4The Structured Approach Disadvantages
- Produces satisfactory results only when functions
have been identified properly and remain
unchanged through time. - Software structure is induced by functions. Thus
evolution of these functions may imply important
structural modifications. - Guarantees only limited modularizations thereby
rendering subsequent modifications difficult and
wrought with side-effects.
5Programming The Object Oriented Approach
- A paradigm shift from a function-centric approach
to an object-centric approach to software
development. - Structure induced by players (which constitute
the more static part of the system) rather than
by functions (the dynamic and evolving part of
the system). - Doesnt replace the structured approach builds
on top of it. - Further modularization achieved through the
decoupling of the system into independent objects.
6The Object Oriented Approach Advantages
- Models the real world more closely.
- Is easier to maintain because its structure is
inherently decoupled. - Leads to reuse which in turn leads to faster
software development and higher quality programs.
7What are objects anyway
- Objects in an object oriented system are models
or abstractions of the things that make up the
real-world system. - Objects may correspond to actual physical objects
such as car, table,employee, customer and so on. - Objects may also correspond to concepts such as a
bank account, insurance policy etc.
8Objects
- They have properties much like real world
objects. Eg. A car object may have properties
colour, make, price etc. - They exhibit behaviour much like physical
objects. Eg. A car object can move, accelerate.
9Object Defined
- An object is a complex data type that contains
- other data types, usually called properties,
attributes or variables, and - modules of code, usually called operations or
methods that manage these attributes.
10Abstraction
- Abstraction maps real-world objects to computer
models
Id No Make Model Colour Year of Manufacture
Employee Code Name Designation Basic Pay Division
11Encapsulation
Attributes
Operations
Quote Price
Customer
Price?
Price
Check Price
Salesperson
Product
12Encapsulation
- Encapsulation means objects dont know or care
how other objects store or process data. - The hiding of implementation details is referred
to as encapsulation.
13Encapsulation Advantages
- Leads to a higher level of modularization in the
sense that - each object is independent of every other object
and - the procedural code contained in each object is
modularized into several independent operations.
14- Data is encapsulated in objects
- Data protected against unexpected accesses thus
guaranteeing data integrity
15- Changes to internal data structures or
operations of an object affect only that object.
- Information hiding and reduced impact of side
effects associated with change
16- Methods or operations manipulate a limited no. of
attributes - They are cohesive
17- Communication occurs only through the methods
that comprise the wall - Object is decoupled from other elements of the
system
18- All the necessary data structures and functions
for a particular object are contained within the
object - Increased reusability
19- Encapsulation
- High-Quality Software
20Objects, Classes and Instances
- Can you build completely separate objects for
each variation of every object in our world? - No
21Objects, Classes and Instances
- Employees of an Organization
Employee Code Name Designation Basic Pay Division
395 Tom SSA 10,000 XYZ
Employee Code Name Designation Basic Pay Division
1360 Lara SA 7,000 ABC
Employee Code Name Designation Basic Pay Division
2375 Dick PSA 15,000 XYZ
22Objects, Classes and Instances
- A class is a generalized description (e.g. a
template, blueprint) that describes a collection
of similar objects.
Object Chair1
Class Chair
The object inherits all attributes operations
of the class
Cost Dimensions Weight Location Color
Cost Dimensions Weight Location Color
Buy Sell Weigh Move
Buy Sell Weigh Move
23Objects, Classes and Instances
- Each object belongs to a class.
- An object has values associated with its
attributes. - Software objects are built from the class via a
process referred to as instantiation. Any object
is an instance of a class. - At run time, a single class like employee can
have hundreds of objects in existence at the same
time.
24Object-oriented Decomposition
Attributes
Operations
Quote Price
Customer
Price?
Price
Check Price
Salesperson
Product
25Object Intercommunication
- Decomposition is not the end of the development
of an object oriented system it signals the
beginning. - The objects have to be tied together to allow an
applications functionality to be built .
26Object Intercommunication
- In an object-oriented system, teams of objects
operate in synergy to implement the functionality
of the application. At execution time, the
objects contribute as a whole to the proper
execution of the application. -
27Object Intercommunication
28What is a message?
- Messages are the means by which objects interact.
- Messages tie an object oriented system together.
- Message is a dynamic integrator that allows an
application to built through the collaboration of
a group of objects. - Message dynamically links the objects that were
separated by the decomposition process.
29Message Defined
- The unit of inter-object communication is called
message.
30Inheritance
- More General Abstractions
Vehicle
Is a
Is a
Land Vehicle
Air Vehicle
Is a
Is a
Is a
Is a
Car
Truck
Plane
Helicopter
31Class Inheritance Specialization
ClassA
Attribute A1
Operation A1
ClassB
Attribute A1 Attribute B1
Inheritance
Operation A1 Operation B1
ClassC
Attribute A1 Attribute B1 Attribute C1
Operation A1 Operation B1( B1 code
modified) Operation C1
Specialization
32Inheritance How to implement
- Generalization achieved through abstraction.
- Specialization achieved through extension.
- Generally implemented at the same time.
33Generalization Specialization
Vehicle
Generalization
Specialization
Land Vehicle
Air Vehicle
Car
Truck
Plane
Helicopter
34Inheritance Advantages
Inheritance
Better management of Complexity
Code Reuse
Faster Development simplified maintenance
35An example
Vehicle
Move
Land Vehicle
Air Vehicle
Move
Move
Plane
Car
Truck
Helicopter
Move
Move
Move
Move
36Polymorphism
- The ability to trigger different operations in
response to the same message is called
polymorphism. - This means that the same message can behave in
different ways depending on what object it is
sent to.
37Polymorphism
- Polymorphism is achieved by writing code , not in
terms of the sub-classes, but in terms of the
super class. - The benefits of polymorphism are mainly obtained
during maintenance.
38The Software Problem
- Growing demand for sophisticated software
- Growing software complexity
39What is UML?
- UML stands for Unified Modeling Language
- UML is a universl language for object-oriented
modeling - UML is the standard language for visualizing,
specifying, constructing and documenting the
artifacts of a software system - Maps real-world processes of a computer system
with a graphical representation or blue print.
40Benefits of UML
- Helps capture business processes
- Enhances communications
- Manages complexity
- Defines architecture
- Enables reuse
41UML Diagrams
- Five different groups of UML diagrams offer five
different ways of looking at the same problem - Use Case Diagrams
- Use Case Diagrams
- Use Case Descriptions
- Static Structure Diagrams
- Class Diagrams
- Object Diagrams
42UML Diagrams
- Interaction Diagrams
- Sequence Diagrams
- Collaboration Diagrams
- State Diagrams
- State Diagrams
- Activity Diagrams
- Implemetation Diagrams
- Component Diagrams
- Deployment Diagrams
43The UML Use Case Diagrams
- Represent the functions of a system from a users
point of view. - They allow the definition of the systems
boundary and the relationships between the system
and the environment.
44The UML Static Structure Diagrams
- The class diagram shows the classes that will be
included in your application and the
relationships between classes. - Object diagrams are used to explore specific
problems with specific classes.
45The UML Interaction Diagrams
- Sequence Diagrams show the flow of messages
(events) between objects in a temporal context. - Collaboration Diagrams are a combination of
object and sequence diagrams. They show the flow
of events between objects.
46The UML State Diagrams
- A state diagram shows all of the values (states)
that the attribute of an object can take as
messages (events) are processed. State diagrams
are only prepared for classes whose instances are
very dynamic. - An activity diagram represents the internal
behaviour of a method or a use case as a sequence
of steps.
47The Solution
- Software engineers must know
- How to do their job
- How to explain their work to others and
- How to understandothers work, when it is
explained to them
48The UML Implementation Diagrams
- Implementation diagrams show design and
architectural decisions. - Component Diagrams describe software components
and their relationships within the implementation
environment they indicate the choices made at
implementation time.
49The UML Implementation Diagrams
- Deployment Diagrams show the physical layout of
the various hardware component (nodes) that
compose a system, as well as the distribution of
executable programs (components) on this
hardware. Placing component diagrams on top of
deployment diagrams indicate which modules of
code will go on which hardware platforms.