Struktura softwaru

Úvod

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.

Principy struktury softwaru WEB

Heuristická pravidla pro návrh softwarové struktury

(1)Vylepšení funkcí modulu

PerformprescribedfunctionsPart;errorhandlingpart;whendataneedstobereturnedtothecaller,returnthecorrectendflag.

(2) Eliminovaná duplikační funkce

(3)Limittheinfluenceofthemodulewithinthecontrolrangeofthemodule

(4) Hloubka, šířka, rozvětvení Mírné a rozvětvení

(5) Střední velikost modulu

Moduleistoolarge:comprehensibilityisreduced.Themoduleistoosmall:thecostismorecomplexthantheeffectiveoperatingsysteminterface.

(6) Snižte složitost rozhraní modulu

Theinterfacetransmissioninformationshouldbesimpleandconsistentwiththemodulefunction.

(7)Funkce modulu je předvídatelná

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

(8)Vyhněte se připojeným modulům

Preventbranchesorreferencesinthemiddleofmodules(forcontentcoupling).

(9)Thesoftwaremustbepackagedaccordingtodesignconstraintsandportability

Packagingreferstothetechnologyusedtoassemblesoftwareforaspecificenvironment.

Struktura adresáře je přehledná

Struktura adresáře je přehledná,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.

Přiměřeně pojmenovat

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

Frequentlychangingcontentandinterfacemakethetemplatebetter

Frequentlychangingcontentandinterfaceusetemplatebetter,ifitismadeaccordingtothetraditionalproduction,theHTMLpagecontentisplacedintheprogramwhenprocessinginput,Itismoretroublesometochangetheprogram,whichmaycausegreaterinconvenience.

Jednotné úložiště veřejných informací

Jednotné úložiště veřejných informací,thisismainlyfortheconvenienceofthemostcommonfunctionsthatcanbecalledduringteamdevelopment,withouteverydeveloperhavingtocopyAcopyorwriteacopyofitandstoreitintheprogramfile.Thiswastesspaceandisnotveryefficient.

Zahrnuté soubory nelze vkládat příliš

Zahrnuté soubory nelze vkládat příliš.Thisisbecauseeverytimetheprogramincludesafile,itneedstobeopenedandread.ThisisIttakestime,andthatistosay,youmayencounterbugsthatarehardertofindwhenprocessingpaths.

Neukládejte příliš mnoho souborů obsahu do adresáře

Ifthefilesarelargeandlarge,itisbesttodividethemintodirectoriesanddisks.

Datová struktura by měla být navržena rozumně

Datová struktura by měla být navržena rozumně,conciselyandconcisely.

Ověření dat by mělo být na straně serveru

Ověření dat by mělo být na straně serveru,butthishasitsdisadvantages,thatis,whentheamountofdataislarge,theserverwillloadRunningandauditingdataintegritycancosttimeandsystemresources.Ontheclientside,itwillnotoccupytoomanyresourcesoftheserver,becauseitoccupiestheresourcesoftheuser.

Connectingtothedatabaseislate,anddisconnectingisearly

Connectingaslateaspossibleanddisconnectingassoonaspossiblecanminimizetheuseofsystemresourcesandprovideconditionsforthenextconnection.

Použijte SESSION a COOKIE tak, jak je to jen trochu možné

Použijte SESSION a COOKIE tak, jak je to jen trochu možné,becausetheuseofSESSIONtakesupsystemresources,andSESSIONisstoredontheserverside,andeachreadinSESSIONThedataismoreexpensive.Althoughcookiesdonotoccupyserverresources,cookiesarenotverysafe.

Související články
HORNÍ