• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/39

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

39 Cards in this Set

  • Front
  • Back
Factory Design Pattern
The essence of the Factory Pattern is to "Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses." The factory method design pattern handles this problem by defining a separate method for creating the objects, whose subclasses can then override to specify the derived type of product that will be created. More generally, the term factory method is often used to refer to any method whose main purpose is creation of objects. (Wikipedia)
Singleton design pattern
The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. (Wikipedia)
Iterator design pattern
the Iterator pattern is a design pattern in which iterators are used to access the elements of an aggregate object sequentially without exposing its underlying representation. An Iterator object encapsulates the internal structure of how the iteration occurs.

For example, a tree, linked list, hash table, and an array all need to be iterated with the methods search, sort, and next. Rather than having 12 different methods to manage (one implementation for each of the previous three methods in each structure), using the iterator pattern yields just seven: one for each class using the iterator to obtain the iterator and one for each of the three methods. (Wikipedia)
Adapter design pattern
he adapter design pattern (often referred to as the wrapper pattern or simply a wrapper) translates one interface for a class into a compatible interface. An adapter allows classes to work together that normally could not because of incompatible interfaces, by providing its interface to clients while using the original interface. (Wikipedia)
Three object design principles
open closed, dependency inversion, and single responsibility.
Separation of concerns, what it is, its benefits
Separation of concerns is a basis for breaking software into smaller pieces (e.g. classes). If done well, it leads to cohesion within the individual pieces and loose coupling between the pieces
Checklist for Writing Bulletproof and Leakproof Code
1. Minimize accessibility of classes, methods, and, especially, data members. Use private and minimize scope.

2. Minimize mutability. Final, immutable objects, design for inheritance or prohibit it, unmodifiable wrapper for classes.

3.Check preconditions wherever feasible

4. Create defensive copies of parameters or return values

5. Enforce singletons
Single most important factor that distinguishes a well-designed program from a poorly designed one? (effective java) How do you design for this?
The degree to which the module hides its internal data and other implementation details from other modules. Well-designed programs clearly separate the API from its implementation.

You need to minimize the accessibility of classes and members to uphold encapsulation. Make each class or member as inaccessible as possible.
Why are immutable classes better than mutable ones? (Effective Java)
They are easier to design, implemen, and use than mutable classes. They are less prone to error and are more secure.
What are the five steps to make a class immutable (Effective Java)
1. No mutators.
2. Ensure that the class can't be extended.
3. Make all fields final.
4. Make all fields private.
5. Ensure exclusive access to any mutable component.
How can you design or prohibit inheritance ? (Effective Java)
"There are two ways
to prohibit subclassing. The easier of the two is to declare the class final. The
alternative is to make all the constructors private or package-private and to add
public static factories in place of the constructors" -ej
What is the relationship between OCP and inheritance/composition?
Inheritance and composition, when used correctly, is the java mechanism by which we can reuse code.
Polymorphism as it relates to interfaces
Polymorphic behavior is promised in the interface but is actually implemented in one of several subclasses.
Why does subclassing adhere to the OCP?
Mechanism by which we reuse code.

Inheritance - Your original class is unchanged.

Person (superclass) knows nothing about student (subclass). So we are building more onto person without it knowing.

Composition -
An engine doesn't know it is isnide a car. Also, car is just a client of piston engine and doesn't know any of the internals.
In computer science, how do we know when it is appropriate to use subclassing?
Shared common behavior
Two ways to manage complexity?
Divide into pieces, and use abstraction (with programming by contract).
Difference between Java Collection and Java Collections?
Collections - set of utility routines

Collection - interface
According to Kye, what is a dynamic iterator?
One that returns data only as it is needed.
What is refactoring?
Refactoring is making code better without chnaing the actual way that the code behaves. Improves structure and form. Extract method is one way.
Black box testing vs. white box testing
– black box = testing that ignores the internal mechanism of a system and focuses entirely on the outputs generated. White box – testing that takes into account the internal mechanism of the system
Direct Access Table
One drawer for every possible member of the set. Uses tons of memory but is really fast.
Hash Table
Emulates DAT without using as much memory. Utilizes hash function.
For each loops
better to use according to Bloch.

(Element E: Set MyBag)
What is the benefits of implementing comparable and what does compareTo = 0 imply?
It implies that there is a natural ordering of your objects and then they can take advantage of any type of methods that sort objects. if two objects have a compareTo = 0 implies the two objects are equal.
Why favor composition over inheritance? (EJ)
Inheritance violates encapsulation. Superclass may change in next releases, and then the subclass may break.

Inheritance, you have to worry about substitution principle.
What does it mean to use function objects to represent strategies? (Effective Java)
Function objects only have behavior, they don't have states. They perform actions on other objects, rather than on themselves.
What is a nested class?
A nested class is one that is defined within another class. It should exist only to serve its enclosing class. If a nested class would be useful in some other context, then it should be toplevel.
What are the four types of nested classes? (EJ)
the four kinds:
1. static member classes - simplest, ordinary class inside another class.

2. non-static member classes
3. anonymous classes.
-no name
4. local classes.
How do you make a defensive copy?
When parameter is inputted, copy that. Return the copy to the user. (Leander talking).
How do you design method signatures carefully?
Choose good names.
Don't go overboard, every method should pull its weight.
Avoid long parameter lists.
For parameters types, favor interfaces over classes.
Prefer two element enum types to boolean parameters.
What is a powerful technique for minimizing the scope of local variables?
Declare it only when it is first used. Nearly every local variable deceleration should contain an initializer.
What is the order of preference when looping and why? When can you not use a foreach?
1. For each - easier to read, more efficient.
2. For - you can use loop variables.
3. While.

You can't use a for each if the collection does not implement iterator. Also, if you are going to be mutating the collection, then you should not use for each. Also, if you need more than one iterator over more than one collection, you can not use for each (parallel iteration )
Model View Controller Design pattern
Several problems can arise when applications contain a mixture of data access code, business logic code, and presentation code. Such applications are difficult to maintain, because interdependencies between all of the components cause strong ripple effects whenever a change is made anywhere. High coupling makes classes difficult or impossible to reuse because they depend on so many other classes.

The Model-View-Controller design pattern solves these problems by decoupling data access, business logic, and data presentation and user interaction.

The model is the application layer. When it updates, it sends a message to the view. Then the view updates. The view is the user interface. When you make a change to the view, it sends user messages to the controller. The controller translates this for the model and selects which view for the user.
Chaining in a hash table?
Basically, just adding a linked list where a drawer is so that you can chain together elements of the same hash value.
Three layers/levels of a program
Presentation [gui]

Application [code]

Server [database/network]

Also could be called User Interface, Module, and Database.
Layered architecture:

1. Interactions between layers is highly _______.
2. Each layer uses the layer ____ it and provides information to the layer ____ it. [Spatial terms]
3. A layer has no knowledge of the layer ____ it.
1. Constrained / restricted.
2. Uses the layer below, provides information above it.
3. Above it.
What are some advantages of layered architecture?
Each layer is cohesive.

Provides support for information hiding.

Reduction of coupling.

Helps with separation of concerns and breaking things into smaller problems.
Disadvantages of layered architecture
Can be slow.

Can be difficult to debug.

Difficult to design perfectly what goes in each layer.
Three uses of the final keyword.
1. Final class can not be extended.
2. Final method can not be overridden.
3. Final variable can not be changed.