Repeating module name for each module component

前端 未结 5 1946
北恋
北恋 2020-12-29 08:48

The famous Best Practice Recommendations for Angular App Structure blog post outlines the new recommended angularjs project structure which is now component-oriented, not fu

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 09:32

    It's all about organizing large Projects (code base):


    I've found names and folder-hierarchies to be very valuable for organizing large projects. Similarly, meaningful, hierarchical names help me tremendously.

    Coming from the ASP.NET world, where projects are huge, we have:

    Solutions -> managing Projects (assemblies) -> with folders -> and sub-folders, for files.

    So an ASP.NET MVC Project will have a Home Controller in the Controllers Folder of the MVC Presentation Project, and Views in the Views Folder.


    When using AngularJS in my projects, I like the approach of naming

    App(Module)-type(directive/service)-(sometimes more detail)
    

    This is in addition to naming folders for apps, and having directives and services in folders for their types with the folder named after the app and the app often named functionally or after the ASP.NET View (like my View may be Account-Login).

    All this because my projects are very very big. I end up having many AngularJS apps, crazy number of directives, and even fair number of services.

    When your project is small or even medium size, the advantages are arguable. But when your project grows big, organization is critical! Both to help you find the code you need, and to continue propagating more.

提交回复
热议问题