What is JavaBean? What is its function?

What is JavaBean? What is its function?

definition:

JavaBean is a reusable component written in JAVA language. To be written as a JavaBean, the class must be concrete and public, and have a parameterless constructor. JavaBean exposes the member properties of internal domains by providing public methods that conform to the consistent design pattern, and obtains them with set and get methods. As we all know, attribute names conform to this pattern, and other Java classes can discover and manipulate the attributes of these JavaBeans through the introspection mechanism (reflection mechanism). JavaBean can be divided into two types: one is a JavaBean with a user interface (UI, User Interface); the other is a JavaBean without a user interface, which is mainly responsible for processing transactions.

Features:

Basically, JavaBean can be seen as a black box, that is, a software device that only needs to know its function without having to care about its internal structure. The black box only introduces and defines its external features and interfaces with other parts, such as buttons, windows, colors, shapes, handles, etc. By treating the system as a communication network connected by a black box, we can ignore the system details inside the black box and effectively control the overall performance of the system.

Composition:
(1) Properties In JavaBean, properties are not just properties in the traditional object-oriented concept, they are also supported by APIs for property reading and property writing. The property value can be carried out by calling the appropriate bean method.
(2) Method (method) By default, all public methods of beans can be called externally, but beans generally only lead to a subset of their public methods.
(3) Event (event) The main way for Bean to exchange information with other software components is to send and receive events. We can think of the event support function of the bean as the input and output pins in the integrated circuit: engineers connect the pins together to form a system, allowing the components to communicate. Some pins are used for input and some pins are used for output, which are equivalent to sending events and receiving events in the event model.

Function:
Used to pass values. For example, attributes such as user name, password, gender, and age can be encapsulated into a class, and then it can be called directly. Instead of using a lot of parameters when passing values.

Usage scenarios: VO, POJO, TO, etc.

Guess you like

Origin blog.csdn.net/giantleech/article/details/114573385