L7: Making Software Reusable Flashcards

1
Q

What is a “type”?

A
  • Primitive types are variables that store actual values
  • Reference types store references to an object T
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Abstract classes versus interfaces

A

Neither can be instantiated as object, both can specify behaviour and data

An interface is a collection of behaviour offered by an object of that type:
- Methods are defined but empty, all of them must be implemented in the class
- A class can implement multiple interfaces, since interfaces are not inheritance

An abstract class is abstracted behaviour of a collection of classes:
- Methods can be abstract (no implementation) or concrete (with implementation)
- Are (should be) part of an inheritance structure

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

Enumeration (enums)

A
  • Set of fixed values/constants
  • Can be used in switches, loops, …
  • Can also involve methods
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Record

A

Designed to store fixed values
Automatically have:
- Private field for each component
- Public getter
- Public constructor
- Implemented toString() method

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

SOLID

A
  • Single responsibility: each unit (class) should have only one responsibility
  • Open/closed: units should be open for extensions, but closed for modifications
  • Liskov substitution: methods that use references to classes must be able to use objects of derived classes (i.e. subclasses) without knowing it
  • Interface segregation: no code should be required to rely on methods it is not using
  • Dependency inversion: higher-level units should not depend on lower-level units, and both should depend on abstractions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

KISS: Keep It Simple, Silly!

A

It does not help to have a complicated solution nobody understands

Simpler solutions are less error-prone

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