DEV Community

loading...
Cover image for How to organize the project folders and files?

How to organize the project folders and files?

blog profile image Larson Reever ・3 min read

Project structure (folder structure) is a very basic thing and usually ignored, especially junior developers.

Alt Text

Good structure can help you increase your efficiency.

What are the most common ways to oganize the project structure?

There is not correct answer here, depend on developers.

I. Structure

Today, I will show you 2 common ways to arrange files in project which can help you access to files easier.

  1. Group files by features

Alt Text
Any projects have at least 2 features. Large projects have many features. This way has 2 advantages:

You can access to other related files in the same folder. Press Ctrl + 5 to quick access files in the same folder.

You can copy folders to new projects and reuse it easily. This is the reason I love this way.

Where should I put the models, which are used in many features?

Common folder is an option.

But I usually put it in the most related folder. For example: Product model is in folder Products, User model is in folder Membership or Login.

  1. Group files by type

Alt Text

You can make many folders of same purpose files like, Models, Controllers, Views
You have right folders for right types, don't have to confuse where to put files.

This way is very easy for newcomers (junior developers), they can easily find the files they want.

I don't use this way so I don't know more benefits of it. Anyone who is using it, please share me in comments.

II. Naming

Naming is very important. Descriptive names help you easy to find and understand the mission of files.
Some things you should know in naming.

  1. Class name is file name

RegisterController should be written in RegisterController.swift. You don't have to remember 2 names, just one for Register feature. Keep your mind free to remember other things.

  1. Feature name is folder name and prefix of file names

This is for group by features way. Register feature should have structure like below.

Alt Text

The folder name can be Register or RegisterController, no problem. You can understand its functionality at first glance, right.

If you're using group by types way, you can name your files with prefix is feature name as above example. Benefits are below.

Alt Text
Conclusion

Hope these tips can help you increase your coding performance. I effectively use them to manage my projects at Redblink. Please share me how you organize your project structure. I am sure your ways are awesome ways.

Introduce a very cool tool: https://github.com/venmo/synx. You should try it.

Discussion (0)

Forem Open with the Forem app