Software structure

Introduction

Theso-calledmodulereferstoarelativelyindependentcollectionofprogramobjectssuchasdatadescriptionsandexecutionstatements.Eachmoduleintheprogramneedstobenamedseparately,andaccesstothespecifiedmodulecanberealizedthroughthename.Inhigh-levellanguages,modulesareembodiedasfunctions,subroutines,procedures,etc.Amodulehasfourcharacteristics:input/output(interface),function,internaldata,andprogramcode.Theinput/outputisusedtorealizethedatatransmissionbetweenthemoduleandothermodules,thatis,theoriginaldatarequiredbythemoduleistransferredandtheresultdataisobtainedfromthemodule.Functionreferstotheworkdonebythemodule.Theinput/outputandfunctionsofthemoduleconstitutetheexternalcharacteristicsofthemodule.Internaldatareferstoalocalquantitythatcanonlybeusedinsidethemodule.

Someprogramshaveasingle-modulestructure,andsomehaveamulti-modulestructure.Thesemodulesareinseparableinthelogicoftheprogram,canbewrittenindifferentprogramminglanguages,canberespectivelycompiledbythecorrespondingcompiler,canbecombinedwithotherprogramunitsandloadedintothecomputertorun.Duetotheneedtowritelargeprogramsandmodulescanbeusedmultipletimes,modularizationisagoodmethod.Alargeprogramcomposedofasetofmodulescanhavethreestructures,namelysequentialstructure,concurrentstructureanddistributedstructure.Theprogramofsequentialstructureistheoldest,andtheprogramminglanguageusedissequentialprogramminglanguage,suchasALGOL,FORTRAN,Candsoon.Theprogramoftheconcurrentstructureiscomposedofseveralmodulesthatcanbeexecutedatthesametime.Thesemodulescanbeexecutedinparallelonmultipleprocessors,ortheycanbecross-executedonthesameprocessor.Theprogramminglanguageusedisaconcurrentprogramminglanguage,suchasconcurrentPASCAL,Modula-2,etc.Theprogramofthedistributedstructureiscomposedofseveralmodulesthatcanberunindependently.Thesemodulescanbedistributedinadistributedsystemandrunonseveralcomputersatthesametime.Theprogramminglanguageusedisthedistributedprogramminglanguage.Forlargeprograms,itcanalsobeamixtureofthesethreestructures.

PrinciplesofWEBsoftwarestructure

Heuristicrulesforsoftwarestructuredesign

(1)Improvementofmodulefunctions

PerformprescribedfunctionsPart;errorhandlingpart;whendataneedstobereturnedtothecaller,returnthecorrectendflag.

(2)Eliminateduplicationfunction

(3)Limittheinfluenceofthemodulewithinthecontrolrangeofthemodule

(4)Depth,width,fan-outModerateandfan-in

(5)Moderatemodulesize

Moduleistoolarge:comprehensibilityisreduced.Themoduleistoosmall:thecostismorecomplexthantheeffectiveoperatingsysteminterface.

(6)Reducethecomplexityofthemoduleinterface

Theinterfacetransmissioninformationshouldbesimpleandconsistentwiththemodulefunction.

(7)Thefunctionofthemoduleispredictable

Themoduleisregardedasablackbox,thesameinputproducesthesameoutput,anditsfunctionispredictable.Thefunctionofthemodulewithinternalstatemaybeunpredictable.Difficulttounderstand,difficulttotest,anddifficulttomaintain.

(8)Avoidill-connectedmodules

Preventbranchesorreferencesinthemiddleofmodules(forcontentcoupling).

(9)Thesoftwaremustbepackagedaccordingtodesignconstraintsandportability

Packagingreferstothetechnologyusedtoassemblesoftwareforaspecificenvironment.

Thedirectorystructureisclear

Thedirectorystructureisclear,nottoodeeporcomplicated.Itisbettertousearelativeaddressforthepath.

