Java Layering Concepts (RPM)

Source: Internet
Author: User

Layout:default
Title:java layering concept (RPM)
Category: [Technology, Java, code Learning]
Comments:true
---

Java Layering Concepts (RPM)

For the concept of layering, seems to be a simple three layers, more, it is a bit difficult to distinguish, so the collection of this.

Ervice is the business layer action layer that is used as the controller DAO (data access Object) to access 1. What is the function of the action layer, service layer, modle layer and DAO layer in Java? (the service layer described below is biz)
  首先这是现在最基本的分层方式,结合了SSH架构。modle层就是对应的数据库表的实体类。

The DAO layer uses Hibernate to connect to the database, to manipulate the database (add and revise).

Service (Biz) layer: Refers to the corresponding DAO database operation, where you can write your own code (such as simple judgments).

Action layer: refers to the corresponding service (BIZ) layer, where the combination of struts configuration file, jump to the specified page, of course, can also accept the page to pass the request data, can also do some calculation processing.

All of the above hibernate,struts need to be injected into spring's configuration file, and spring links these together to become a whole.

Other answers:
General Java is a three-tier architecture data Access Layer (DAO) Business Logic Layer (biz or services) interface layer (UI)
Action is part of the business layer and is a manager (the main switch) (the function is to reverse) (take out the foreground interface data, call the Biz method, forward to the next action or page)
The model is generally a physical object (which turns the real thing into an object in Java) is a temporary storage of data for easy persistence (in a database or write to a file) but rather as a package to encapsulate some data to use in different layers and various Java objects
DAO is the data access layer is used to access the database to implement data persistence (the memory of the data persisted to the hard disk other answers:
Action is a controller DAO primarily does the interactive work of the database modle is the model to store your entity class Biz to do the corresponding business logic processing

What is the difference between the DAO layer and the Biz layer in 2.java?

The

First explains the meaning on the surface, the service is the business layer, and DAO is the data access layer.
Hehe, this question I have also had, remember before just learn programming time, are in service directly call Dao,service inside on new A DAO class object, call, other meaningful thing did not do, also do not understand have this have what use, attend work long after will know, Business is the most serious work.
We all know that the standard mainstream is now programmed using the MVC Integrated Design pattern, MVC itself is not part of the design pattern, it describes a structure, the ultimate goal of decoupling, decoupling means that you change a layer of code, does not affect my other layer of code, If you would like the framework of spring, you will understand interface-oriented programming, the presentation layer calls the control layer, the control layer calls the business layer, and the business layer calls the data access layer. Initially it may be new object to call the next layer, such as you in the Business Layer new DAO class object, call the DAO class method to access the database, it is wrong to write, because in the business layer should not contain concrete objects, can only have a reference, if there is a concrete object exists, it is coupled. When that object does not exist, I also want to modify the code of the business, which is not logical. Like the motherboard on the memory is broken, I change memory, there is no need to change the motherboard together. I do not need to know which production memory is, do not know how much capacity, as long as the memory can be plugged into this interface to use. This is the meaning of MVC. Next say you feel the meaning of service, in fact, because you are now doing things layered is not so strict, in a you do something business itself is also less, for the simplest example, you do a paging function, data 1000, you 20 in a page, you can put this function as a tool class package up, Then call this encapsulation method in the business layer, this is the real job in the business, as long as no access to the database, it should be written in the business.
again have not understood the cross-examine, this is the experience question, hehe, actually later you will understand. Just started to write the code is a request, I went to the database fetch, business almost no.

Other excellent answers:
Rather than saying that you are using the SSH framework now, make a user module:
(1), assume that now you do this function will use the user table and the permission table, then your front page access action,action to call the User module service, User module service to determine whether you are operating the user table or permission table, If you are working with the user table, the service implementation class will call Userdao. If you are manipulating a permission table, invoke the right of the DAO
(2), that is, DAO must be corresponding to each table one by one of the database, and the service is not. You got that? Actually you a project a service and a DAO actually also can operate the database,

It's just that if there's a lot of problems, it's a lot of trouble, and it's too messy.

(3), the advantage is that your entire project is very systematic, and the database table can be consistent, and functional modularity, so that later maintenance or error is easier to change, performance is also higher
In short, DAO layer is dealing with database, service layer is dealing with some business process,
As for why you're talking about using service layer encapsulation, I think: In general, some of the business processes of a program need to connect to the database, some do not need to deal with the database and directly is some business processing, so that we need to integrate into the service, This can play a better role in development and maintenance, but also is the embodiment of the model layer function in the MVC design pattern

What is the action in 3.java and what is DAO?

The action class is [the class that obtains the form form data and processes the logic]
DAO (Data Access Object) is an interface implementation of [a session that obtains an operational database through Sessionfactory, and implements some basic deletions to add modified data to more practical business operations in the servlet]

4. What is the Pojo class?

A simple Java object (Plain old Java Objects) is actually a common JavaBeans, and the Pojo name is used to avoid confusion with EJBS, and the abbreviation is more straightforward. Some of these properties and their getter setter methods can sometimes be used as value Object or a DTO (Data Transform object). Of course, if you have a simple arithmetic attribute is also possible, but not allowed to have a business method, There is no way to carry a connection or something.

What are the 5.pojo classes and VO classes respectively?
vo有两种说法,一个是viewObject,一个是valueObject..

Take the former for example, it is only responsible for encapsulating the data passed over the page, which is somewhat different from the PO.

Take Struts1 For example, Actionform is a typical viewobject. And Valueobject is the object that holds the value when the page is passed between pages ....

In general, the PO is the thing that eventually passes to Bo and Bo to pass a DAO, and in many cases it corresponds to our real database table.

And ViewObject is the data submitted on a page, not necessarily the same as the PO properties ....

The difference between Pojo and DTOs

Ational the abbreviation for Mapping (Object Relational mapping). The popular point is that the object is bound to the relational database, and the object is used to represent the relational data.
In the world of O/R mapping, there are two basic and important things to understand, namely Vo,po.
VO, a Value object, a PO, a persistent object (Persisent objects) that consists of a set of properties and properties of the get and set methods. Structurally, they are nothing different. But it is completely different from its meaning and nature.

1. Vo is created with the New keyword and collected by the GC.

The PO is created when new data is added to the database, and the data in the database is deleted. And it can only survive in a database connection, and the disconnection is destroyed.

2. Vo is a value object, the precise point is that it is a business object, is living in the business layer, is used by business logic, it is the purpose of survival is to provide a place for the data to survive.

The PO is stateful, and each property represents its current state. It is the object representation of the physical data. Using it, we can decouple our programs from physical data and simplify the transformation between the object data and the physical data.

3. Vo's properties are different depending on the current business, that is, each of its properties corresponds to the name of the data needed for the current business logic.

The properties of the PO correspond to the field one by one of the database table.

# PO objects need to implement serialization interfaces.

A PO is a persisted object that simply represents an object of the physical data entity and why does it need it? Because it simplifies our understanding and coupling to physical entities, simply speaking, you can simplify the programming of object data into physical data. What is VO? It is a value object, accurately speaking, it is a business object, is living in the business layer, is the business logic needs to understand, need to use, and then simply, it is the conceptual model of the transformation obtained.
First of all, the Po and Vo, their relationship should be independent of each other, a VO can be just a PO part, also can be a number of PO composition, the same can also be equated to a PO (of course I refer to their attributes). Because of this, the PO is independent, the data persistence layer is independent, it will not be interfered by any business. Because of this, the business logic layer is also independent, it will not be affected by the data persistence layer, the business layer is only concerned about the business logic processing, as to how to save how to read to others! However, another point, if we do not use the data persistence layer, or do not use Hibernate, then Po and VO can also be the same thing, although this is not good.

Java's (Po,vo,to,bo,dao,pojo) explanation
  • PO (Persistant object) Persistent object
    The concept that occurs at the O/R mapping, without the O/R mapping, does not exist. Usually the corresponding data model (database), itself also has some business logic processing. Can be seen as a Java object mapped to a table in the database. The simplest PO is a record in a table in the corresponding database, and multiple records can be used with a collection of PO. The PO should not contain any operations on the database.

  • VO (Value object) value objects
    Typically used for data transfer between business tiers, as is the case with PO, which contains only data. But it should be abstracted out of the business object that can correspond to the table, or not, depending on the needs of the business. Personally feel the same DTO (data transfer object) that is passed on the web.

  • to (Transfer object), data transfer object
    Objects that are transferred between different tie (relationships) in the application

  • BO (business object) service object
    From the business model perspective, see the domain objects in the UML component Domain model. A Java object that encapsulates the business logic, by invoking the DAO method and combining Po,vo for business operations.

  • POJO (Plain ordinary Java object) simple, rule-free Java objects
    Java objects that are purely traditional in meaning. In some object/relation mapping tools, the Persisent object that maintains database table records is a pure Java object that conforms to the Java Bean Specification and does not add other properties and methods. My understanding is the most basic Java Bean, only attribute fields and setter and getter Method!.

  • DAO (data Access object) Access objects
    is a sun's standard Java EE design pattern, which has an interface that is DAO, which has negative persistence layer operations. Provides interfaces for the business layer. This object is used to access the database. Usually used in conjunction with PO, DAO contains various methods of operation of the database. Through its method, combine the PO to carry on the related operation to the database. Sandwiched between business logic and database resources. With VO, provide database crud operations ...

  • O/R Mapper object/relationship Mapping
    After defining all the mapping, this O/R mapper can help us do a lot of work. With these mappings, this O/R mapper can generate all the SQL statements about the object save, Delete, read, and we no longer need to write so many lines of DAL code.

Entity model (solid mode)
DAL (data access Layer)
Idal (interface layer)
Dalfactory (class factory)
BLL (business logic Layer)
BOF business Object Framework service objects Frame
SOA Service Orient Architecture Services-oriented design
EMF Eclipse Model Framework Eclipse Modeling Framework

    • PO: Full name is
      Persistant Object Persistent Objects
      The most vivid understanding is that a PO is a record in the database.
      The advantage is that a record can be processed as an object and can be easily converted to other objects.

    • BO: The full name is
      Business object: Operational objects
      The main role is to encapsulate the business logic as an object. This object can include one or more other objects.
      such as a resume, education experience, work experience, social relations and so on.
      We can have an education experience corresponding to a PO, work experience corresponding to a PO, social relations corresponding to a PO.
      Create a CV-based Bo object to process resumes, each BO containing these po.
      When we handle business logic like this, we can deal with Bo.

    • VO:
      Value Object Value objects
      ViewObject Presentation Layer Objects
      The data object that the main interface displays. For a Web page, or an interface for SWT and swing, use a Vo object to correspond to the value of the entire interface.

    • Dto:
      Data Transfer Object Data transfer objects
      It is mainly used for remote calls, etc. where large quantities of objects need to be transferred.
      For example, if we have 100 fields in a table, then the corresponding PO has 100 attributes.
      But we just show 10 fields on the interface,
      The client uses the Web service to get the data, and there is no need to pass the entire PO object to the client.
      At this point we can pass the result to the client with a DTO with only these 10 attributes, and this will not expose the service-side table structure. After the client is reached, if the interface is displayed with this object, then its identity will be converted to VO.

    • Pojo:
      Plain ordinary Java object simple Java objects
      Personal feeling Pojo is the most common and changeable object, is an intermediate object, is also our most often dealing with objects.

A Pojo is a PO after persistence
It is the DTO that passes and passes directly through it.
Directly used to correspond to the presentation layer is VO

    • DAO:
      Data Access Object Information
      This everyone is most familiar with, and the above several o the biggest difference, basic without the possibility and necessity of mutual transformation.
      Primarily used to encapsulate access to a database. It can be pojo to the PO, with PO assembled VO, DTO
    • The Po:persistant object is persisted as a Java object that is mapped to a table in the database. The simplest PO is a record in a table in the corresponding database, and multiple records can be used with a collection of PO. The PO should not contain any operations on the database.

    • The Vo:value object value. Typically used for data transfer between business tiers, as is the case with PO, which contains only data. But it should be abstracted out of the business object that can correspond to the table, or not, depending on the needs of the business. Personally feel the same DTO (data transfer object) that is passed on the web.

    • Dao:data Access object that is used to access the database. Usually used in conjunction with PO, DAO contains various methods of operation of the database. Through its method, combine the PO to carry on the related operation to the database.

    • Bo:business object, which encapsulates the Java object of the business logic, invokes the DAO method and combines po,vo for business operations;

    • Pojo:plain ordinary Java object Simple, non-regular Java objects, I personally think it and other not a level of things, Vo and Po should belong to it.

    • VO: Value object, view object
    • PO: Persistent Object
    • QO: Querying objects
    • DAO: Data Access Object
    • DTO: Data Transfer Object
    • The actionform in struts is a VO;
    • The entity Bean in Hibernate is a PO, also called Pojo;
    • The criteria in hibernate is equivalent to a qo;
    • When using hibernate, we define some methods of querying, which are written in the interface and can have different implementation classes. And this interface can be said to be a DAO.
      Personally think Qo and DTOs are similar.
      ----------------------------------------
    • Po or bo, the closest layer to the database, is an ORM O, basically a database field corresponding to a property in Bo, for synchronization and security considerations, it is best to give DAO or service calls, rather than using Packcode,backingbean, or Bo tune.
    • DAO, the data access layer, the object in the Vo,backingbean can be put into ....
    • DTOs, seldom used, are basically put into DAO, but play a role in transition.
    • QO, is to put some with persistent query operations with the statement into the.
    • The basic elements and methods used in the VO,V layer are placed therein. If you want to call Bo, do the Bo conversion vo,vo convert Bo operation. Vo's advantage is that its page element attributes more than Bo, can play a very good role ....
    • It's not right upstairs, PO is a persistent object. Bo=business object-business object.
    • The PO can be strictly corresponding to the database table, and a single PO is mapped to a table.
    • Bo is the business logic processing object, my understanding is that it is filled with business logic processing, in the business logic of complex applications to be useful.
    • Vo:value Object value objects, view object views
    • PO: Persistent Object
    • QO: Querying objects
    • DAO: Data Access Object--also DAO mode
    • DTO: Data Transfer Object-also DTO mode
Refer to the Blog

[Java] Java Layering Concept (EXT)-1iqueen-Blog Park
Https://www.cnblogs.com/lkboy/p/4210742.html

Java Layering Concepts (RPM)

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.