Understanding Poco

Source: Internet
Author: User
Keywords Java poco understanding means
Tags address business business logic developers different it is java name

Understand Poco first to understand Pojo
1, what is Pojo
Pojo has a variety of names, pure old Java object, plain ordinary Java object, and so on.
According to Martin Fowler, "Plain old Java object" is literally translated as "pure old-fashioned Java objects," but everyone uses "simple Java objects" to address it.
The intrinsic meaning of Pojo refers to those Java objects that do not inherit from any class, do not implement any interfaces, and are not invaded by other frameworks.
The concept of Poco is borrowed from the Java Pojo, and the meaning of the two is consistent, and the different languages are used only differently. So Poco's explanation is "Plain old C # Object".
2. Why are there Pojo?
Mainly Java developers are the complexity of the EJB fear, we have to rethink, and return to the "pure old-fashioned" javabean, that is, there is no parameter constructor, each field has getter and setter Java class.
3, the significance of Pojo
Pojo allows developers to focus on business logic and unit testing out of the framework. In addition, because Pojo does not need to inherit the framework's classes or implement its interfaces, developers are able to build inheritance structures and build applications with great flexibility.
The meaning of Pojo is its simplicity and flexibility, because it is simple and flexible, so that pojo can arbitrarily expand, so competent for many occasions, but also let a model across multiple layers to become a reality.
First write a core Pojo, and then implement the business logic interface and persistent interface, it becomes domain Model, when the UI needs to be used, it implements the data binding interface, becomes VO (View Object).
4, Pojo and Po, vo difference
Pojo refers to simple Java objects (Plain old Java Objects, pure old Java object, or Plain ordinary Java).
A PO refers to a persistent object (Persistant object persistence).
Vo refers to a value object or a View object (Value object, view objects). Note that the VO in this article refers specifically to view Object.
The persistent object must actually correspond to the entity in the database, so it differs from the Pojo. For example, Pojo is created by new and collected by GC. However, the persistent object was created by the Insert database and deleted by the database delete. Basically, the persistence object lifecycle is closely related to the database. In addition, persistent objects can often only exist in a database connection, connnection closed, persistent objects do not exist, and Pojo as long as not be GC recovery, always exist.
Because there are so many differences, the persistent object Po (persistent object) is definitely different from Pojo in code, and at least the PO will add some properties and methods for managing the entity state of the database relative to Pojo. And Orm pursuit of the goal is to PO in use as far as possible and pojo consistent, for programmers, they can use the PO as a pojo, and feel the existence of PO.
5, Pojo expansion
Pojo contains only the simplest field attributes, nothing superfluous, and it is essentially an ordinary javabean.
But on the basis of Pojo, different objects can be extended.

Adds a method of persistence for Pojo (Insert, Update, Delete ...). After that, Pojo became a PO. After adding data binding to Pojo, Pojo becomes view Object, UI Model. Ways to increase business logic for Pojo (such as document Review, transfer ...) After that, Pojo became domain Model. Pojo can also be used as a dto.
Related Article

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.