Java object-oriented

Source: Internet
Author: User

This article is excerpted from:

Java Basics

Object-Oriented Design Philosophy: Consider

1. What objects and classes are involved in the problem domain?

2. Methods and attributes of classes and objects

3. Relationships between objects, classes, and classes

 

Concepts of objects and Classes

Object: The description of the thing in the problem domain in computer language. The object uses attribute (static) and method (dynamic)

State) to distinguish things

Class: an abstract concept used to describe objects of the same class. Class defines the static

State and dynamic attributes

A class can be seen as a template of an object, and an object can be seen as a specific instance of a class.

 

Relationships between classes (objects)

Association relationship: the parameters of methods in a class are often another class. This is the weakest link.

Inheritance relationship: the relationship between XX is a YY. Indicates that xx inherits from YY. For example, if Golden Monkey is an animal

Is an inheritance relationship.

Aggregation: XX is a part of YY. The head is a part of a person, and the hand is a part of a person. Aggregation (loose coupling ):

The relationship between the captain and the team. Combination: the two are an inseparable part. The head belongs to a person and cannot be a brain

The bag belongs to both a person and that person.

Implementation relationship: the relationship between interfaces and implementation classes. For example, for the Shanghai class, there can be a lot of steps for this method.

Methods, such as driving and driving.

 

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.