Top Banner
Programming Using C++ / Introduction to Programming with C++ ICT 120 / CSD 106
21
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 1 oop

Programming Using C++ / Introduction to Programming with C++

ICT 120 / CSD 106

Page 2: Lecture 1 oop

Introduction to Object-Oriented Analysis and Design (OOAD)

• What is OOA?– It is a method of analysis that examines

requirements from the perspective of the classes and objects found in the vocabulary of the problem domain

– The chief OOA activity is discovering and documenting the key classes for a particular problem domain

Page 3: Lecture 1 oop

Introduction to Object-Oriented Analysis and Design (OOAD)

• What is OOAD?– It is the generic term for the process of analyzing a

problem and developing an approach for solving it.– Essential for large programs– Plan in pseudocode or Unified Modeling Language

(UML)• UML is widely used

Page 4: Lecture 1 oop

Introduction to Object-Oriented Analysis and Design (OOAD)

• What is OOD?– It is a method of design encompassing the process

of object-oriented decomposition and a notation for depicting both logical and physical as well as static and dynamic models of the system under design.

– OOD • Models real-world objects in software• Models communication among objects• Encapsulates attributes and operations (behaviors)

– Information hiding» Communication through well-defined interfaces

Page 5: Lecture 1 oop

Introduction to Object-Oriented Analysis and Design (OOAD)

• UML– Graphical representation scheme– Enables developers to model object-oriented systems– Flexible and extensible (capable of being enhanced with

new features)

• Some UML Features– Use Case Diagrams– Class Diagrams– Sequence Diagrams– Collaboration Diagrams– Activity Diagrams

Page 6: Lecture 1 oop

Overview of Object-Oriented Programming

• Object Oriented Programming (OOP)– A method of implementation in which programs

are organized as cooperative collections of objects, each of which represents an instance of some class, and whose classes are all members of a hierarchy of classes united via inheritance relationships.

– OOP is centered around the object– Classes are generally viewed as static, whereas

objects typically have a much more dynamic nature.

Page 7: Lecture 1 oop

Overview of Object-Oriented Programming

• Object Oriented Programming (OOP)– Conceptual Framework • Object model

– Abstraction– Encapsulation– Modularity– Hierarchy

Page 8: Lecture 1 oop

Overview of Object-Oriented Programming

• Conceptual Framework – Object model• Abstraction

Page 9: Lecture 1 oop

Overview of Object-Oriented Programming

• Conceptual Framework – Object model• Abstraction

– An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of objects and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer

– Abstraction pays attention to important properties while ignoring details

Page 10: Lecture 1 oop

Overview of Object-Oriented Programming

• Conceptual Framework – Object model• Encapsulation:

Page 11: Lecture 1 oop

Overview of Object-Oriented Programming

• Conceptual Framework – Object model

Page 12: Lecture 1 oop

Overview of Object-Oriented Programming

• Conceptual Framework – Object model• Modularity: is the process of dividing a program into

modules which can be compiled separately, but which have connections with other modules.

Page 13: Lecture 1 oop

Overview of Object-Oriented Programming

• Conceptual Framework – Object model• Hierarchy:

– Classes of objects are arranged into hierarchies that model and describe relationships among the classes.

– The most important hierarchies in a complex system are:» Class structure “is a ” hierarchy» Object structure “part of ” hierarchy

– Examples:» Inheritance: “is a”

• generalization/specialization » Aggregation/Composition: “part of”

Page 14: Lecture 1 oop

Overview of Object-Oriented Programming

• Basic principles behind using OOP techniques involve:– Classes– Objects– Inheritance– Polymorphism

Page 15: Lecture 1 oop

Overview of Object-Oriented Programming

• Basic principles behind using OOP techniques involve:– Class• A class is a set of objects that share a common attributes

and a common behaviour.• A class consists of a category of things.• A class definition describes all the attributes of member

objects of that class as well as the methods that implement the behavior of member objects

– Example• Class Student

– This represents the characteristics common to all students

Page 16: Lecture 1 oop

Overview of Object-Oriented Programming

• Basic principles behind using OOP techniques involve:– Object• Object is any thing. It is a specific item that belongs to a

class. It is called an instance of a class• Object is an entity that has attributes, behaviour and

identity• The attributes and behaviour of an object are defined by

the class definition.

Page 17: Lecture 1 oop

Overview of Object-Oriented Programming

Example of Class vs Object

Page 18: Lecture 1 oop

Overview of Object-Oriented Programming

• Basic principles behind using OOP techniques involve:– Inheritance• A form of software reuse in which the programmer

creates a class that absorbs an existing class’s data and behaviours and enhances them with new capabilities• Base class

– Existing class• Derived class

– New class

Page 19: Lecture 1 oop

Overview of Object-Oriented Programming

– Inheritance: Example

Student

GraduateStudent UndergraduateStudent

Base Class

Derived Class

Page 20: Lecture 1 oop

Overview of Object-Oriented Programming

– Polymorphism

Page 21: Lecture 1 oop

Overview of Object-Oriented Programming

– Polymorphism• A concept in type theory, according to which a name

may denote objects of many different classes that are related by some common superclass; thus, any object denoted by this name is able to respond to some common set of operations in different ways.• It is feature that allows the same operation to be carried

out differently depending on the object.• It allows you to create new objects that perform the

same functions as the base object but which perform one or more of these functions in a different way.