Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Folder Structure and File Naming Conventions #2266

Closed
@shairez

Description

@shairez

Hi Guys,
I tried to find common conventions and best practices on how to structure large scale applications but couldn't find any that made sense for me.

We all believe it's very important to stay consistent when working in a team, and I think we should strive towards having a unite angular file naming conventions and even a common folder structure to save time.

In Java and in Flex it was very clear how to structure and name your folders / files, but in Javascript for some reason it is still the wild west.

So I'm raising this issue to see if anyone think the same and to get way more experienced devs involved and sharing their thoughts so we can try and create a naming convention that will hopefully find its way to the WIKI for newcomers to see.

I divided it to several topics:

Multi Word Separation:

  1. Dashed: my-folder or my-file
  2. camelCased: myFolder or myFile
  3. underlined: my_folder or my_file

From what I see, the common use is the dashed one: my-file.

File Suffix:

Because I think it's a good practice to separate each controller / service / module into its own file I think having a suffix is important and I saw in other projects several options for this also:

  1. userController.js
  2. userCtrl.js
  3. user.ctrl.js

I favor #3, as we can suffix any file by it's type and it seems clearer:
Controller - .ctrl.js
Service - .srv.js
Module - .mdl.js
etc...

One use case it can help is when you when you need to concatenate files in a specific order and you want the modules to be first in the concatenation. so you can do something like: [".mdl.js", ".js"]

Folder structure

In large scale applications, we usually divide things into modules, but looking at some example projects like angular-app or angular-sprout, I got confused and it was hard to see which one can survive the test of time and thousands of files. I personally don't know what is the best way, but it seems that things are usually divided into two categories: "Common" and "Core". core meaning the application specific files, and common are reusable components between modules.

I can create a new "Seed" project we can debate over if it's something that other find useful.

So... what do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions