CodeWeblog.com » business logic,open source software,focus on business » Struts, Spring, Hibernate advantages and disadvantages

Struts, Spring, Hibernate advantages and disadvantages

Struts, Spring, Hibernate advantages and disadvantages
Struts with Tomcat, Turbine, and many other Apache projects, are open-source software, which is its one great advantage. Allow developers to more in-depth understanding of its internal mechanisms for implementation. Struts open source framework is created in order to allow developers to build at based on Java Servlet and JavaServer Pages (JSP) technology, Web applications easier. Struts framework will provide an open standard framework, through the use of Struts as a foundation, developers can focus more on application business logic. Struts framework itself is to use the Java Servlet and JavaServer Pages technology, a Model-View-Controller (MVC) implementation.
Specifically,
Has the advantages of Struts:
1. Realize MVC pattern, structure, clarity, so that developers focus on business logic implementation.
2. There is a wealth of tag can be used, Struts Tag Library's (Taglib), such as the flexibility to spend, you can greatly improve development efficiency. In addition, the current domestic JSP developers, apart from the use of commonly used built-in JSP tag, very few develop its own tag, perhaps Struts are a good starting point.
3. Page navigation. Page navigation will be a future direction of development, in fact, to do so, allowing the system to the context more clearly. Through a configuration file, you can grasp the entire system between the various parts of the contact, which the latter has an immense amount of good maintenance. Especially when another group of developers to take over the item, the embodiment of this advantage may become more pronounced.
4. Exception handling mechanisms provided.
5. Database link pool management
6. Supporting I18N
Disadvantage:
First, go to display layer, need to configure forward, each time to the show floor, I believe most of them are directly to the jsp, which involves the shift, need to configure forward, if there are ten display layer jsp, need to configure the ten second struts, and does not include some directory, file changes, modifications need to re-forward, note that each modified configuration, the request to re-deploy the entire project, while tomcate such a server, it is also necessary to restart the server, if the business changes frequently complex systems, such as simple unimaginable. Now is the case, dozens of hundreds of individuals at the same time online using our system, everyone can imagine, I have little trouble.
Two, Struts in Action is necessary to thread-safe manner, it is merely an example of permit to deal with all requests. Action so used all the resources necessary for a unified synchronization, this would cause a thread safety problem.
Three test inconvenient. Struts each Action are coupled together with the Web layer so that it depends on the test Web containers, unit testing is also difficult to achieve. But there is a Junit extension of the instrument can Struts TestCase implementation of its unit tests.
Four, types of conversion. Struts put the FormBean all data as String type, it can use the Commons-Beanutils instrument for the type of transformation. But its transformation is at Class level, but also the type of transformation can not be configured. Type conversion error when the information back to users is also very difficult.
Friday, the dependence on the Servlet too. Struts must deal with when Action need to rely on the ServletRequest and ServletResponse, all it could not shake off their Servlet container.
Six, the front of the expression language. Struts integrates JSTL, so it is mainly the use of JSTL expression language to access data. But the JSTL expression language in the Collection and property aspects of the index appears to deal with very weak.
Seven of Action to implement the control difficult. Struts create an Action, if it want to control the implementation of the order would be very difficult. Even you want to go to Writing Servlet you achieve the functional requirements.
Eight of Action prior to and after treatment. Struts deal when Action is based on the class of hierarchies, it is very difficult in the action before and after treatment instructions.
Nine, not enough to support the case. In the struts, the actual form is a Form corresponding to a Class Action (or DispatchAction), In other words: In the Struts actually are a form can only correspond to a case, struts this case means that for the application event, application event and component event is compared to a coarse-grained case.

Struts important ActionForm form object is an object, it represents an application, this object contains at least some fields, these fields are jsp page form input field, because a form corresponding to a case Therefore, when we need to be refined to form particle case these fields, that is, a field corresponding to a case, the simple use of Struts unlikely, of course, through a combination of JavaScript can also turn the implementation .
2. Hibernate
Hibernate is an open source object-relational mapping framework, it had a very lightweight JDBC object package so that Java programmers can use arbitrary objects to manipulate database programming thinking.
Hibernate can be applied to any use of JDBC occasion, either in the Java-client program useful, you can at Servlet / JSP in Web applications, are the most revolutionary, Hibernate can be in the application of EJB in the J2EE architecture to replace the CMP to complete the important task of data persistence.
Most development agencies often take to create their own independent data persistence layer. Once the underlying data structures change, then modify the application to adapt the rest of the cost of such a change will be very enormous. Hibernate timely fill this gap, it provides a Java application-to-use, efficient object-relational mapping framework. hibernate is a lightweight persistence framework, it is very rich in features.
Advantages:
a.Hibernate the use of Java reflection mechanisms rather than byte-code enhancement procedures to achieve transparency.
b.Hibernate performance is very good, because it is a lightweight framework. Mapping the flexibility is excellent.
c. It supports a variety of relational database, from one-on-one to many-to-many relationship between the various and complex.
Disadvantage: it limits the use of your object model. (For example, a persistent type should not mapped to multiple tables) of its unique interface and poor market share also makes people uneasy, in spite of this, Hibernate or the development of its powerful reducing the power of these risks. Other open source persistence framework also has some, but have not Hibernate so there is market impact.

