Object Oriented Programming Flashcards

1
Q

4 Major Principles of OOP

A
  • inheritance
  • polymorphism
  • abstraction
  • encapsulation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

abstract class

A
  • a class that you only inherit from
  • you don’t directly instantiate from
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

polymorphism

A
  • The ability of a subclass to also act as an instance of its own superclass
  • Ex:
    • Superclass -> Shape
    • Subclasses-> Squares, Triangles
    • You can create an array of shapes and safely fill it with squares and triangles
  • Every triangle/square/circle is also a shape
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

encapsulation

A
  • the process of hiding information pertaining to an object from the client
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

UML

Class Diagrams

A
  • unified modeling language

3 parts

  • class name
  • attributes
    • visibility - name - colon - datatype
  • method
    • visibility - name - parens - args - colon - return type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

OOP Design

Steps

A
  • focus on what, not how

Steps

  1. Obtain/prepare textual description of problem
  2. Underline nouns => classes
  3. Underline adjectives => attributes
  4. Underline active verbs => methods
  5. Flesh out the requirements
  6. Identify classes
    1. Underline nouns
  7. Identfy attributes
    1. Underline adjectives
    2. Use domain knowledge
  8. Identify oeprations
    1. Underline active verbs
    2. Examine interactions among entities
  9. Identify major entities
  10. Define bahaviors (methods) for each major entity
  11. Identity sub-entities
  12. Define behaviors for each sub-entity
  13. Define relationships between entitties
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

interaction between objects

A

3 main types

  1. x uses (depends on) y: dependency
  2. x has y: association/aggregation/composition:
  3. x is a y: generalization (inheritance)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

association

A
  • a type of OOP relationship
  • a Has-a relationship
  • two objects have a relationship, but they can exist independently of each other
  • there is no ownership or lifetime dependency
  • ex: doctor and patient
  • Notation
    • Solid line
    • Describe relation with text
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

aggregation

A
  • a type of OOP relationship
  • a ‘Has-a’ relationship
  • A special type of association which describes a whole and its parts
  • The parts can exist ouside of the whole
  • ex: a baseball team and players
  • Notation
    • Solid lne, open diamond
    • Part to whole
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

composition

A
  • a type of OOP relationship
  • a ‘has a’ relationship
  • there is ownership
  • when owner is destroyed, child is destroyed
  • both ownership and lifetime dependency
  • ex: house and room
  • ex: class and inner class
  • Notation:
    • Solid line, closed diamond
    • Part to whole
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

generalization

A
  • a type of OOP relationship
  • an ‘IS-a’ relationship
  • basically inheritance
  • Notation:
    • solid line, open triangle
    • subclass to superclass
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

dependency

A
  • x uses y
  • if y changes, x might change
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly