OOP Flashcards
What are objects?
Objects are Python’s abstraction for data. Formally, it is a collection of data and associated behaviors. All data in a Python program is represented by objects or by relations between objects.
Every object has an identity, a type and a value. An object’s identity never changes once it has been created; you may think of it as the object’s address in memory. The ‘is’ operator compares the identity of two objects; the id() function returns an integer representing its identity.
What does an object’s type determine?
determines the operations that the object supports (e.g., “does it have a length?”) and also defines the possible values for objects of that type. The type() function returns an object’s type (which is an object itself). Like its identity, an object’s type is also unchangeable.
The value of some objects can change. Objects whose value can change are said to be:
mutable
objects whose value is unchangeable once they are created are called:
immutable
The value of an immutable container object that contains a reference to a mutable object can change when:
the latter’s value is changed; however the container is still considered immutable, because the collection of objects it contains cannot be changed.
An object’s mutability is determined by its type; for instance, numbers, strings and tuples are _______ while dictionaries and lists are __________.
immutable
mutable
What does it mean to be object oriented?
To be functionally directed toward modeling objects.
What is Object oriented analysis?
the process of looking at a problem, system, or task that somebody wants to turn into an application and identifying the objects and interactions between those objects.
What is object oriented design?
the process of converting such requirements into an implementation specification. The designer must name the objects, define the behaviors, and formally specify what objects can activate specific behaviors on
other objects. The design stage is all about how things should be done.
Define an iterative development model.
In iterative development, a small part of the task is modeled, designed, and programmed, then the program is reviewed and expanded to improve each feature and include new features in a series of short cycles.
What’s the difference between an object and a class?
Classes describe objects. They are like blueprints for creating an object. Objects are instances of classes that can be associated with each other. An object instance is a specific object with its own set of data and behaviors.
What is UML?
The relationship between classes of objects in an inventory system aka (Unified Modeling Language).
It is used to specify, visualize, modify, construct and document the artifacts of an object-oriented software-intensive system under development.
It offers a standard way to visualize a system’s architectural blueprints, including elements such as activities, actors, business processes, database
schemas, components, programming language statements, and reusable software components.
It combines techniques from data modeling (entity relationship diagrams), business modeling (work flows),
object modeling, and component modeling. It can be used with all processes, throughout the software development life cycle, and across different implementation technologies.
The Unified Modeling Language is a standardized general-purpose modeling language and nowadays is managed as a de facto industry standard by the Object Management Group (OMG). UML includes a set of graphic notation techniques to create visual models of software-intensive systems.
What are objects?
Objects are instances of classes that can be associated with each other. An object instance is a specific object with its own set of data and behaviors; Objects are nouns.
What is a class?
A blueprint of an object. It defines the specific characteristics that are shared by all instances of an object for that class.
What is a class attribute?
It defines the properties of the class. eg. name, weight, height, color, etc. Attributes are adjectives.
What is a class method?
The behaviors that can be performed on a specific class of objects. Methods are like functions in structured programming, but they have access to all the data associated with that object. Like functions, methods can also accept parameters, and return values. Methods are verbs.
What are parameters to a method?
a list of objects that need to be passed into the method that is being called.
What does it mean to invoke a method?
Also known as method call, it is the process of telling the method to execute itself by passing it the required parameters as arguments.
Define encapsulation.
The process of hiding the implementation, or functional details, of an object via information hiding. Encapsulation is, literally, creating a capsule, so think of creating a time capsule. If you put a bunch of information into a time capsule, lock and bury it, it is both encapsulated and the information is hidden.
What is a model?
An abstraction of a real concept.
Define abstraction.
means dealing with the level of detail that is most appropriate to a given task. It is the process of extracting a public interface from the inner details. when abstracting interfaces, try to model exactly what needs to be modeled and nothing more.
What should you consider when designing an interface?
When designing the interface, try placing yourself in the object’s shoes and imagine that the object has a strong preference for privacy. Don’t let other objects have access to data about you unless you feel it is in your best interest for them to have it. Don’t give them an interface to force you to perform a specific task unless you are certain you want them to be able to do that to you.
Define composition.
The act of collecting together several objects to compose a new one. Composition is usually a good choice when one object is part of another object and that object cannot exist without the primary object.
Define object diagram.
also called an instance diagram. It describes the system at a specific state in time, and is describing specific instances of objects, not the interaction between classes.
Define aggregation.
Aggregation is almost exactly like composition. The difference is that aggregate objects can exist independently
Define inheritance.
one class can inherit attributes and methods from another class.
Define polymorphism
is the ability to treat a class differently depending on which subclass is implemented.
Define multiple inheritance.
allows a subclass to inherit functionality from multiple parent classes.
Define asynchronous message.
typically means the first object calls a method on the second object which returns immediately.
Define refactoring.
improve the design by moving code around, removing duplicate code or complex relationships in favor of simpler, more elegant designs.