OOP Final Flashcards

1
Q

polymorphic

A

one name and many different meanings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Overloading
ad hoc polymorphism

A

one name that refers to two or more different implementations. Must share the same method name.

i.e. occurs within the context of the parent class/child class relationship

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Overriding
inclusion polymorphism

A

A child class redefining a method inherited from a parent class. Must maintain the same method signature

i.e. single function name (or method name) has several alternative implementations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Overloaded method binding

A

distinguished at compile time based on their type signatures

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Polymorphic variable

A

variable that can hold different types of values during the course of execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Pure polymorphism

A

when a polymorphic variable is used as a parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Generics (Templates)

A

A way of creating general tools or classes by parameterizing on types

i.e. leaves types of methods & classes unspecified to be used in wider range of situations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Inheritance & composition

A

Types of software reuse

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Goal of polymorphism

A

Facilitates reuse of standard software components that leads to:

rapid development
reliability
ease of use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

inheritance

A

is-a relationship

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

composition

A

has-a relationship

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Using Composition

A

Everything must be redefined while leveraging an existing software component in the creation of a new application

i.e. Set and List are unique data structures but Set can be reimplemented completed using List class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Composition class hierarchy

A

no explicit or implicit claims about substitution.

i.e. Set and List are distinct and neither can be substituted in situations where the other is required

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Using Inheritance

A

Declare a new class as a child of an existing class. Thus, all data areas and functions associated with the original class are automatically associated with the new data abstraction.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Composition Advantages

A
  • simpler, and clearly indicates what operations are provided
  • Easier to change underlying details (change data representation)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Inheritance Advantages

A
  • shorter code from code reuse
  • possibly increased functionality
  • slight advantage in execution time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Inheritance Disadvantages

A
  • Can be difficult to understand what behavior is provided
  • May introduce unintended usage of behavior

i.e. programmer must understand a class constructed using inheritance and the parent class (yo-yo problem - flipping back and forth between two or more classes)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Polymorphism Mechanisms

A

Overloading
Overriding
Polymorphic Variable
Generics

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Static Polymorphism
Compile time polymorphism

A

compiler identifies which method is being called at the compile time

20
Q

Dynamic Polymorphism
Run-time Polymorphism

A

method being called is determined at runtime and not at compile time

21
Q

Implementing Static Polymorphism

A

Method & operator overloading

22
Q

Implementing Dynamic Polymorphism

A

Method overriding

23
Q

virtual
override

A

if the same method is present in both superclass and subclass then the subclass method must use keywords in its method signature to be called during run-time

24
Q

Static Polymorphism advantages

A
  • more flexibility in
25
Dynamic Polymorphism advantages
- Flexibility & Extensibility - Late Binding - Support for Inheritance - Easier maintenance and updates
26
late binding
The decision about which method to call is deferred until runtime. This allows for more dynamic behavior, where the appropriate method to invoke is determined based on the actual type of the object during runtime.
27
Static Polymorphism advantages
- Better performance since compilers knows at compile time which method to call - Early error detection - Simplicity - No runtime overhead
28
Choosing between runtime and compile time polymorphism
The choice between runtime and compile-time polymorphism depends on the specific requirements of the program. In many cases, a combination of both types of polymorphism is used to leverage their respective benefits in different parts of the code. i.e. a system might use runtime polymorphism for managing a polymorphic collection of objects, while using compile-time polymorphism for efficiency in certain performance-critical sections.
29
Design Pattern Goal
- Reduce information flow that must pass over this boundary - Make process of connecting simple
30
Pattern description
name synopsis forces solution counterforces related patterns
31
synopsis
A short description of the problem the pattern design to solve ex. Used to connect a client who needs a service described using once interface with a provider who implements the desired functionality but uses a different interface
31
name
used to describe a pattern. ex. The adapter pattern
32
forces
a description of the requirements for a pattern or the considerations that must be taken into account in the use of the solution
33
Counterforces
A description of reasons that might need to be considered in deciding to not use a pattern
34
Related Patterns
this section describes related patterns that user might want to consider in the solution to their problem
34
solution
the resolution ex. the adapter implements the interface as specified by the client and passes the work on to the service provider
35
Iterator design pattern
Problem: provide client access to elements in a collection without exposing the structure of the collection solution: allow client to manipulate that returns the current value and move to the next element in the collection Description: Iterator is used to traverse a container of data to access the container's elements without the need to know the underlying structure
36
Creational Pattern
These type of pattern support the creation of objects. Because in certain situations there are more elegant ways than using the new operator.
37
Software Factory design pattern
Problem: simplify the creation of many different types of classes which share a similar parent class Solution: Hide creation within a method, have the method declare a return type that is more general than its actual return type Description: Abstract Factory provides an interface for creating families of related or dependent object without to specify concrete classes
38
Singleton design pattern
Problem: You want to ensure there is never more than one instance of a given class Solution: Make the constructor private, have a method that returns just one instance which is held inside the class itself Description: This pattern ensures that only one instance of an object is created and that this instance is globally accessible
39
Singleton Examples
Logger class Configuration Management Database Connection Pool Print Spoolers
40
Decorator design pattern
Problem: Allow functionality to be layered around abstraction, but still dynamically changeable Solution: Combine inheritance and composition by making an object that both subclasses from another class and holds an instance of the class Description: The decorator pattern allows to add functionality to an object at run time without altering its structure
41
Adapter design pattern
Used to connect a client (Object that needs a service) with a server (object that provides a service) ex. Client requires a certain interface while the server provides necessary functionality it does not support the interface
42
Runtime vs Compile time (4 each)
Runtime - flexibility and extensibility - late binding - support for inheritance - easier maintenance and updates Compile time - performance - early error detection - simplicity - no runtime overhead
43