HowtoreducecostsofbusinesslogicmaintenanceTomasCernyDepartmentofComputerScienceandEngineeringCzechTechnicalUniversity,CharlesSquare13,Prague,CzechRepublicEmail:tomas.cerny@fel.cvut.czMichaelJ.DonahooDepartmentofComputerScience,BaylorUniversity,Waco,TX,USAEmail:jeffdonahoo@baylor.eduAbstract—Threetierenterpriseapplicationsintroducemultiplechallengesforsoftwareengineers.Althoughwecandividetheapplicationintothreetiers,westillneedtodesignproperlyeachtierinternallytoachievemultipledesignqualities.Themiddlebusinesstiercaptureslogicinwhichweassociateobjects,validatebusinessrules,etc.Oftenmultiplecross-cuttingconcernsaremixedintheserviceswhichresultsinbloated,highlycoupledde-signwithverylowcohesion.Inthispaperwepresentacasestudythatwedevelopbasedonourfouryearexperiencewithenterpriseapplicationthatstruggledfrommultipleweakdesigndecisions.Weemphasizemultipleaspectsthatshouldbedecoupledfromtherestoftheserviceswhichincreaseservicecohesionandresultsinbetterreadability,maintenance,testability,reuseanderror-avoidance.Our“bestpractices”suggestionsforbusinesstieraregenerallyapplicableandallowthedesignertoseparateserviceconcernsintomultipleunitsallowingtoachievethementionedqualityattributes.Keywords—Businesslayer,bestpractices,refactoringI.INTRODUCTIONApplicationdesignanddevelopmenttrendssettledforthelastdecadesontheuseofobjectorientedanalysis(OOA)anddesign(OOD)[1][2][3].OODisaspecialtypeofcall-and-returnarchitecturalstyles[4][5]andextendsapproachessuchasmainandsub-routinecallandabstractdatatype.ThemostbasicelementofOODisanobjectthatencapsulatesdataandprovidesoperationsonthetopofthemviamethods.Multipleobjectsinteractviamethodcalls,whichimpliesthatobjectsmustknowabouteachothertocollaborate.Theaimofobjectuseistoprovideinformationhidingandqualityattributes[6][7]suchasmodifiabilityandreuse.Objectcaninadditioninheritfromanotheroneinordertoextendandspecializeparent’scapabilities.Objectsprovidemanypossibilitiesforourdesign,butthereisnopreventionofmakingpoordesign.Fewsoftwarequalitymetricsexisttoprovidefeedbackonthedesignmaturityandtoreducemaintenanceandmodificationcosts[8].Lowcoupling,ameasureofhowstronglyisoneobjectconnectedtoanotheroneandhighcohesionthatsays,howstronglyrelatedaretheresponsibilitiesofanobject[1]aregoodexamplesofsuchmetrics.Tohaveagooddesignthatcontainsreadableandreusablecomponentsitshouldprovidebothlowcouplingandhighcohesion.Unfortunatelythesemetricsdoesgiveusasolutiontoaproblemthatwemayencounterduringourdesign.InordertouseOODeffectivelyweoftenapplydesignpatterns[2][3],thatrepresentthebestavailablesolutionalsoreferredas“bestpractices”.Designpatternshasgrowntomultiplecategoriesandspreadfromanalyzesoverdesigntocoding.BesidesmultiplepatternssimplifyingdesignersdecisionsanotherinnovativecontributionandcomplementtotheOOPappearedknownaspectorientedprogramming(AOP)[9].AOPthatintroducestheideaofcross-cuttingconcernsinobjects.Theseconcernsthenspreadthroughmultiplearchitec-turallayersandcannotbeisolatedwiththesoleuseofOOP.AOPdefinesthelocationwheremultipleconcernscrossasapointcut.Thispointcutasreachedbytheprogramcanuseanadditionalcode(separatelydefined)knownasanadviceandtogetherformanaspect.Thiswayouroriginalcodedoesnotexperiencemessedfragmentswithmultipleconcerns,butratherfocusonthemainconcernandtheextensiononesarehookedtoit.Everyextensiontothemainconcernisdefinedandmaintainedseparatelywhichsupportsmodifiability,reuse,maintenance,lowcouplingandhighcohesion.Everylargerapplicationofthesedaysemploysdesignpatterns,thesemayprovidethearchitecturalstructureorjustasimplecreationalfactory[2].Largeenterpriseapplicationsoftenemploy3-tierarchitectureinwhichmultipledesignpatternsareapplied[3].Such3-tierconsistsoftiersfordatapersistence,handlingbusinesslogicandpresentation.Eachtiermayconsistofspecificdesignpatternsandsomeconcernsexistthatmaycrossallthetiers,suchasloggingorsecurity.Weoftendealwithobject-relationalmappinginthepersistencetierandprovideaccesstoobjects.Higherbusinesstierthenusestheaccessinterfacesandappliesbusinesslogicwithaddedconstraintsplacedonobjectcollaboration.Thepresentationtierdealswithprovidingtheviewonthedataandallowsclientstointeractwithwhattheysee.Thepresentationandpersistencetiersareprettystraightforward.Ontheotherhandthebusinesstieritthemostvariableandoftenalsothemostcomplicatedone[3].Businesstiercontainsbusinesslogic,captureshowbusinessobjectsinteractwithoneanotherandmakeslogicaldecisionsbasedonbusinessrules.Itdealswithfunctionalvalidationandexceptionhandling,itmaycontainmanagementoftransactionsandsessions,checksuseraccessrightsandmakesintegrationofservicestransparenttothepresentationtierabove.Todealwiththese,multipleapplicationdevelopmentframeworks,suchas[10][11],suggesttologicallyseparatefurthertocontrollers[1](alsocalledhandlers,actions,managers,etc.)thattakecareoftransactionandsessionboundaries,exceptionshandlingand___________________________________978-1-4244-8726-4/11/$26.00©2011IEEEtoservicesthatimplementbusinessrules,businessvalidationandcallpersistence.Inaddition,controllersneedtoknowtheappropriateservicesto