• 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/15

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;

15 Cards in this Set

  • Front
  • Back
What is the rule of rules for writing leakproof/bulletproof code? how is this done?
Minimize Accessibility -- This is done by using private as often as possible, and minimizing the scope of local variables.
What is minimizing accessibility also known as?
encapsulation / information hiding. Information hiding decouples the modules that comprise a system.
What are the four possible access levels for members (fields, methods, nested classes, and nested interfaces) ?
private -- accessible only from top-level class where it is declared

package-private -- accessible from any class in the package where it is declared. Technically known as default access.

protected -- the member is accessible from subclasses of the class where it is declared

public -- the member is accessible from anywhere.
How do we minimize mutability?
1) Use final keyword as often as possible

2) create immutable objects when feasible

3) put an unmodifiable wrapper around your Java collection class.

4) Design for inheritance or prohibit it.
Enumerate the Checklist for Writing bulletproof/leakproof code?
1) Minimize Accessibility (encapsulation)
2) Minimize Mutability
3) Check preconditions wherever feasible
4) Create defensive copies
5) Enforce singletons.
A final class cannot be
A final method cannot be
A final data member, parameter, or local variable cannot
1) subclassed
2) overwritten
3) change once they are set.
3 purposes of final
1) clearly state your intent
2) clearly flags items with simple behavior
3) allows the compiler and virtual machine to perform performance optimizations.
3 examples of use of inheritance
Person-Student, Miniscule List-MinuteList, InstrumentHashSet
Advantages of Inheritance & Major Disadvantage
1) code is very compact
2) clearly communicates intent to reader

Disadvantage -- it can violate encapsulation
Disadvantages of Composition & Major Advantage
1) intent is much less clear to the reader
2) More code -- but these delegation routines can be generated for you

Advantage -- it does not violate encapsulation (the black box is maintained)
Singleton Design Pattern
One instance of a class or one value accessible globally in an application.
Template Design Pattern
In the template design pattern we want to encapsulate what changes. Consider the typical problem of sorting, where we must both order elements and compare elements. We might want to have different comparing methods.
Collcetion vs. Collections
Collection is an interface that describes what all collection objects should have (List, Set) NOT MAP.

Collections is a concrete class with many static methods that does things to a collection (max, min, sort) This operates on a collection.
What are HT bad for?
What are HT good for?
They are not easily sorted, since they're designed to be random. (what if we had to get all students from B-E?)

good for containsKey. We don't want to use containsValue...a bit slow.
Decorator Design Pattern
use as an alternative to subclassing when we want to add additional functionality to an object.
window w = new basicWindow();
...
w = new VerticalScroll(w);