节点 JS - MVC - 命名约定

Node JS - MVC - Naming Conventions

我通常会按如下方式设置应用程序结构:

+----my_awesome_nodejs_app
|    +----app
|    |    +----app.js
|    |    +----node_modules
|    |    +----tomatoes
|    |    |    +----tomatoes.controller.js
|    |    |    +----tomatoes.helper.js
|    |    |    +----tomatoes.model.js
|    |    |    +----tomatoes.route.js
|    |    +----views
|    |    |    +----tomatoes.pug
|    +----public
|    |    +----tomatoes
|    |    |    +----tomatoes.css
|    |    |    +----tomatoes.js
|    +----spec
|    |    +----tomatoes.spec.js

我赞成命名约定与前端的命名约定相匹配(例如 example.com/tomatoes)——因为我认为它更容易支持长期(尽管可能有更好的方法)这个)

也就是说 - 如果说,我决定将 tomatoes 更改为 sausages - 我需要相应地更新我所有的测试、目录名、文件名和评论(更不用说页面-具体 CSS 或 JS).

这是我在执行此类操作时只需要接受并考虑在内的事情,还是有其他(更好的)方法可以做到这一点以提供更大的灵活性?

在不对解决方案进行过度设计的情况下,很难摆脱必须对所有相关文件执行更改。

将 component/module/part 的所有相关文件放在同一个文件夹中会有帮助,请参阅 Relational Structure in this blog post for more information

在我看来,关系结构也使更大的项目更容易处理,因为您可以在同一个地方找到所有相关资源,而不必搜索分散在项目周围的文件来进行更改。