OOP Flashcards

1
Q

modularity

A

organizing principle: different components of sftwr sys divided into separate functional units (think module: collection of closely related classes/functions)

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

abstraction

A

distill complicated system down to most fundamental parts

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

ADT

A

mathematical model of data structure that specifies type of data stored, supported operations on them, types of parameters of operations

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

duck typing

A

treats abstractions implicitly

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

ABC

A
only purpose is to serve as base class through inheritance 
(how Python supports ADT's: defines 1 or more common methods that all implementations of abstraction must have)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

encapsulation

A

should not reveal internal details of implementations

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

self

A

serves to identify particular instance upon which a member is invoked

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

__init__ method

A

constructor of the class; establishes state of newly created object w/ appropriate instance variables

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

operator overloading

A

implementing a specially named method
….ie, + operator overloaded by implementing __add__ method
a + b -> a.__add__(b)

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

iterator

A

key behavior: supports special method __next__ : returns next element of collection, if any, or raises StopIteration exception

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

generator

A

automatically produces iterator of yielded values

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

Python provides automatic iterator implementation on classes that define:

A

__len__ & __getitem__

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

lazy evaluation

A

represents the desired elements w/out storing explicitly in memory (rather than creating new instance); ie, range

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

inheritance

A

allows new class (child class) to be defined based upon existing class (base/parent/super class)

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

2 ways subclass differentiates from its superclass

A
  • special existing behavior (overrides method)

- extend: provides new methods

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

super().__init__

A

calls __ini__ method from parent class

17
Q

protected members

A

single underscore; accessible to subclasses, but not public

18
Q

private members

A

double underscore; not accessible to public or subclasses

19
Q

namespace

A

abstraction that manages all identifiers defined in particular scope (maps each name to its value)

20
Q

instance namespace

A

manages attributes specific to individual object (__init__)

21
Q

class namespace

A

manages members that are shared by all instances of class

22
Q

nested class

A

supports outer class (unrelated to inheritance)

23
Q

alias

A

ie, foo = bar: foo alias for bar

24
Q

shallow vs deep copy

A

shallow: can add/remove elements without affecting other, but if edit, changes both
deep: the new references its own copies of those objects referenced by original

25
Q

template method pattern

A

when an abc provides concrete behaviors that rely upon calls to other abstract behaviors (soon as subclass provides def’s for missing abstract behaviors, inherited concrete behaviors well defined)

26
Q

metaclass

A

provides template for class def itself

27
Q

@abstractmethod

A

(declares methods to be abstract) don’t provide implementation, but expect concrete subclasses to support those methods