1. doing sth. with state: data structure
  2. doing sth. with methods: algorithms
  3. We do not trust clients! When they pass us parameters, we need to check its' correctness
  4. String: check null
  5. How to decide the state: clients are god! we give what they need!
  6. The reason we are using an object class is not say the class including main might be too long. It is because of the efficiency and share.
  7. Object Init Constructors
    1. basic
      1. obj's init state
      2. public <Class name>(para) {<statement>}
      3. default constructor new Point();
    2. common mistake
      1. NO return types
      2. NO redeclare fields
    3. The keyword this
      1. this
        1. refer to implicit parameter
        2. this.<field name>
        3. this.<method name>(<expre>)
        4. shadowed variables
    4. Multiple Constructors
      1. give clients different way to construct
      2. different signature
      3. public Point() {this(0,0);}
  8. Encapsulation
    1. Basics
      1. encapsulation
        1. encapsulate is not totally hiding the field
        2. It is just not giving the client access to modify it
      2. abstraction
      3. private <type> <name> = <value>;
      4. + public int getX(){return x;}
      5. The accessor methods give the client read-only access
    2. Sun's style
      1. fields>constructors>methods
    3. class invariant
      1. An assertion about an obj's state remain true for the lifetime
      2. precondition to constructors and postcondition for method
      3. throw new IllegalArgumentException();
    4. Changing internal Implementations
  9. Case Study
    1. Object-Oriented Design Heuristics
      1. 1. cohesion
        1. single abstraction
      2. objects should NOT handle console I/O for less interwind
      3. 2. reduce unnecessary coupling
      4. 3. Related data and behavior should be in the same place
      5. CRC card
        1. class
        2. responsibilities
        3. collaborators
          1. which class it couples
    2. Stock Fields and Method Headers
      1. store values
        1. void
      2. process values
        1. return type
    3. Stock Method and Constructor Implementation
      1. constructor
        1. init
        2. pass string cannot be null
        3. throw new NullPointerException();
        4. pass value
        5. throw new IllegalArgumentException();
  10. Object State and Behavior
    1. Object State: Fields
      1. Field
        1. variables in an obj of its inner state
        2. every obj will have it
      2. client code will use Point class by create Point object
      3. record/struct
        1. state, no behavior
    2. Obj behavior: Method
      1. Instance method
        1. call: <obj name>.<method name>(para)
        2. without specify the obj in the method
        3. obj contains state and methods, they are stored as an entity
        4. cause it is "instance"'s methods
      2. static method
        1. <class name>.<method name>(para)
        2. if in the class, <method name>(para)
      3. the Implicit Parameter
        1. implicit parameter
          1. a.<method>(b)
          2. a is impl, b is expli.(kind of like y=kx+b)
      4. Mutators and Accessors
        1. Mutator
          1. Common convention:
          2. methodName
          3. set***; setID; setTitle
          4. modify internal state
          5. read-write
        2. Accessor
          1. 1.info no modify 2. return a related value without changing obj inner values
          2. e.g. subString, length, String...
          3. return station
          4. common convention
          5. get***; is***
          6. read only
        3. the toString method
          1. auto trans to String, when concatenated with String
          2. .toString
          3. inheritance
          4. usually println does not include in class because it limits the output format
          5. toString returns a string that can be used by println
  11. Object-Oriented Programming
    1. Basics
      1. OOP
        1. actions --> objects
        2. e.g. GUI
      2. Objects
        1. entity = state + behavior
        2. instances
      3. State
        1. values
      4. Behavior
        1. actions
          1. reporting
          2. modifying
      5. Client (Code)
        1. code, interact with objects or class
      6. class
        1. blueprint
    2. Classes and Objects
      1. create object-->class
        1. state
        2. behavior
        3. how to construct
      2. class-->objects-->client prog
    3. Point Objects
      1. 2D