JAVA Object-oriented programming--self-summary

Source: Internet
Author: User

Subsystem

A system structure is a structure consisting of multiple subsystems of a system and a subsystem consisting of several smaller subsystems. So what are the characteristics of subsystems?

Characteristics:

1, structural Stability: Software in the design phase, in a system divided into smaller subsystems, the design is reasonable, making the structure of the system more robust, to adapt to the needs of user change

2. Extensibility: When the software adds new functions, it can create a new subsystem on the basis of the existing subsystem, which inherits some characteristics of the original atom system, and has some new features, which improves the reusability and expansibility of the software.

3, cohesion: Each subsystem only completes the specific function, the different subsystems will not have the function overlap. In order to avoid the overlap between subsystems, the granularity of each subsystem should be as small as possible, the system structure formed in this way is called the structure of fine granularity system. The cohesion of subsystems can improve the reusability and maintainability of software.

4, Composable: A number of fine-grained subsystems have been combined to become a large system. The composable nature of subsystems can improve the reusability and maintainability of software, and simplify the software development process.

5, Loose coupling: Subsystems are independent of each other, modified a subsystem, will not affect other subsystems. When the user annoying demand changes, only need to modify the implementation of the specific subsystem, so as to improve the maintainability of the software.

There are two major types of software development {structured development and object-oriented development}

Object-oriented-objects have the following characteristics:

1. Objects of all Things

2. Each object is unique. The uniqueness of objects comes from the uniqueness of things in the real world

3. Object has attributes and behavior

4, the object has a state state is the value of the individual properties of an instantaneous object, some of the object's behavior will often change the state of the object itself, that is, the value of the property

5. Objects belong to a class, each object is an instance of a class

All instances of the same class have the same properties, the surface their properties have the same meaning, but their state is not necessarily the same, that is, the property value is not necessarily the same

All instances of the same class consist of all instances of the class itself and all instances of its subclasses, and all instances of the class have the same behavior in order for them to have some of the same functionality. All instances of the class itself implement the same functionality in the same way, and the subclasses between the parent classes and the instances between the subclasses may implement the same functionality in different ways.

Interface :

There are two meanings of interfaces in Java:

1, refers to the above introduction of the meaning of the interface, that is, all the services provided by the system, the Declaration of the method of being a public type in the object.

2, refers to the use of interface keyword to define a real interface, also known as the interface type, it is used to clearly describe all the services provided by the system, he can in more detail to the implementation of the system details and interface separation

Encapsulated, Transparent

Encapsulation refers to the properties and implementation details of hidden objects, and only exposes interfaces externally. Encapsulation can provide the following advantages for software systems:

1, easy to use the correct, easy to understand and use the system, to prevent users from mistakenly modifying system properties

2, help to establish the loose coupling between the systems, improve the system's independence

3, improve the reusability of software, each system is a relatively independent whole, can be reused in a variety of environments

4, reduce the risk of building large-scale systems, even if the entire system is not successful, individual independent subsystems may still be valuable

There are 4 levels of access control available in the Java language:

1). Public: Open to the outside, highest level of access

2). Protected: Public only for classes or subclasses in the same package

3). Private: Not public, only within the object's internal access, the lowest access level

4). Default: Public only for classes in the same package

Two principles of Encapsulation (approximate):

1. Hide as many things as possible and provide a simple interface to the outside.

The higher the system's package, the higher its relative independence, and the more convenient it is to use.

2. Hide all the attributes

If a property is allowed to be accessed by the outside world, provide a public way to access the property

Why not define the volume property as the public type, so that the user can access it directly?

Reason:

1, more in line with the real world external causes through the internal cause of the objective law, the property of an object change should be the result of the interaction between external and internal causes

2. Be able to control the pronunciation of attributes and modify the internal access level flexibly. Some properties of an object are only allowed to be read by the consumer, but are not allowed to be modified by the user, but only for the object's internal changes

3. Prevent users from mistakenly modifying properties

4, help the object encapsulation implementation details Sometimes, if a property of an object changes, a series of practice reactions will occur within it, but these reactions are transparent.

JAVA Object-oriented programming--self-summary

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.