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
Which array can have null values
Can have null values:
- String array
Can’t have null values:
- Integer array
- Set integers
Dependency Inversion Principle
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?
For ADTs, we distinguish between specification and implementation. Which of the following are part
of the specification of an ADT?
For ADTs, we distinguish between specification and implementation. Which of the following are part
of the Implemenation of an ADT?
What are the advantages of throwing a Java exception instead of returning a special value to signal
a violated precondition?
In the context of abstract data types, what is encapsulation, and why is it useful?
What is functional decomposition?
This is a design technique that carries out Divide & Conquer (solely) with procedural
abstraction.
Decomposition is driven by considering the required functionality of the
program being designed. In requirements, functionality can often be discovered in the verbs.
Design guidelines:
- aim for single-purpose, general methods (SRP = Single Responsibility
Principle),
- low coupling
- high cohesion
- low complexity (no deeply nested control
structures)
- avoid code duplication (DRY = Don’t Repeat Yourself). Parameters, return
values, global versus local data, recursion.
Explain one disadvantage of functional decomposition.
Disdvantages of Divide & Conquer
- Top-level divisions are hard to make: can have big consequences. Need experience and
need to experiment (try alternatives).
Advantages of automated test cases on manual ones
Name at least four reasons why it is not a good idea to include unnecessary test
cases.
What is the purpose of the SwingWorker class of Java?
It makes it easy to run some code in a background thread, and still interact with it in a
controlled way.
Describe the two main steps for client code to use the SwingWorker class?
Explain two design patterns which play a role in the SwingWorker, and what that
role is.