0% found this document useful (0 votes)
2 views11 pages

Module 02

This document covers Object Oriented Analysis and Design, focusing on the concepts of objects and classes. It includes an analogy of building a car to explain the process of identifying user needs, assessing requirements, and refining designs. Key terminology, class creation, instance objects, built-in attributes, and inheritance are also discussed, along with the importance of data hiding.

Uploaded by

kalamkumar22
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)
2 views11 pages

Module 02

This document covers Object Oriented Analysis and Design, focusing on the concepts of objects and classes. It includes an analogy of building a car to explain the process of identifying user needs, assessing requirements, and refining designs. Key terminology, class creation, instance objects, built-in attributes, and inheritance are also discussed, along with the importance of data hiding.

Uploaded by

kalamkumar22
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

Object Oriented Analysis and Design

module 02
Dr Abu-Eesa
Islamic Online University
back2basics

 Previous module
 Object
 Concept of a class

 This module (module02)


 Back to basics
 notion of objects and classes
Analogy: building a new car

 Identify activities
 User community and needs  form team
 Requirements assessed  expand team to include automobile engineers &
other experts
 Refine initial design  prototypes etc.

 Some months later…..


 Build a plant for production & hire people!
Overview of OO terminology

 Class
 Class variable
 Data member
 Function overloading
 Instance variable
 Inheritance
 Instance
 Instantiation
 Method
 Object
 Operator overloading
Creating Classes

 ClassName.__doc__
 demo(python example)
 empCount – class variable
 __init__() – special method
Instance Objects

 Creating instance: Call class using the class name and input any arguments its
__init__ method will accept
 Access attributes: use dot operator with object
 Use following functions instead of using normal statements to access attributes
 The getattr(obj, name[, default]) : for accessing attribute of object.
 The hasattr(obj,name) : for checking if an attribute exists or not.
 The setattr(obj,name,value) : for setting an attribute. If attribute does not exist, then
it would be created.
 The delattr(obj, name) : for deleting an attribute.
Built-In Attributes

 __dict__: Dictionary containing the class's namespace.


 __doc__: Class documentation string or none, if undefined.
 __name__: Class name.
 __module__: Module name in which the class is defined. This attribute is
"__main__" in interactive mode.
 __bases__: A possibly empty tuple containing the base classes, in the
order of their occurrence in the base class list.
Class: Vehicle
Vehicle

-Moves
-has operator

Car Truck Aeroplane

-Windows -windows -wings


-Doors -doors
-wheels
Inheritance

 Saves us starting from scratch


 Derive from pre-existing class
 Also inherits parents attributes
 Child can override parent data members and methods

 Use issubclass(sub, sup)


 isinstance(obj, Class)
examples

 Some examples from tutorialspoint to illustrate


Data Hiding

 Visibility to outsiders

You might also like