How can you de-couple creating an instance of a class (since it’s dependent on a concreate class)?
By creating an abstract factory class
What are object patterns?
Patterns produced by experienced developers, that when followed produce code with less bugs/issues.
What is encapsulation?
Wrapping data and it’s methods into a unit by restricting direct access to an objects internal state.
- only allowing interaction through well defined interfaces.
What is inheritance?
Reusing code from superclasses. A subclass uses the functionality from a superclass and is able to extend it for modification.
How can you ensure loose coupling?
make every public method final. If something is public there’s no reason it should be overridden, unless you’ve allowed this when defining the class.
What are the OO benefits (achieved by following SOLID)
What are the two steps for OO development and explain them?
What is the role of documentation and list some examples:
What are patterns vs components?
List a number of OO design patterns:
Describe the MVC OO design pattern:
Describe what each of the Model, View and Controller components would be implemented as:
Model: classes and objects
View: GUI framework / web templates
Controller: classes and methods
Describe in detail what the model component in the MVC does:
Describe in detail what the view component in the MVC does:
Describe in detail what the controller component in the MVC does:
What are the benefits of the MVC OO design pattern?
Describe the command pattern
an object is used to encapsulate all information needed to perform an action or trigger an event at a later time
Describe the structure of a command pattern:
What are the key benefits of the Command Pattern?
Describe the factory class object pattern:
Give an example of a scenario when you’d use a factory class pattern:
For handling different image file types:
How to handle the string when the input image file could be JPG, PNG, etc…
public static Image getInstance(String fileName){
if (fileName.endsWith(“.png”)) {
return( (Image)new ImagePNG(fileName));
}
if (fileName.endsWith(“.jpg”)) {
return( (Image)new ImageJPG(fileName));
What are the benefits of using the factory class object pattern
Describe a singleton (class) design pattern:
What is lazy initialisation?
The instance of a singleton class is only created when the object is needed (not when the application is loaded up.