Структура на софтуера

Въведение

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.

Принципи на структурата на софтуера WEB

Евристични правила за проектиране на софтуерна структура

(1) Подобряване на функциите на модула

PerformprescribedfunctionsPart;errorhandlingpart;whendataneedstobereturnedtothecaller,returnthecorrectendflag.

(2)Елиминирана функция на дублиране

(3)Limittheinfluenceofthemodulewithinthecontrolrangeofthemodule

(4) Дълбочина, ширина, разклоняване навън Умерено и навътре

(5) Умерен размер на модула

Moduleistoolarge:comprehensibilityisreduced.Themoduleistoosmall:thecostismorecomplexthantheeffectiveoperatingsysteminterface.

(6) Намаляване на сложността на интерфейса на модула

Theinterfacetransmissioninformationshouldbesimpleandconsistentwiththemodulefunction.

(7) Функцията на модула е предвидима

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

(8) Избягвайте свързани модули

Preventbranchesorreferencesinthemiddleofmodules(forcontentcoupling).

(9)Thesoftwaremustbepackagedaccordingtodesignconstraintsandportability

Packagingreferstothetechnologyusedtoassemblesoftwareforaspecificenvironment.

Структурата на директорията е ясна

Структурата на директорията е ясна,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.

Наименуване по подходящ начин

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

Frequentlychangingcontentandinterfacemakethetemplatebetter

Frequentlychangingcontentandinterfaceusetemplatebetter,ifitismadeaccordingtothetraditionalproduction,theHTMLpagecontentisplacedintheprogramwhenprocessinginput,Itismoretroublesometochangetheprogram,whichmaycausegreaterinconvenience.

Единно съхранение на публична информация

Единно съхранение на публична информация,thisismainlyfortheconvenienceofthemostcommonfunctionsthatcanbecalledduringteamdevelopment,withouteverydeveloperhavingtocopyAcopyorwriteacopyofitandstoreitintheprogramfile.Thiswastesspaceandisnotveryefficient.

Включените файлове не могат да бъдат вградени твърде много

Включените файлове не могат да бъдат вградени твърде много.Thisisbecauseeverytimetheprogramincludesafile,itneedstobeopenedandread.ThisisIttakestime,andthatistosay,youmayencounterbugsthatarehardertofindwhenprocessingpaths.

Не съхранявайте много файлове със съдържание в директорията

Ifthefilesarelargeandlarge,itisbesttodividethemintodirectoriesanddisks.

Структурите на данните трябва да бъдат проектирани разумно

Структурите на данните трябва да бъдат проектирани разумно,conciselyandconcisely.

Проверката на данните трябва да е от страната на сървъра

Проверката на данните трябва да е от страната на сървъра,butthishasitsdisadvantages,thatis,whentheamountofdataislarge,theserverwillloadRunningandauditingdataintegritycancosttimeandsystemresources.Ontheclientside,itwillnotoccupytoomanyresourcesoftheserver,becauseitoccupiestheresourcesoftheuser.

Connectingtothedatabaseislate,anddisconnectingisearly

Connectingaslateaspossibleanddisconnectingassoonaspossiblecanminimizetheuseofsystemresourcesandprovideconditionsforthenextconnection.

Използвайте SESSION и COOKIE колкото е възможно по-малко

Използвайте SESSION и COOKIE колкото е възможно по-малко,becausetheuseofSESSIONtakesupsystemresources,andSESSIONisstoredontheserverside,andeachreadinSESSIONThedataismoreexpensive.Althoughcookiesdonotoccupyserverresources,cookiesarenotverysafe.

Related Articles
TOP