Web architecture: MVC, lazy initialization, data transfer objects, an open In View session, is there a single approach?

What disadvantages do you see in the next design (and what will be your ideal architectural proposal) for a typical three-tier web application?

My current approach to the project is very rude (assuming Java, Spring, Hibernate, JSP)


Controller

Standing, potentially wrapped in a read-only transaction (to avoid lazy initialization exceptions), get entities from the persistence store only through the service, passes them to the view as a model. Conducts business logic on them (should BL be located only in the service layer?), If necessary, return to the service level for saving.

The benefits . For a read-only transaction, there is only one connection, the absence of redundant hits for the same persistent object, it makes better use of the query cache, the service level should not “know” the request parameters or init is required, avoid lazy initialization exceptions.

Cons . A read-only transaction approach can be risky, controllers are not an ideal place for business logic ... it is very difficult to make JUnits (your input is a request ...)


View

Non-transactional (access to non-lazy collections / members will result in a lazy initialization exception)

Pros :

  • The author of the review should not only influence the point notation of application performance (for example, the reason N + 1 is chosen because of the lazy initialization of a large collection.

  • (Flex Rich ) , .

: //DAO ()/ ( ). , ,


Model

( ), .

: POJO, , , .

: , , , , .


Transactional, , DAO . , BL , , , BL .


DAO

, BL,


, :

?

( ), ( , ..)? , , - ( )?

? POJO ? beans ( )?

, , , , "".

+3
4

, . , Martin Fowlers, .

, , . , , , , , .

, . Martin Fowlers " " , . , .

+3

Super, SOFEA, .

, REST SOAP, JSON XML. , , 100% !!!!

, , N-, , .

N- . DTO , . ( IMO) DTO - , -. View , - .

, , , - . , - -. , , .

( Struts 1.2) -. , , - . , !!!!

SOFEA, -, . AJAX -, , , MVC, ( ) ( MVC).

-. GUI ? - .

SOFEA/SOUI , , , , .

+2

.

, UI- Beans. , UI- Bean . , ( ) .

:


class UIBean {
  DomainObject o;

  public String getDescription(){
     return trimToSummaryText(o.getDescription());
  }

  private static String trimForSummaryText(){
     ....
  }
}

:

  • . Frontend-Developer .
  • , , .
  • beans (ui- Bean ). .

, java-. , - .

+1

, , , -. , , : (, View Service) UiBean-s, DTOs ( ), POJO //.

/ Java EE spec "DTO" "ValueObject", .

, .

0