The pros and cons of Struts Hibernate and Springframeworks.docx
《The pros and cons of Struts Hibernate and Springframeworks.docx》由会员分享,可在线阅读,更多相关《The pros and cons of Struts Hibernate and Springframeworks.docx(8页珍藏版)》请在冰豆网上搜索。
TheprosandconsofStrutsHibernateandSpringframeworks
TheprosandconsofStruts,Hibernate,andSpring3frameworks
Thestrutsframeworkhastheadvantagesofmodularity,flexibilityandreuse,whilesimplifyingthedevelopmentofMVCbasedwebapplications.
Advantages:
Struts,likemanyApacheprojectssuchasTomcatandTurbine,isopensourcesoftware,whichisoneofitsgreatadvantages.Enabledeveloperstolearnmoreabouttheirinternalimplementationmechanisms.
Beyondthat,thebenefitsofStrutsareprimarilyfocusedontwoaspects:
theTaglibandthepagenavigation.TheTaglibisataglibraryforStrutsthatisflexibleenoughtogreatlyimprovedevelopmentefficiency.Inaddition,asfarasthecurrentdomesticJSPdevelopersareconcerned,itisveryraretodevelopyourowntagsinadditiontothecommonlyusedtagsbroughtinbyJSP,andperhapsStrutsisagoodstartingpoint.
Asforpagenavigation,Ithinkthat'sgoingtobeadevelopmentinthefuture,infact,tomakethecontextofthesystemclearer.Byusingaconfigurationfile,youcangrasptheconnectionbetweenthepartsofthesystem,whichisofgreatbenefittolatermaintenance.Thisisespeciallytruewhenanotherdevelopertakesovertheproject.
Inaddition,strutsisanindustry"standard"(manysuccessfulcases),richinlearningresources,andexcellentHTMLtags
Disadvantages:
TaglibisoneoftheadvantagesofStruts,butforbeginners,butneedaprocessofcontinuouslearning,canevendisruptyourwebpageinthehabitofwriting,but,whenyougetusedtoit,youwillfeelit'sreallygood.
StrutssplittheControllerofMVCintothree,addingtothecomplexityofthesystemwhilegainingclarity.
ActionFormsisnotusedforunittesting(StrutsTestCasecanonlybeusedforintegration)
Struts,likemanyApacheprojectssuchasTomcatandTurbine,isopensourcesoftware,whichisoneofitsgreatadvantages.Enabledeveloperstolearnmoreabouttheirinternalimplementationmechanisms.TheStrutsopensourceframeworkwascreatedtomakeiteasierfordeveloperstobuildWebapplicationsbasedonJavaservletsandJavaServerPages(JSP)technologies.TheStrutsframeworkprovidesaunifiedstandardframeworkfortheopen,whichallowsdeveloperstofocusmoreonthebusinesslogicoftheapplicationbyusingStrutsasafoundation.TheStrutsframeworkitselfisamodel-view-controller(MVC)implementationusingJavaservletsandJavaServerPagestechnology.
Specifically,theadvantagesofStrutsare:
ImplementtheMVCpattern,andthestructureisclear,allowingdeveloperstofocusontheimplementationofthebusinesslogic.
Richtagscanbeused,andtheStrutstaglibrary(Taglib),ifflexible,cangreatlyimprovedevelopmentefficiency.Inaddition,asfarasthecurrentdomesticJSPdevelopersareconcerned,itisveryraretodevelopyourowntagsinadditiontothecommonlyusedtagsbroughtinbyJSP,andperhapsStrutsisagoodstartingpoint.
Pagenavigationisgoingtobeadevelopmentinthefuture,infact,tomakethecontextofthesystemclearer.Byusingaconfigurationfile,youcangrasptheconnectionbetweenthepartsofthesystem,whichisofgreatbenefittolatermaintenance.Thisisespeciallytruewhenanotherdevelopertakesovertheproject.
ProvideExceptionhandlingmechanisms.
Databaseconnectionpoolmanagement
6.SupporttheI18N
A,gotodisplaylayer,needtoconfigureforward,everytimegototheshowlayer,thatmostaredirectlytransferredtotheJSP,andinvolvesturning,needtoconfigureforward,iftherearetenshowstheJSPlayer,needtoconfigurethestruts,tentimesanddoesnotincludedirectoryandfilechanges,sometimesneedtomodifytheforward,notethateverychangeconfiguration,requesttoredeploythewholeproject,andtomcatethisserver,alsohavetorestarttheserver,ifthebusinesschangecomplexfrequentsystem,suchassimpleoperationunthinkable.Nowthat'sit,dozensofpeopleareusingoursystemonlineatthesametime,andyoucanimaginehowbigmyworriesare.
TheActionofStrutsmustbethread-safe,whichallowsonlyoneinstancetohandleallrequests.SoalltheresourcesthatactionUSESmustbesynchronized,whichraisestheissueofthread-safety.
EachActionofStrutsiscoupledwiththeWeblayer,sothatitstestsdependontheWebcontainer,andunittestsaredifficulttoimplement.However,aJunitextensiontool,StrutsTestCase,canimplementitsunittests.
Four,typeconversion.Struts'sFormBeanUSESallthedataasaStringtype,whichcanbetransformedusingthetoolCommons-Beanutils.
ButitstransformationisattheClasslevel,andthetypeoftransformationisunconfigurable.Theerrormessagereturnedtotheuserisalsoverydifficult.
5,thedependencyonservletsistoostrong.StrutsneedstorelyonServletRequestandServletResponsetohandleAction,andallitcan'tgetridoftheServletcontainer.
Thefront-endexpressionlanguageaspect.StrutsintegratesJSTL,soitmainlyUSEStheexpressionlanguageoftheJSTLtogetthedata.However,theexpressionlanguageoftheJSTLisveryweakintheCollectionandindexproperties.
7,thecontrolofActionexecutionisdifficult.StrutscreatesanActionanditwillbeverydifficulttocontrolitsexecutionorder.YoumayevenwanttorewritetheServlettoimplementyourfunctionalrequirements.
Eight,toActionbeforeandaftertreatment.TheStrutsprocessingwhentheActionisbasedontheclasshierarchies,itisdifficulttooperatedinActionbeforeandafterprocessing.
Nine,supportforeventsisnotenough.Inthestruts,isactuallyaFormtheFormcorrespondingtoanActionclass(orDispatchAction),inotherwords:
inthestrutsisactuallyaFormcorrespondingtoanevent,onlythestrutsthiseventiscalledapplicationevent,applicationeventandcomponentcomparedtotheeventisacoarse-grainedevents.
Strutsimportantactionformsformobjectisanobject,itrepresentsakindofapplication,thisobjectcontainsatleastafewfields,thesefieldsaretheJsppageintheforminputfield,asaformcorrespondingtoanevent,sothatwhenweneedtorefinetheeventgranularitytoforminthefield,thatis,afieldcorrespondingtoanevent,simplyusetheStrutsisunlikely,ofcourse,bycombiningturnJavaScriptcanbeimplemented.
2.Hibernate
Hibernateisanopensourceobject-relationalmappingframework,itisverylightweightforJDBCobjectencapsulation,maketheuseofJavaprogrammerscanfollowone'sinclinationstomanipulatethedatabaseobjectprogrammingthinking.
Hibernatecanbeusedinanysituation,usingtheJDBCcanintheJavaclientprogram,practical,andcanalsobeusedintheServlet/JSPWebapplication,themostrevolutionarysignificanceisthatHibernatecanreplacetheCMPinEJBofJ2EEapplicationarchitecture,tocompletetheimportanttaskofdatapersistence.
Mostdevelopmentorganizationsoftenadoptdatapersistencelayersthatcreateseparatedata.Oncetheunderlyingdatastructurechanges,thecostofadaptingtherestoftheapplicationtothischangewillbeenormous.Hibernatedulyfillsthisgap,providinganeasy-to-use,efficientobject-relationalmappingframeworkforJavaapplications.Hibernateisalightweightpersistenceframeworkthatisrichinfunctionality.
Advantages:
A.h.ibernateUSEStheJavareflectionmechanisminsteadofthebytecodeenhancementprogramtoachievetransparency.
B.Hibernate'sperformanceisexcellentbecauseit'salightweightframework.Theflexibilityofmappingisexcellent.
Itsupportsavarietyofrelationaldatabasesfromone-to-onetomany-to-manycomplexrelationships.
Cons:
itlimitstheobjectmodelyouuse.(forexample,apersistenceclassescannotbemappedintomultipletables)itsuniqueinterfaceandpoormarketsharealsodisturbing,nonetheless,Hibernateorwithitspowerfulmomentumtomitigatetheserisks.Otheropensourcepersistenceframeworksalsohavesome,butnoneofthemhaveamarketimpactlikeHibernate.
Abovepostalittlepassion,inthehopethatunderstanding,IloveyounotbecauseofsomepeoplecriticizetheHibernateanduncomfortable,butbecauseofwhoIaminsidethepostviewreallymademefeelridiculous.NomatterwhatyouthinkofHibernateasagoodthing,theonlythingI'msorryaboutisthatyoucan'tfindareallyhigh-levelevaluationofHibernateintheChineseBBS.OnTSShasahotaboutHibernatethread,withhundredsofpaste,includingHibernateauthorGavinandLiDOJDOCTO,forJDOandHibernatehadsomeheatedargument,Ihavethepatiencetoseeitagain,stillhavenotfoundtoHibernatereallypowerfulattack,theso-calledattackjusttoHibernatewithoutaGUIconfigurationtool,nocommercialcompanysupport,notstandardized,andsoontheseuntenablereason.
HerearesomeSuggestions:
One,HibernateisthelightweightobjectencapsulationofJDBC,anindependentobjectpersistencelayerframework,andAppServer,whichisnotnecessarilyassociatedwithejbs.HibernatecanbeusedinanysituationwhereJDBCcanbeused,
Forexample,thedatabaseaccesscodefortheJavaapplication,theimplementationclassfortheDAOinterface,andeventhecodeforaccessingthedatabaseinBMP.Inthatsense,HibernateandEBarenotacategorything,andthereisnosuchthingasaneither/orrelationship.
Second,HibernateisacloselyassociatedandJDBCframework,HibernatecompatibilityandJDBCdriver,andthedatabasehasacertainrelationship,andtheJavaprogramthatUSESit,however,doesn'thaveanythingtodowiththeAppServer,thereisnocompatibilityproblems.
Hibernatecan'tbeusedtocomparedirectlywithEntitybeans,onlyintheframeworkoftheentireJ2EEproject.Andeveninthewholesoftwareframework,Hiberna