Posted above sentiment a bit agitated, hope of understanding, I do not criticize someone because Hibernate are unhappy, but because there's Posts opinion really makes me feel ridiculous. Whether you think that Hibernate is also good, not good also, I only regret that, at English forum inside the Hibernate can not find a really high level of evaluation. At TSS, there is a Hibernate about the hot thread, with hundreds of stickers, including Hibernate and LiDO JDO author Gavin's CTO, for JDO and Hibernate have had some heated arguments, I once again read the patient is still not found Hibernate really strong against the attacks, the so-called attacks against Hibernate simply does not have a GUI configuration tool, there is no commercial company support, there is no standardization and so on such flimsy grounds.
To add a few of my observations:
First, Hibernate is a lightweight JDBC object package, it is an independent object persistence layer framework, and the App Server, and EJB Nothing contact inevitable. Hibernate can use JDBC can be used at any occasion, such as Java applications, database access code, DAO interface implementation class, or even access the database inside the BMP code. In this sense, Hibernate and EB is not a scope of things, there was no relationship between one or the other.
Two, Hibernate and JDBC are a closely related framework, so Hibernate compatibility and JDBC drivers, and databases must have a relationship, but it's Java and the use of procedures, and the App Server has no relationship, there was no compatibility problem .
Three, Hibernate should not be used to direct and to do Entity Bean contrast, only on the framework of the entire J2EE project can be compared. And even on the software in terms of the overall framework, Hibernate is also used as a substitute for JDBC appear, rather than substitute for Entity Bean appears, so I make the list once I have set out the framework of the structure of n times:
Traditional architecture:
1) Session Bean <-> Entity Bean <-> DB
Performance in order to solve the obstacles to alternative architecture:
2) Session Bean <-> DAO <-> JDBC <-> DB
Use Hibernate to improve the efficiency of the above architecture the development of the architecture:
3) Session Bean <-> DAO <-> Hibernate <-> DB
3 on the above architecture to analyze:
1, memory consumption: the use of JDBC architecture of 2 is undoubtedly the most provincial of memory, Hibernate Architecture of 3 times, EB architecture one of the worst.
2, operating efficiency: If the JDBC code written in a very optimized, then the JDBC architecture to run the most efficient, but the actual project, it is almost impossible, which required a very proficient programmer JDBC, use Batch statement PreapredStatement adjust the Batch Size and Fetch Size and other parameters, and where necessary the use of result set cache and so on. And under normal circumstances are not programmers this. Hibernate Architecture therefore show the fastest operating efficiency. EB's efficiency would be bad architecture very much.
3, the development of efficiency: at JBuilder has the support of the project, as well as easy, EB to develop the most efficient architecture, JDBC times, Hibernate worst. However, in large projects, especially the relationship between persistence layer mapping very complex circumstances, Hibernate efficient amazing, JDBC times, while the EB architecture are likely to fail.
4, distributed, security check, clustering, load balancing support because there is SB as a Facade, 3个architecture there is no difference.
Four, EB and Hibernate difficult to study where?
Where is the difficulty of EB? Not complex XML configuration files on, but slightly careless use of EB, there are serious obstacles to performance. So you need to study hard at a lot of EJB design patterns to avoid the performance problem, need to learn App Server and EB configuration to optimize the operational efficiency of EB. EB to do the development work, programmers have been on most of the energy performance of the EB on the problem, but there is no more energy to care for their input on the main effort to take into account the design of object persistence layer up.
Difficulties in Hibernate? Hibernate itself is not complicated, in fact very easy Hibernate, it is difficult at Hibernate too flexible.
When you use EB to achieve persistence layer, you will find that EB is too clumsy, and awkward to you Nothing can simply select the room, so you do not need to spend energy to design programs to balance the good and bad, go fee brains to consider choice of option, because only the only program in front of you before, you can only do so, they can not select.
Hibernate the contrary, it is too flexible, the same problem, can you at least a dozen programs designed to solve, so special to stir up troubles, what with this, or was it used? These programs have in the end What's the difference between them? Their operating principle What is the difference? Operating efficiency which is better? Just the primary key generation, there are 78 kinds of programs you select, you do not embarrass embarrassed? Collection of property can be used Set, can be used List, can also use Bag, which in the end high efficiency, you do not embarrass embarrassed? Inquiries can be used iterator, can list, which well, What is the difference? Make things difficult for you not embarrassed? Composite primary key you can configure it directly in the HBM can also be custom CustomerType, which is somewhat better? Make things difficult for you not embarrassed? For a table, you can select a single mapping an object, but also father and son can be mapped into the object, but also can be mapped 1:1 into the object of both, under what circumstances in which the program is better, you do not embarrass embarrassed?
This list could have been set out until you do not want to go on looking at so far. When you have before them a dazzling myriad of programs, you will feel happy then? Or sad it? If you are a responsible programmer, then you must carefully study the difference between each program, the efficiency of each program, each program of application of occasions, you will feel that you have entered into a drawing does not come out. If you are using EB, the first seconds you already made the decision, did not have to select, for example, a collection property, you can only use Collection, if it is Hibernate, you will be at Bag, List and Set back and forth between not hesitate summary, or even not sure if there is no way to write programs.
3. Spring
It is an open source project, and currently very active; It is based on IoC (Inversion of Control, inversion of control) and the AOP framework of multi-layer system framework j2ee, but it does not force you to be at every level must be used in Spring because it is a good modular, allowing you to choose according to their own needs to use it to a module; it is a very elegant implementation of the MVC, the different data access technology to provide a unified interface, using IoC can easily make the bean implementation of assembly, provided a concise and, accordingly AOP implementation Transcation Managment, and so on merits:
a. Spring can effectively organize your middle tier objects, regardless of whether you choose to use the EJB. If you only Struts or other use of the API for the J2EE special framework, Spring to address the remaining questions.
b. Spring can eliminate the common lot of projects on the excessive use of Singleton. In my experience, this is a big problem, it reduces the system testability and object-oriented level.
c. through a different application and projects consistent approach to deal with configuration files, Spring can eliminate a wide variety of custom property file format required. Once on a category to find what are the magic-like system property or property they did not understand why this had to read Javadoc or even source code? With Spring, you only need to look at the type of JavaBean property. Inversion of Control of the use (discussed below) to help achieve this simplification.
d. put on the interface through programming rather than on the type of programming is almost reduced to the cost of NOT, Spring can promote the develop good programming habits.
e. Spring is designed to allow applications to use it to create as small as possible dependent on his APIs. Spring applications at most business object does not depend on Spring.
f. the use of Spring applications built unit testing easier.
g.Spring enable the use of EJB implementation to become a choice rather than an inevitable choice for the application architecture. You can choose to use local EJBs or POJOs to achieve business interface, but will not affect the calling code.
h. Spring assist you to solve many problems without the use of EJB. Spring can provide a replacement EJB objects, they apply to many web applications. For example, Spring can use AOP to provide declarative transaction management rather than through the EJB container, if you only need to deal with a single database, or even do not need a JTA implementation.
i. Spring data access to provide a coherent framework, whether it is using JDBC or O / R mapping products (such as Hibernate).
Spring can really make you the most simple and feasible solution to solve your problem. And this is there is there is great value.
Disadvantage:
The use of a small number, jsp in to write a lot of code, the controller is too flexible, the lack of a common controller.
Digg Technorati StumbleUpon Mixx del.icio.us Reddit BlinkList Furl YahooMyWeb feedburner

Tags: business logic (RSS), open source software (RSS), focus on business (RSS), tag library (RSS), logic implementation (RSS), development efficiency (RSS), exception handling (RSS), database link (RSS), model view controller (RSS), java servlet (RSS), javaserver pages technology (RSS), jsp technology (RSS), internal mechanisms (RSS), open source framework (RSS), apache projects (RSS), pool management (RSS), pattern structure (RSS), good starting point (RSS), application business (RSS), page navigation (RSS)

Permalink: http://www.codeweblog.com/struts-spring-hibernate-advantages-and-disadvantages/

Leave a reply