Code Monkey home page Code Monkey logo

Comments (2)

mtpultz avatar mtpultz commented on May 18, 2024

Hi @LucasCaixeta, there are a lot of different ways that people layout their folder hierarchy. Originally it was something like:

/controllers
/directives
/services

But if your application needs to be scalable this will cause lots of growing pains. So others have adopted structures that nest based on the URL or based on your understanding of the UI, which I'll outline below in 3 points:

  1. Assuming basing your folder structure on URL is self explanatory I'll just say the amount of folders you have will balloon.
  2. Using the UI you can split your folders into the below structure where a major feature might be tabs and minor features are the tabbed content with associated component folders. Arguably adding your services into the feature folders might be a bad idea, especially if they cross cut components, so you could add them to a /services folder in the root so you can actually find them and so services aren't written that already exist. Each feature gets its own appjs and is subsequently required by your mainJS.
/major-feature-1
  /minor-feature-1
    controller.js
    directive.js
    service.js
  /minor-feature-2
  ...etc
/services
  cross-cutting-service1.js
  cross-cutting-service2.js
  1. Another take on the last example is using the pages of the application as the folder, which contains the components with their own files, but where services that crosscut are also placed in the root maybe even in a /common folder instead of just /services. Each page gets its own appjs and is subsequently required by your mainJS.
/page
  /component
    controller.js
    directive.js
    service.js
/common
  /services
    cross-cutting-service1.js
    cross-cutting-service2.js

These are examples of all the ways I've read about and have evolved to use, but I'd be interested to know what others have to say with regards to the style guide. Either with other examples and why they are better or tweaks to one of the offered solutions.

Also, I believe this style guide and John Papa's parallel to a degree and diverge where they disagree, but John Papa has an application structure section.

Cheers

from angularjs-styleguide.

toddmotto avatar toddmotto commented on May 18, 2024

Closing off as this is now in the new styleguide which has been completely rewritten in ES6 for Angular 1.5+ (component architecture/components/one-way dataflow etc).

from angularjs-styleguide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.