没有合适的资源?快使用搜索试试~ 我知道了~
首页Angular项目结构最佳实践
资源详情
资源评论
资源推荐

Best Practice Recommendations for Angular App Structure
Proposal:
Changeangularseed,yeoman/generatorangular,(theGoogleinternalexample
go/nghellostyle),andotherdemoappstomodelthefollowingdirectorystructure.
Eventually,developtoolingtomakedevelopmentmoreefficientusingassumptionsbased
ontheseconventions.
Motivation:
Ourtoyanddemoappscurrentlygroupfilesfunctionally(allviewstogether,allcss
together,etc...)ratherthanstructurally(allelementsofaviewtogether,allcommon
elementstogether,etc...)
Whenusedinareallargerscaleapp(e.g.DoubleclickForAdvertisers),readabilityis
improvedbymakingthedirectoryandappstructureconsistentwiththearchitectural
designoftheapp.Wealsowanttobeabletodeveloptoolstomakeappcreationand
managementeasier,andthisissimplifiedwithacommonstructure.
Thisproposaloutlinesamorefunctionalstructurebasedonarepeatinghierarchyand
someusecaseexamples.
Formoreonmotivationandtheneedforarecommendationofsomekind,seethis
lengthydiscussionhttps://github.com/yeoman/generatorangular/issues/109
Why a fractal hierarchy?
Wewantedtobeabletocreateacommonsetofrulesthatcanbeappliedtoalogical
unitwithinanapplication.Theapplicationdevelopercanthendecidehowmanylogical
unitsarenecessary,andapplytherulestoalloftheminthesameway.Thismakesit
easierforlargeapplicationstodevelopastructurethatreflectstheapplicationitself,while
applyingthesamerulesateachlevelofthehierarchy.
ThisstructurewillmakeitpossibleforustodevelopcommontoolingforAngularapps,
andalsosupportfutureplansforAngularwhereroutingbettersupportsgreater
modularityofviews.
Why propose naming conventions?
WewanttoaddressacoupleofissuesthatweseenowinAngularcode:
○ It'sfairlycommonnowtohavethesamenameusedfordifferentkindsof.jsfiles
aServiceandaFilterbothusingthesamename,forexample.Whenediting
filesinanIDEitcanbehardataglancetotellwhichiswhich.Addinganaming
conventionfortypesoffileshelpstoresolvethis.
○ Therearecurrentlymultiplewaysoforganizingbyextensionornaming
convention.Unittests,forexample,arenamed*_test.js,*.spec.js,ortest/*.js,
dependingonwhowrotethecode.Havingasinglerecommendationmakesit
easiertodeveloptools.


















安全验证
文档复制为VIP权益,开通VIP直接复制

评论3