WhatkindofWhatkindofcontentisplacedinthedirectory,sothatitiseasytomanage,sothatthedirectorystructureoftheWEBprogramisclear,andyoucanknowwhatfunctionmodulesandcontentarestoredinacertainfolderataglance.Ifyoustoreitcasually,youwillneverknowwhatacertaindirectoryisforforalongtime.Forexample,executablefilesthatarefrequentlyusedshouldbestoredintherootdirectoryofthe(projectrootdirectory).Thisismainlytofacilitateunderstandingofitsfunction,andalsotoreducetheinputofaddresscharactersintheprogram.Thepicturesusedbytheprogramarestoreduniformlyintheimagesdirectoryundertherootdirectory.Iftheprojectislargerandhasmorebranches,youcancreateadirectorynamethatalsobranchestheprograminthedirectorytostoretherelevantpicturecontent.Theconfigurationfilesoftheprogramandcommoncommonfunctionlibraryareplacedintheincludedirectory,andtheextensionofthefunctionlibraryfilestoredinthisdirectoryshouldbenamed:.phpmustnotbenamed.inc.iniandotherfileswithextensions,Themainreasonistopreventthistypeoffilefrombeingavailableforuserstodownload,ortoconsultthesourcecodecontent,sothatitisconvenientandcleartocall.Thetemplatefilesshouldbestoredinthetemplatesdirectoryundertherootdirectorywiththeextension.html.Iftheprojectislargeandtherearemanycategories,thetemplatefilescanbestoredinthelowerdirectory.Temporaryfilesarestoredintherootdirectorytmpdirectory.Thisdirectoryisusuallysettobereadableandwritablebyanyone.Theuseofrelativeaddressesismainlytofacilitateprogramtransplantation.

Namingappropriately

Thenamingisbestbasedonwhattheprogramisusedfor.Ifawordneedstobedescribed,uselowercasewordstonameit.Ifmorethanonewordcanbeusedtorepresentit,connectthelowercasewordswithanunderscore.Notethatthenameshouldnotbetoolong,whichisinconvenient.Althoughitcanexpressmoreclearly,itisdifficulttotype.Thefunctionnamingintheprogramcanalsobethesame.

Frequentlychangingcontentandinterfacemakethetemplatebetter

Frequentlychangingcontentandinterfaceusetemplatebetter,ifitismadeaccordingtothetraditionalproduction,theHTMLpagecontentisplacedintheprogramwhenprocessinginput,Itismoretroublesometochangetheprogram,whichmaycausegreaterinconvenience.

Unifiedstorageofpublicinformation

Unifiedstorageofpublicinformation,thisismainlyfortheconvenienceofthemostcommonfunctionsthatcanbecalledduringteamdevelopment,withouteverydeveloperhavingtocopyAcopyorwriteacopyofitandstoreitintheprogramfile.Thiswastesspaceandisnotveryefficient.

Includefilescannotbeembeddedtoomuch

Includefilescannotbeembeddedtoomuch.Thisisbecauseeverytimetheprogramincludesafile,itneedstobeopenedandread.ThisisIttakestime,andthatistosay,youmayencounterbugsthatarehardertofindwhenprocessingpaths.

Donotstoretoomanycontentfilesinthedirectory

Ifthefilesarelargeandlarge,itisbesttodividethemintodirectoriesanddisks.

Thedatastructureshouldbedesignedreasonably

Thedatastructureshouldbedesignedreasonably,conciselyandconcisely.

Dataverificationshouldbeontheserverside

Dataverificationshouldbeontheserverside,butthishasitsdisadvantages,thatis,whentheamountofdataislarge,theserverwillloadRunningandauditingdataintegritycancosttimeandsystemresources.Ontheclientside,itwillnotoccupytoomanyresourcesoftheserver,becauseitoccupiestheresourcesoftheuser.

Connectingtothedatabaseislate,anddisconnectingisearly

Connectingaslateaspossibleanddisconnectingassoonaspossiblecanminimizetheuseofsystemresourcesandprovideconditionsforthenextconnection.

UseSESSIONandCOOKIEaslittleaspossible

UseSESSIONandCOOKIEaslittleaspossible,becausetheuseofSESSIONtakesupsystemresources,andSESSIONisstoredontheserverside,andeachreadinSESSIONThedataismoreexpensive.Althoughcookiesdonotoccupyserverresources,cookiesarenotverysafe.

Related Articles
TOP