Objects, UML, and Java Flashcards

1
Q

Two most popular programming languages in 1960s

A

COBOL, Fortran

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

Imperative Paradigm

A

COBOL and Fortran followed an imperative paradigm which broke up large programs into smaller programs called subroutines, which are like methods in Java.

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

Two new algorithms in the 1970s

A

Algol 68, Pascal

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

New idea of programming introduced in 1970s

A

Local Variables

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

Abstract Data Type

A

An abstract data type is a data type that is defined by the programmer and not built into the language. An abstract data type is essentially a grouping of related information that is denoted with a type. It was a way to organize data in a meaningful way.

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

These two programming languages provided a means to organize programs and allow developers to more easily create multiple but unique copies of their abstract data types.

A

C, Modula-2

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

The crucial concept that became popular in the 1980s

A

Object Oriented Design

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

The goal of object-oriented design is to:

A
  1. Make an abstract data type easier to write
  2. Structure a system around abstract data types called classes
  3. Introduce the ability for an abstract data type to extend another
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Object Oriented Programming is a paradigm. What are the 3 programming languages founded based off objects?

A

Java, C++, C#

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

Abstraction

A

Abstraction is the idea of simplifying a concept in the problem domain to its essentials within some context. Abstraction allows you to better understand a concept by breaking it down into a simplified description that ignores unimportant details.

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

Rule Of Least Astonishment

A

The abstraction captures the essential attributes and behavior for a concept with no surprises and no definitions that fall beyond its scope. You don’t want to surprise anyone trying to understand your abstraction with irrelevant characteristics.

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

Encapsulation

A

Encapsulation forms a self-contained object by bundling the data and functions it requires to work, exposes an interface whereby other objects can access and use it, and restricts access to certain inside details.

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

Decomposition

A

Decomposition is taking a whole thing and dividing it up into different parts. Or, on the flip side, taking a bunch of separate parts with different functionalities and combining them together to form a whole. Decomposition allows you to further break down problems into pieces that are easier to understand and solve.

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

How does inheritance work?

A

We use repeated, common, and shared characteristics between 2 or more classes and factor them out into another class. There is a parent class (superclass) and a child class (subclass).

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

Generalization

A

Technique which let us apply a rule “Don’t Repeat Yourself” (DRY) to write programs that are capable of performing the same tasks but with less code. It makes code more reusable because different classes or methods can share the same blocks of code.

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

3 ideas in encapsulation in Java

A
  1. Bundle data, and functions that manipulate the data, into a self-contained object
  2. Expose certain data and functions of that object, which can be accessed from other objects
  3. Restrict access to certain data and functions to only within that object
17
Q

Getter Methods

A

Getter Methods are methods that retrieve data, and their names typically begin with get and end with the name of the attribute whose value you will be returning.
Getters often retrieve a private piece of data.

18
Q

Setter Methods

A

Setter Methods change data, and their names typically begin with set and end with the name of the variable you wish to set.
Setters are used to set a private attribute in a safe way.

19
Q

Three types of relationships found in decomposition

A
  1. Association
  2. Aggregation
  3. Composition
20
Q

Association

A

Association is “some” relationship. This means that there is a loose relationship between two objects. These objects may interact with each other for some time.

21
Q

Aggregation

A

Aggregation is a “has-a” relationship where a whole has parts that belong to it. There may be sharing of parts among the wholes in this relationship.
The “has-a” relationship from a whole to the parts is considered weak. What this means is although parts can belong to the wholes, they can also exist independently.

22
Q

Composition

A

Composition is an exclusive containment of parts, otherwise known as a strong has-a relationship. What this means is that the whole cannot exist without its parts. If it loses any of its parts the whole ceases to exist. If the whole is destroyed then all of its parts are destroyed too. Usually you can only access the parts through its whole. Contained parts are exclusive to the whole.

23
Q

UML empty arrow

A

head: superclass (generalized classes)
tail: subclass (specialized classes)
Arrows should point upwards, as superclasses are always towards the top and subclasses are always towards the bottom.

24
Q

In Java, a protected attribute or method can only be accessed by

A
  1. The encapsulating class itself
  2. All subclasses
  3. All classes within the same package
25
Q

Polymorphism

A

When 2 classes have the same description of a behavior but the implementations of the behavior may be different. This is achieved in an interface.

26
Q

Interface

A

declares method signatures, and no constructors, attributes, or method bodies.

27
Q

What to look out for when using inheritance?

A
  1. Ask yourself: “Am I using inheritance to simply share attributes or behavior without further adding anything special in my subclasses?”
  2. Liskov Substitution Principle
  3. Java Collections Library - Are you using the right type of inheritance/decomposition?
28
Q

Liskov Substitution Principle

A

This principle states that a subclass can replace a superclass, if and only if, the subclass does not change the functionality of the superclass.

29
Q

Coupling

A

Calculates the complexity between a module and other modules

30
Q

Three ways to identify the coupling of a module

A
  1. Degree
  2. Ease
  3. Flexibility
31
Q

Degree

A

Degree is the number of connections between the module and others. With coupling, you want to keep the degree small. For instance, if the module needed to connect to other modules through a few parameters or narrow interfaces, then the degree would be small, and coupling would be loose.

32
Q

Ease

A

Ease is how obvious are the connections between the module and others. With coupling, you want the connections to be easy to make without needing to understand the implementations of the other modules.

33
Q

Flexibility

A

Flexibility is how interchangeable the other modules are for this module. With coupling, you want the other modules easily replaceable for something better in the future.

34
Q

Cohesion

A

Cohesion represents the clarity of the responsibilities of a module.