|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
Mysql的存储引擎接口定义良好。有兴趣的开发者可以通过阅读文档编写自己的存储引擎。object
Forms6iObject-BasedFeatures
PeterKoletzke,Quovera
ObjectsinMirrorareCloserThanTheyAppear
Thiswarning―printedonautomobilemirrors―isparticularlyappropriatetothedevelopmentworld.Ifyouarenotthinkingaboutobjectstoday,yousurelyseethemloominginyourrear-viewmirror.Youruseofobjecttechnologyiscloserthanyouthink.Youwilluseitsoonastheindustrytrendtowardsobject-orientedanalysis,design,andprogrammingcontinues.
Thepopularityofobjectorientation(OO)isduetoitspotentialbenefits.Ifobjectorientationiscorrectlyimplementedinanyaspectofsystemdevelopment,thereisameasurablegainintheareasofstandardscreation,use,andenforcement.AnalysisanddesigniseasierbecausebusinessobjectsaremorecloselyrelatedtoprogrammingobjectsintheOOworld.Thedistinctionbetweenphysicalandlogicalmodelingisnolongerasstrongwithobjectorientationbecausetheuniverseisfilledwiththingsthataremorecloselyrelatedtoobjectsthantorelationaltablesandentities.Complex,easilymaintainable,andquicklyupgradeabledesignsareallpossiblebecauseoftheextensibilitythatOOprovides.
Onthedevelopmentside,thelong-toutedbutneverfullyrealizedbenefitsofreusebecomearealitywhenthedevelopmentteamemploysobject-orientedenvironmentsandtechniques.Commonlibrariesofgenericcodeandmasterobjectsthathavetrueinheritanceaffordcentralmaintenanceforbusiness-relatedprogrammingcomponents.Thisyieldsgreaterconsistencyamongapplicationsintheenterprise.Withproperknowledgeofthecontentsofthelibraries,developerscanbemuchmoreproductiveandcreateapplicationsfasterthanwithoutinheritanceandgenericcode.
ThebiggestdownsidetotheuseofOOisthelearningcurvethatcomeswiththeshiftinenvironments.Developersneedtothinkinanobjectorientedway―thatis,"Everythingisanobject."Theramificationsofthatsimplestatementarewidespreadandnotfullyrealizeduntilyouactuallydiveintocoding.Thiswayofthinkingisverydifferentfromthethinkingin"traditional"language.Youneedtoconsiderthatallnewcodeyouwritehasthepotentialtobeshared.Whilethisisnodifferentfromwritingsharedcodeinotherenvironments,suchasthosethatusethePL/SQLlanguage,whenobject-orientationisagoal,thecodemustbemorerigorouslytestedforallpossibleusesifitistobeatruemasterobject.Thesameconsiderationappliestonon-codeobjectssuchasvisualclasses.Inaddition,developersmustbefullyawareofthemasterobjectsclassesthattheenvironmentofferssotheydonotreinventanexistingobject.Developersmustalsoknowthefeatures,theinterfaces,andhowtobestusetheobjectsinthedevelopmentlibraries.Thereisnoeasyanswertothisotherthantrainingandclosecontactwithsomeoneontheteamwhohastherequiredknowledge.
Object-OrientationinForms?
AstechnologistswhouseForms(currentlycalled“OracleFormsDeveloper”),wewouldliketobeabletotakeadvantageofobjectorientation.However,FormsDeveloperwasnotarchitectedasatrueobject-orientedenvironment.Itdoes,however,containcertainaspectsofanobject-orientedlanguagesuchasSmalltalkorJava.YoucanbaseyouruseofFormsonaspectsofthetoolthatsupportthebenefitsofobjects.Therefore,theterm"object-based"accuratelydescribesastyleofdevelopmentthatyoucanfollowtoexploitobjectconceptsinForms.ThemainaspectsofFormsthatsupportobjectconceptsarethefollowing:
・CodeLibraries
・Subclasses
・ObjectGroups
・ObjectLibraries
・Templates
Eachofthesefeatureswillbediscussedinthispaper.Inadditiontothesefeatures,thearchitectureofFormsisbuiltuponthefollowingaspectsthathaveacounterpartintheobject-orientedworldinlanguagessuchasJava:
・PropertiesofFormsobjectsThesecorrespondtoobjectandmethodattributes.SettingthevalueofapropertyinFormsmodifiesanaspectofhowtheobjectworks.
・AricheventmodelFormshasalwaysprovidedevent-drivenexecution.EverythingthathappensinaFormsruntimesessionisasaresultofcodeattachedtoaneventtrigger.
・ObjecthierarchiesFormsobjectsareorganizedinahierarchicalwaythatsuggestsinheritance.Forexample,althoughthereislittleactualinheritancebetweenblocksanditems,thoseobjectsarearrangedasparentandchildbothinconceptandinthedevelopmentenvironment.
・ObjectinterfacesFormsobjectscanbemodifiedprogrammaticallythroughaninterfacetotheirfunctionality.Formsbuilt-inssuchasSET_ITEM_PROPERTYandSET_WINDOW_PROPERTYallowthecodetomanipulatetheobjectatruntime.
・PrivateimplementationsSincenotallpropertiesareexposedtotheprogrammaticinterface,thismodelcorrespondssomewhattotheideaofprivateorprotectedimplementationsinJava.Inaddition,PL/SQLsfacilitytohidethepackagebodyfromuserssuggeststhisobject-orientedfeature.
・OverridinginheritedpropertiesAkeyfeatureofobject-orientedlanguagesisthatachildobjectcansetpropertieslocallyandoverridethesettingsandbehavioroftheparentobject.Formssubclassingallowslocaloverridesalthoughitdoesnothavethecapabilityforthedevelopertopreventinheritedpropertiesfrombeingoverridden.
Inaway,thereisalowerlearningcurvewithobject-basedfeaturesofFormsDeveloperthanwithothertrueobject-orientedenvironments.Sincetheproductisnotfullyobject-oriented,thedeveloperwhowantstouseobjectfeaturesasmuchaspossiblecandoso,butcanalsoleveragecommonknowledgeofstandardFormsconcepts.Inaddition,Formsisa4GLdevelopmenttoolandis,forthemostpart,quickerandeasiertousethana3GLprogramminglanguage.
InsteadofexplainingwhatOOconceptsFormssupports,thispapertakesthepragmaticapproachofexplainingthetoolsfeaturesthatsupportobject-baseddevelopmentaslistedabove.Italsodiscusseshowyoucanapplythesefeaturestoatemplatethatenablesstandardsenforcement,codereuse,andobjectsharing.Thetemplateisattheheartofobject-basedprogramminginFormsanditsusewillprovidemanyofthesamebenefitsofatrueobject-orienteddevelopmentlanguage.WhilethediscussionfocusesonFormsRelease6(6.0and6i),allconceptsapplyequallytorelease2(Forms5.0).Thesamplecodeusedinthispaperisdownloadablefromtheauthorswebsitesmentionedattheendofthispaper.
CodeLibraries
ThewaythatcodelibrariesworkinFormsisnotmuchdifferentfromthewaythattheyworkinmostothertoolsthatprovidecodesharing.AForms.PLLlibraryisattachedtoaformintheObjectNavigatorandallcodeinthatlibraryisthenavailabletotheform.Otherformscanattachthesamelibraryandthisishowthecodereusemanifests.ToputthisinOOterms,thecodeis"inherited"intothelibrary.Ifthecodeinthelibrarychanges,thebehavioroftheformthathasattachedthelibrarywillalsochange.Whileyoucanoverrideinheritedbehaviorinanobject-orientedlanguage,overridesinPL/SQLarenotasstraightforward.
Sincethecodeinalibrarycanbeshared,itshouldnotbewrittenforjustoneformorapplication.Youhavetothinkintermsofmakingthecodegeneric.Therearetwomaincategoriesofgenericcode:utilitiesandobjectsupportandreusablecomponentmethods.Areusablecomponentisasetofobjectsthatyouhavepackagedtogetherusinganobjectgroup(alsodiscussedlaterinthispaper).
UtilitiesandObjectSupport
UtilitiescanprovideacommoninterfacetotheuserforcommonFormsfunctionssuchascommittingachange.Youcanorganizethepackagesinyourlibrarybyfeatureorreusablecomponent.Forexample,youcancreatealibrarypackagecalledF_ALERTpackage(theF_prefixdenotingaform-specificpackage)tosupportanalertsystem,andF_HELPtosupportahelpsystem.YoucanalsocreategenericcodetosupportandfacilitateusingFormsobjects.Therefore,youcancodeanF_ITEMpackagetosupporttheitemobjectinFormsandanF_BLOCKpackagetosupportthemanipulationofblocks.ApackagelikeF_ITEMwouldcontainprocedurestoaccomplishtaskssuchasdisablingitems,enablingitems,hidingordisplayingitems,andloadingpoplistitemsfromaquery.Theseproceduresmakethetaskseasiertocodeastheyrequireasinglelineofcodeinsteadofanumberoflinesofcode.Forexample,theproceduretoloadapoplistfromaqueryisabout60linesofcodeifitiswrittencorrectlywithsufficientexceptionhandling.Thecalltoagenericprocedureisonlyoneline.Thissavesthedevelopertimebecausethereisnoneedtocodeanddebugthiscommonoperation.
ThefollowingisanexcerptfromtheF_ITEMpackagespecificationinthesamplecodelibrarythatcontainstheprocedurejustmentioned.
mysql的prepare其实是本地PHP客户端模拟的,并没有根据你mysql的设置做字符集的调整。应该交与mysqlserver端做prepare,同时得调用mysql_set_character_set去操作,server才会按照字符集去做转义。 |
|