Object oriented thinking Flashcards

1
Q

What are steps of object oriented thinking?

A
  1. examine the problems or concepts at hand
  2. break them down into component parts
  3. think of these parts as objects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are abstract classes?

A

Classes that cannot be instantiated.

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

What are 3 categories of objects?

A
  1. entity objects
  2. control objects
  3. boundary objects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are entity objects? When do you identify entity objects?

A

Entity objects are the most familiar, because they correspond to some real-world entity in the problem space.

  1. If you have an object representing a chair in your software, then this is an entity object.
  2. If you have an object representing a building or a customer, these are all entity objects.

Generally, these objects will know attributes about themselves. They will also be able to modify themselves, and have some rules for how to do so.

When you are identifying objects to include in your software and breaking down those objects into smaller objects, you will initially get entity objects. The other categories of objects will come later, as you start to think about the technical design of the software.

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

What are boundary objects? Give examples

A

Boundary objects are objects which sit at the boundary between systems.
1. This could be an object that deals with another software system - like an object that obtains information from the Internet.
2. It could also be an object with the responsibility of showing information to the user and getting their input.

If you program a user interface - the visual aspect of software - you are probably mostly working with boundary objects.

Any object that deals with another system - a user, another software system, the Internet - can be considered a boundary object.

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

What are control objects?

A

Control objects are objects which are responsible for coordination. You will discover control objects when you attempt to break down a large object, and find that it would be useful to have an object that controls the other objects.

A great example is a Mediator: it simply coordinates the activities of many different objects so that they can stay loosely coupled.

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

What are 3 types of relationships in decomposition?

A
  1. association
  2. aggregation
  3. composition
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is association?

A

A loose relationship between two objects which may interact with each other for some time, but they are not dependent on each other.

If one object is destroyed, the other can continue to exist. There can be any number (including 0) of each item in the relationship.

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

What is this decomposition relationship? why?

public class Student {

public void play( Sport sport ){
execute.play( sport ); }
}

A

Association.

In this code excerpt, a student is passed a sport object to play, but the student does not possess the sport. It only interacts with it to play. The two objects are completely separate, but have a loose relationship. Any number of sports can be played by a student and any number of students can play a sport.

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

What is aggregation?

A

Aggregation is a has-a relationship where a whole has parts that belongs to it. Although parts can belong to the wholes, they can also exist independently.

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

What kind of decomposition relationship is this?

public class Airliner {
private ArrayList<CrewMember> crew;
public Airliner() {
crew = new ArrayList<CrewMember>();
}
public void add( CrewMember crewMember ) { ...
} }</CrewMember></CrewMember>

A

aggregation

The airliner would not be able to offer services without the crew. However, the airliner does not cease to exist if the crew leave. The crew also do not cease to exist if they are not in the airliner.

In the Airliner class, there is a list of crew members. The list of crew members is initialized to be empty and a public method allows new crew members to be added. An airliner has a crew. This means that an airliner can have zero or more crew members.

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

What is composition?

A

Composition is one of the most dependent of the decomposition relationships. This relationship is an exclusive containment of parts, otherwise known as a strong “has-a” relationship. In other words, a whole cannot exist without its parts, and if the whole is destroyed, then the parts are destroyed too. In this relationship, you can typically only access the parts through its whole. Contained parts are exclusive to the whole.

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

What is this decomposition relationship? Why?
public class House { private Room room;
public House(){
room = new Room();
} }

A

composition

In this example, a Room object is created at the same time that the House object is, by instantiating the Room class. This Room object does not need to be created elsewhere, and it does not need to be passed in when creating the House object. The two parts are tightly dependent with one not being able to exist without the other.

A house is made up of multiple rooms, but if you remove the house, the room no longer exists.

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

What is polymorphism?

A

In object-oriented languages, polymorphism is when two classes have the same description of a behaviour, but the implementation of the behaviour may be different.

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

What is encapsulation?

A

Encapsulation involves three ideas.
1. It bundles attribute values and behaviours that manipulate those values into a self-contained object.
2. It also exposes certain data and functions of the object to other objects that need them
3. alternately restricts access to certain data and function to only within that object.

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

What are functional vs non-functional requirements?

A

Functional: what the system of application is expected to do. (e.g. correcteness)

Non-functional: how well the system or application does what it does. (e.g. performance, resource usage, efficiency, reusability, flexibility, maintainability)

17
Q

What is a package?

A

The means by which Java organizes related classes into a single namespace.