Final Review Flashcards
Test-Driven Development requires one to define contracts and interfaces before writing test cases. T/F ?
True
Functional Decomposition
breaking down a complex system into smaller, functional parts.
ADT
An abstract class or interface that contains a description of all possible operations it can do on a data type but not its implementation
Abstraction function
An abstraction function
Representation Invariant
A representation invariant is a condition or property that must always be true for the internal state of an object or data structure.
A condition inside a method that most hold. A condition about its implementation
Difference between a public invariant and RI
A public invariant is a condition that must hold for a public method to function properly
Represention Invariant is a condition that must hold in a methods implemenation
Dependency Injection
Its is like parameterising but for classes,
During the construction, inject info
What to talk about in @post
- The result
- The variables that are modified
Which array can have null values
Can have null values:
- String array
Can’t have null values:
- Integer array
- Set integers
Dependency Inversion Principle
- high-level modules should not depend upon low-level modules, but that both should depend upon abstractions.
- abstractions should not depend upon details, but that details should depend upon abstractions
Key words
Testability
Resusibility
Understandability
Maintainability
Modifibility
Coupling
Cohesion
Describe the main steps (w.r.t. declaration and execution) for client code to use the SwingWorker class.
i. (Static aspect; declaration) By subclassing SwingWorker and overriding the doInBackground() and done() methods.
ii. (Dynamic aspect; execution) The resulting SwingWorker subclass must be in- stantiated for each run. The background thread is activated by calling execute().
Which of the following design patterns are used for Java’s SwingWorker?
- Facade
- Template
For ADTs, we distinguish between specification and implementation. Which of the following are part
of the specification of an ADT?
- Contracts for individual operations
- Zero or more public invariants
For ADTs, we distinguish between specification and implementation. Which of the following are part
of the Implemenation of an ADT?
- An abstraction function
- A representation invariant.
What are the advantages of throwing a Java exception instead of returning a special value to signal
a violated precondition?
- Exceptions can carry additional information
- Exceptions are typed and can have messages, allowing for specific exception handling and more clear
information while debugging and reading stack traces - The programmer might forget to check the return value; exceptions cannot be ignored so easily