Itsc 2132 Object Oriented Programing: Lecture One
Itsc 2132 Object Oriented Programing: Lecture One
INTRODUCTION
LECTURE ONE
OUTLINE
• A vague understanding of the problem is transformed into a precise description of the tasks that a
software system need to carry out
• Result : - functional specification that have the following characteristics :
• It completely defines that tasks to be performed
• Free from internal contradiction
• Readable by both expert in the problem domain and developer
• Reviewable by diverse interested parties
• Can be tested against reality
• The analysis phase concern itself with description of what need to be done ,not how
• Common method used : textual description and use case [behavior of the system]
THE DESIGN PHASE
Scenario 1
• Assume you undertake the following activities on a daily basis. Arrange this list into a sensible order then split this list into
three blocks of related activities and give each block a heading to summaries the activities carried out in that block.
Get out of bed
Eat breakfast
Park the car
Get dressed
Get the car out of the garage
Drive to work
Find out what your boss wants you to do today
Feedback to the boss on today’s results
Do what the boss wants you to do
STRUCTURAL PARADIGM( CONTINUED …)
• You should have been able to organize these into groups of related activities and give
each group a title that summarizes those activities.
Get up :- Get out of bed, Get dressed, Eat breakfast
Go to Work :- Get the car out of the garage, Drive to work ,Park the car
Do your job :- Find out what your boss wants you to do today ,Do what the boss
wants you to do ,Feedback to the boss on today’s results.
STRUCTURAL PARADIGM( CONTINUED …)
• We can change and improve one section of the instructions without changing the other parts.
For example we could improve the instructions for going to work….
• Listen to the local traffic and weather report, Decide whether to go by bus or by car, If
going by car, get the car and drive to work. Else walk to the bus station and catch the bus
• We can do this without worrying about any potential impact this may have on ‘getting up’ or
‘doing your job’.
• In the same way structuring computer programs can make each part more understandable
and make large programs easier to maintain.
OBJECT ORIENTED PARADIGM
• With an address book we would want to be able to perform the following actions :- find out details of a
friend i.e. their telephone number, add an address to the address book and, of course, delete an address.
• We can create a simple software component to store the data in the address book (i.e. list of names etc)
and the operations we can perform (i.e add address, find telephone number etc).
• By creating a simple software component to store and manage addresses of friends we can reuse this in
another software system i.e. it could be used by a business manager to store and find details of
customers. It could also become part of a library system to be used by a librarian to store and retrieve
details of the users of the library.
• Thus in object oriented programming we can create re-usable software components (in this case an
address book).
WHY WE USE THE OBJECT ORIENTATION
PARADIGM?
• The major problem of software arises due to :
Poor analysis and design: the computer system we create doesn’t do the right thing.
Poor maintainability: the system is hard to understand and revise when, as is
inevitable, requests for change arise.
• Before you write the software you must first develop a model of what that software must be
able to do and how it should work.
• Object oriented modelling is based on the ideas of abstraction, encapsulation, inheritance and
polymorphism
• The general proponents of the object oriented approach claims that this model provides:
Better representation of real world(Founded on the concept of object and class)
Better abstractions (modelling information and behavior together)
Better maintainability (more comprehensible, less fragile)
Better reusability (classes as encapsulated components)
THE OBJECT AND CLASS CONCEPT
Scenario 3
• Think of an object you possess. Describe its current state and list two or three things you can do with that
object.
Feedback
• You probably thought about an entirely physical object such as a watch, a pen, or a car.
• Objects have a current status. A watch has a time (represented internally by wheels and cogs or in an
electronic component). A pen has a certain amount of ink in it and has its lid on or off. A car has a current
speed and has a certain amount of fuel inside it.
• Specific behavior can also be associated with each object (things that you can do with it) :- a watch can be
checked to find out its time, its time can also be set. A pen can be used to write with and a car can be driven.
THE OBJECT AND CLASS CONCEPT(CONTINUED…)
• Deciding just what classes we should create in our system is not a trivial task as the real
world is complex and messy
• In essence we need to create an abstract model of the real world that focuses on the
essential aspects of a problem and ignores irrelevant complexities
• E.g. in the real world bank account holders sometimes need to borrow money and
occasionally their money may get stolen by a pick pocket. If we were to create a bank account
system
• should we allow customers to borrow money?
• Should we acknowledge that their cash may get stolen and build in some method of them
getting an immediate loan
• Is this an irrelevant detail that would just add complexity to the system and provide no real
benefit to the bank?
FINAL THOUGHTS ON OOP( CONTINUED …)
• Using object oriented analysis and design techniques our job would be
• Look at the real world
• Come up with a simplified abstract model that we could turn into a computer system
• How good our final system is will depend upon how good our software model is
EXERCISE
1. Consider a computer system that will allow items to be reserved from a library.
Imagine one such item that you may like to reserve and list two or three things that a
librarian may want to know about this item.
2. Note that we can consider a reservation to be is an intellectual object (where the
actual item is a physical object). Considering this intellectual object (item reservation)
list two or three actions the librarian may need to perform on this object
3. Considering the most general category of object that can be borrowed from a library, a
‘loan item’, list two or three more specific subcategory of object a library can lend out
ASSIGNMENT ONE
• Give example programing languages that are under their category [sample code if possible]
• What sort of difference and similarity each have