Some simple object-oriented personal insight


1. The difference between process-oriented and object-oriented:
  process-oriented and object-oriented programming is a kind of thinking, different ways of thinking.
  Process-oriented: thinking practitioners; "how to do | how to achieve?" And then step by step to achieve it.
  Object-oriented: that is thought leaders; "this matter should find who completed?" This man is the object to complete, does not care about the implementation process, only the object of attention.
  Relying on an object-oriented process-oriented.
2. Object-oriented advantages:
  1) object-oriented way of thinking closer to the way of thinking of real life.
  2) Object-oriented reflected in the way of thinking more managers, embodied in the process for the performer.
  3) You can simplify complex issues.
3. Classes and Objects
  object-oriented concept proposed two - class, object
  categories: | template series of things (a common definition of a series of things).
  Object: a thing in real life real.
  No classes there is no way to create objects.
4. custom class
  pubic class class name {
  // property
  modifiers data type variable name = variable value;
  // function
modifier return type | void method name (parameter list) {
         method body;
     }
  }
  Note: members without static modification.
5. Use custom class
  1) guide the packet
    directly to the java.lang package contents does not require the leader packet, with the packet type does not require the leader packet.
  2) Create a variable of this type | references to create an object -> new
reference data type variable name = new reference data types ();
  3) the use of the contents of
    a variable name attribute name.
    Variable name method name (argument).
6.new create step object will be performed
  1) to open up space for the object on the heap, the current members of the property class will follow the object into the heap memory capacity with the default values.
  2) call the constructor to initialize the object information (usually members of the first attribute assignment).
  3) the address of the object is returned to the reference.
7. builder
  constructor known construction methods, and constructors.
  Role:
    initialize the object information.
  Definition:
    Modifier class name ([parameters]) {
      ....
    }
    1) does not return type, no void.
    2) there may be return as required, early termination method.
    3) construction can not static, abstract, used together final.
  Call:
    follow the new use, new which step.
  Note:
    1) If no constructor, the compiler will implicitly provide an empty constructor for you.
    2) If there is a custom constructor, the compiler will not provide any constructors for you, including the empty structure.
    3) defining a plurality of configurations, a different parameter list constituting constructor overload, in accordance with call arguments match () constructor different.
    4) constructor modifiers may be private, proprietary, this configuration can only be used in the current class.
  Define different configurations according to different requirements, usually at least a null configuration.

Guess you like

Origin www.cnblogs.com/DHY868168/p/11265859.html