0% found this document useful (0 votes)
35 views4 pages

Software Engineering 4

The document discusses object-oriented design and its advantages over classical software engineering approaches. It introduces key concepts of object-oriented programming including encapsulation, classes, inheritance and multiple inheritance. Real-world examples are provided to illustrate these concepts.

Uploaded by

Mandy Lores
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views4 pages

Software Engineering 4

The document discusses object-oriented design and its advantages over classical software engineering approaches. It introduces key concepts of object-oriented programming including encapsulation, classes, inheritance and multiple inheritance. Real-world examples are provided to illustrate these concepts.

Uploaded by

Mandy Lores
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Overview

 Classical Software Engineering


– Stepwise Refinement
Software Engineering – Problems with Classical Approach
 Basic Features of Object-Orientation
– Encapsulation
Lecture 4
 Objects
So what does Object-Oriented mean anyway?
 Classes
A Basic Object Oriented Model – Inheritance
 Multiple Inheritance

Example Stepwise Refinement:


Classical Software Engineering Making a cup of Instant Coffee
1. Boil Water 1.1 Fill Kettle 1.1.1 Put kettle under tap
 Programming Language Evolution led to larger and 1.1.2 Turn on tap
more complex programs incomprehensible to humans 1.1.3 Wait until kettle is full
1.1.4 Turn off tap
 Methodology required to build such programs
1.2 Switch on Kettle
 In the 1960s and 70s, a methodology called Structured 1.3 Wait until boiling
Programming became established 1.4 Switch off kettle
– essentially divide and conquer 2. Put Coffee in Cup 2.1 Open coffee jar 2.1.1 find coffee jar
2.1.2 remove lid from jar
– write high level algorithm for problem
2.2 Extract spoonful of
– divide algorithm into a series of significant sub-algorithms coffee
each forming a program module 2.3 Tip spoonful into cup
– repeat process on sub-algorithms until they become small 2.4 Close coffee jar 2.4.1 put lid on coffee jar
enough to be expressed as program code (Stepwise 2.4.2 replace jar on shelf
Refinement) 3. Add water to Cup
Problems with Classical Approach Real World Analogy
 Software Life-Cycle Models (Waterfall) evolved to  In everyday life, simplifications of the world are made
allow Structured programs to be written by naming various Entities
 Initially very promising results were achieved – Examples: John, Room G1A, Canterbury
 However:-  These entities possess properties
– as software began to exceed ~50 000 lines of code, the – Name, Building, Location
paradigm began to break down since it is either action or  Everyday tasks involve interaction with these entities
data oriented but not both
 In practice, only properties relevant to these tasks
– also as Maintenance was required to adapt the software to
changing requirements, the module structure began to
are considered significant
break down making subsequent maintenance more and  Use same idea as a model for Software Construction
more difficult – call the entities Objects

Object Orientation Encapsulation: Objects


 Treat components of the system as Student A Lecturer B Six example
abstract objects with relevant properties / Objects from the
attributes Administration
Course C System
 E.g. University Administration system Student D
Lecture
– Object : Student:
 Properties needed: Name, id no, course etc. Lecture Theatre

 Not needed: Height, hair colour etc


 An Object Encapsulates properties related •Objects have their own properties: A lecture has a title, theme, Slide
running order
to an entity in the system
•Objects have relations to each other: A given lecture involves many objects
Classes Class Definition
 Many Objects share common properties  Classes have a number of attributes
– e.g.Student may have name, Id, grade
Student A Student B
achieved

 Group together such objects to form a class  Also have Operations


– e.g. Student, Lecturer, Course – e.g. enrol for course, calculate marks

 Identifying Classes major part of design Student


process Name:String
StudentId:Integer
– e.g. Dependent on system requirements, EnrolForCourse()
Lecture Theatre may or may not be a Class CalculateResults()

Definitions Inheritance
 Message: Information sent to an object  Classes often extend the definition of other
requesting an operation to be performed Classes
 Attribute: Property of an object often
Person
expressed as a variable
 Operation: A Function which an object
may perform Student Lecturer
 Method: An implementation of an
operation (Method is wholly encapsulated  Student has all the attributes of a person
within the class) (e.g. name) plus specific attributes
(e.g.Student ID)
Multiple Inheritance
Example Inheritance
GeomFigure Animal
General properties part of
X-Coord:Integer
Y-Coord:Integer superclass Phylogenetic Phylogenetic
Display() Specific properties part of
Remove()
subclass Mammal Terrestrial Habitat Fish

Circle Rectangle Triangle Pig Aquatic


SideA:Integer
Radius:Float Length:Integer
SideB:Integer
Width:Integer
SideC:Integer

SetRadius(R) SetSides(Length, Width) SetSides(A,B,C)


Dolphin Trout

Summary

 Object Oriented Design is an attempt


to overcome the problems of Software
Engineering
 Three Main Concepts
– Encapsulation
– Inheritance
– ( + Polymorphism to be covered soon!)

You might also like