4. Object Model Flashcards
(34 cards)
What is Object-Oriented Programming (OOP)?
OOP is a programming paradigm based on “objects,” which contain data (attributes or properties) and code (methods or functions). Objects are instances of classes, which determine their types.
What is Object-Oriented Design (OOD)?
OOD is the process of using objects and object-oriented programming principles when designing a software solution.
When one object calls a method of another, what are some key considerations for the calling object?
The calling object (client) must adhere to rules about calling the method (e.g., number of inputs, data types), and these rules are defined by the object being called (server). The server object might also keep its internal workings secret (information hiding).
What defines the acceptable calls an object can receive?
Acceptable calls are defined by the object’s methods (also known as operations, procedures, subroutines, or functions), each of which has a specific signature (name, parameters, types, etc.).
What is an object’s “interface”?
An object’s interface is the set of method signatures for that object. It defines the “services” the server object will offer.
What is “Information Hiding” in the context of OOD?
An object can hide its state (attributes) and restrict access to it, allowing interaction only through its public interface.
In object interaction, which object is the “client” and which is the “server”?
The object calling a method is the client object, and the object receiving and executing the call is the server object. The method call is the message.
What is modular programming?
Modular programming is a software design technique that emphasizes separating the functionality of a program into independent, interchangeable modules (packages).
How do objects differ from modules in terms of data handling?
Modules are often loose groupings where “promiscuous” access to data can lead to misuse. Objects, in contrast, encapsulate data, meaning internal data is typically hidden and accessed via methods.
What is UML?
UML, or Unified Modeling Language, is a standardized visual language used in software engineering to represent different aspects of a system’s structure and behavior.
Name three types of diagrams in UML.
Examples include Class Diagrams, Use Case Diagrams, Sequence Diagrams, Activity Diagrams, State Machine Diagrams, Component Diagrams, Deployment Diagrams, and Package Diagrams.
What are the three compartments typically found in a UML class notation?
- Class Name,
- Attributes,
- Operations.
In UML, what does a “+” symbol before an attribute or operation signify?
It signifies public visibility.
In UML class diagrams, what does a “-“ symbol typically signify when placed before an attribute or operation name?
In UML class diagrams, a “-“ symbol before an attribute or operation name typically signifies that the member has private visibility.
What is an “Association” in UML object relationships?
Association represents a relationship where one object accesses another in some way (e.g., calling a method, accessing an attribute). It can be bidirectional, unidirectional, or prohibited.
What is “Inheritance” (or Generalization) in UML?
Inheritance is when an object (subclass) inherits the properties (attributes and methods) of another object (superclass), representing an “is a” relationship.
What is “Composition” in UML, and what kind of relationship does it represent?
Composition is a strong “has a” relationship where an object references another object as an instance variable, and the “part” object cannot exist independently of the “whole” object.
How does “Aggregation” differ from “Composition” in UML?
Aggregation is a weaker “has a” relationship where the child class (part) can exist independently of the parent class (whole), unlike composition where the part cannot exist without the whole.
In UML, what is the symbol for a “Realization” or “Implementation” relationship, and what does it generally signify?
The symbol for Realization/Implementation is a dashed line with a closed, unfilled arrowhead. It generally signifies that one classifier (e.g., a class) implements or realizes the contract specified by another classifier (e.g., an interface).
In UML, what is the symbol for a “Dependency” relationship, and what does it generally signify?
The symbol for a Dependency relationship is a dashed line with an open arrowhead. It generally signifies that a change in one element (the supplier) may affect another element (the client) that depends on it.
What is Polymorphism in OOP?
Polymorphism refers to the ability of objects of different classes to be treated as objects of a common superclass. It allows methods to be invoked on different objects in a uniform manner, providing a single interface to entities of different types. It’s the ability to take on many forms.
What are the two main types of polymorphism?
- Compile-time Polymorphism (Static Binding or Early Binding), e.g., method and operator overloading.
- Runtime Polymorphism (Dynamic Binding or Late Binding), e.g., method overriding and interface implementation.
What is “Duck Typing”?
Duck Typing is a concept where an object’s type/class is less important than the methods it defines. If an object supports the required methods or properties for an operation, it’s considered to be of the expected type, even without explicit inheritance
Explain “Subtyping” as a form of polymorphism.
Subtyping is a type of polymorphism where code written for a supertype will also work correctly on objects of its subtypes. This is often achieved through inheritance.