Thinking in Java Reading Notes -- 1. introducation to object

Source: Internet
Author: User

All +
All-

Thinking in Java

  • 1. introducation to object

    • + -
      object-oriented -- abstraction

      • 1. You can regard all the conceptual components of the problem to be solved as an object.
      • 2. Program is a group of objects that send messages to each other and tell the other party what to do.
        A message is a request that calls a method specific to an object.
      • 3.
      • 4. Any object is an instance of a class
      • 5. All objects belonging to the same class can accept the same message
      • all objects have statuses, behaviors, and labels
      • each object belongs to a class, and these classes define its features and behaviors
      • A Class describes a group of objects with common features and behaviors.
      • A class is actually a data type.
        • class, customized by programmers to solve specific problems
        • data type, designed to represent a computer's storage unit
      • object, which is an instance of the class
      • each object is an independent entity of this class
    • + -
      object-oriented -- interface

      • each object can only meet certain requests, and the object can accept requests.
        it is determined by the interface defined by its class.
      • the interface is only responsible for determining the requests that the object can accept, and the response of the object to the
        request, implemented by Code
      • you send a message (submit a request) to the object
        the object determines how to handle the message (execute code)
      • light lT = new light ()
        lt. On ();
    • + -
      object-oriented -- service

      • Object-service provider
        the task of a software engineer is to create a group of objects that provide the best service to solve the problem.
      • in a good object-oriented design, an object should only do
        one thing, and do one thing well, instead of doing many things.
      • good object-oriented design should be highly cohesive
    • + -
      hide

      • programmer classification

        • creator of the class
        • customer programmer-class user
      • hiding the internal implementation of the class can avoid misoperation of sensitive parts inside the class.
      • only allow client programmers to access the service through class-defined interfaces.
        it can be used without affecting client programmers, modify the specific internal implementation
      • Public -- accessible to anyone
      • private -- only the class creator can access
      • protected -- only the inherited class can be accessed
      • package -- default access permission
        • members with default access permissions of other classes that belong to the same package
        • outside the package, members with default access permissions are treated as private members.
    • + -
      reuse implementation

      • directly create an object with a class
      • place the class object in a new class -- create a member object
      • synthesize composition -- combine multiple existing classes of different types into new classes
      • aggregate aggregation-Dynamic Synthesis
      • generally, "merging" is a has-a relationship. For example, a car has an engine.
      • when creating a new class, the use of "synthesis" should be given priority
    • + -
      inheritance: Reuse interface

      • base class, superclass, parent class
      • derived class, inherited class, subclass
      • changes in the base class affect the derived class
      • the base class stores the common features and behaviors of all classes inherited from it.
      • all messages that can be passed to the base class can also be passed to Their Derived classes
      • you can determine what type of message a class can receive.
      • the derived class and the base class belong to the same type-class equality
      • extends
      • override -- Method for redefining the base class in the derived class
      • completely replace (pure substitution)
      • is-a relationship
      • is-like-a relationship
    • + -
      Polymorphism

      • Generic
      • Bind later
      • Upcasting
    • + -
      Abstract

      • The compiler prohibits anyone from creating abstract objects.
      • Abstract Method
      • The abstract method only exists in the abstract class.
      • Abstract method indicates that all classes derived from this class have this method,

        But the implementation of this method is not here
      • If a class inherits from the abstract class

        Method implementation is either an abstract class
    • + -
      Interface keyword

      • It is not allowed to implement any method to completely separate interfaces from implementations.
      • It can inherit multiple interfaces, but cannot inherit multiple common classes or abstract classes.
    • + -
      Object Creation

      • Create -- C ++ In the heap
      • Create Java in stack
      • New Keyword
      • Garbage Collector
    • + -
      Container)

      • Iterator
    • Single Inheritance System
    • Upload/download/parameterized type
    • Exception Handling
    • + -
      Concurrency

      • Thread
      • Lock Resources
    • Persistence
    • + -
      Java and Internet

      • Web
      • Client Programming
      • Plug-ins
      • Script Language
      • Server programming
        • Servlet
        • JSP
    • + -
      Why is Java successful?

      • The system is easier to express and understand
      • Maximize the use of Class Libraries
      • Exception Handling
      • Suitable for compiling large systems
    • Java or C ++?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.