Mister_L
Mister_L

Reputation: 2611

angular 4 folder structure one item per file with models and interfaces

Angular's style guide recommends to define one thing, such as a service or component, per file. But what about simple model classes or interfaces? For example, say you are inside a component folder, and you create a file my-component.interfaces.ts. You can place all of your component's interfaces there (or model classes without methods), and see them all clearly in a collapsed view. Would you still argue that instead it is best to create an interfaces folder, and place each interface (or model) in separate file?

Thanks.

Upvotes: 1

Views: 1281

Answers (1)

Narm
Narm

Reputation: 10864

At the end of the day how you choose to structure your application comes down to personal preference. However, the recommendations from Angular outline many well established patterns and practices that are generally adopted by the larger development community.

From a code readability and maintenance perspective it is always easier to manage/extend/debug a file that has one well constructed class then a file that has many classes.

Again it is a personal decision; if you're working on a personal project that only you will be developing and maintaining then you should do whatever works best for you. However, if you're working with a team or expect other developers to get involved at some point I would highly recommend you follow the patterns and guide, because that is what other developers will be use to and expecting.

Upvotes: 1

Related Questions