1/33
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Objects in Software
They are the main building blocks in OOD. In programming, they make up the structure of software.
Object Interactions
They can communicate with each other by sending and receiving messages. When an object receives a message, it can respond with a result
Hidden Structures of Objects
When you use an object, you don’t need to know how it works on the inside. Its internal structure is hidden, which makes it easier to work with.
Main Purpose of Programs
This is to process data. They exist to take in info, work on it, and produce useful results.
Task of OOD
It is to split a system’s data and behaviour into a set of interacting objects. This makes the program easier to manage and understand.
OOD View of Programs
It represents a program as a collection of objects that interact with each other. Each object manages its own part of the work but connects with other objects to complete the system.
Role of Objects in Applications
They define what the program does. They are not just storage units but active parts that shape how the application works.
Object Roles
Data Provider
Service Provider
Controller
Constructor
Coordinator
An object may play one role, or it may take on serveral roles at the same time, depending on what the program needs.
Object Roles: Data Provider
It collects, stores and provides data for use in the program.
Object Role: Service Provider
An object offers services and performs computing tasks for the program.
Object Role: Controller
An object makes decisions about how the program should respond or behave
Object Role: Constructor
An object generates other objects and maintains the relationships between them.
Object Role: Coordinator
An object analyses events and delegates tasks to other objects.
Internal Structure of Objects
Each object contains data and methods to process that data. To interact with other objects, an object also includes interface methods. Interaction between objects is only possible through these interface methods.
Physical Form of an Object
An object is made up of binary data and microprocessor instructions. These occupy a reserved block of memory, but the actual layout is system-dependent.
Links between Objects
These can be created at compilation time, when the program is built, or dynamically at run time, while the program is running.
Logical Form of an Object
An object must be declared in your program through classes. When it is declared, it is given a unique name, which allows you to identify it and follow the relationships between all objects in the program.
Object-Oriented Analysis
Looking at a problem, system or task and identifying the objects and interactions between those objects.
Object-Oriented Design
Converting requirements into an implementation specification. Name the objects, define the behaviours, and specify object interaction
Object-Oriented Programming
Converting the design into a working program that does exactly what the customer wants
Object Identity
This means each object must have a unique identifier. This unique name allows the object to be recognised and ensures correct interaction with other objects. This can be specified by a programmer or assigned by another object acting as a constructor.
Object State
This refers to the actual values stored in it, which reflect the properties or attributes of the object. For example, a circle circle object might store values for its coordinates, radius and constant values like pi. Objects from the same class share attributes but may have different states.
Object Behaviour
This is what the object can do, defined by its supported actions called methods. These methods determine how an object acts and reacts to its role.
Object Mutator Methods
They can change the object’s state.
Object Accessor Methods
They only access values without changing them.
Meaning of ‘self‘ parameter in Python
This is a specific reference to the object that is calling the method. It makes sure the method knows which object it is working with.
Why ‘self‘ is needed in object methods
Object methods must contain an argument that refers to the objcet calling the method. It connects the method to the exact object that is using it.
‘self‘ and other functions
A normal function or a class method does not have the ‘self‘ argument. Only object methods require it, because they need to know which object is calling them.
Calling methods with and without ‘self‘
If you call a method using the object directly, Python assigns the object to the ‘self‘ argument automatically. But if you call it by class name without passing the object, Python will give an error because there is no value for ‘self‘.
Instance (Object) Variables
These variables are for data that is unique to each object. They are not shared with other objects. They are defined inside methods with the prefix ‘self‘. They are accessed using self.object-variable inside the class
Class (Static) Variables
These variables are for data that is shared by all objects of the same class. THey are defined outside methods but still inside the class. They are accessed using object.class-variable or class-name.class-variable.
Class Method
This is created using the @ decorator. Unlike an object method, it works with class variables instead of instance variables. To call one, you use the class name or the object name.
Difference Between Object and Class Methods
Python automatically passes the object name as the first argument for the object methods. For class methods, Python automatically passed the class name as the first argument.
Static Method
This is created using the @ decorator. It does not receive an object or a class automatically when called. To call one, you can use either use the class name or the object name. In both cases, no object or class reference is passed to it.