简体   繁体   English

重复组成单词作为命名约定有什么意义?

[英]What is the point of repeating the component word as naming convention?

Let us say we have a component with this structure, why we need to repeat the word "component" in the naming of component's files, since we already have it in our parent folder? 让我们说我们有一个具有这种结构的组件,为什么我们需要在组件文件的命名中重复“组件”这个词,因为我们已经将它放在我们的父文件夹中了? I saw that this is the recommended Angular 2 Style Guide . 我看到这是推荐的Angular 2 Style Guide Maybe it is easier to tell that this file is about a component rather than a service, if you include it in the name, but other than that is there any other benefit? 如果你把它包含在名称中,可能更容易告诉这个文件是关于组件而不是服务,但除此之外还有其他任何好处吗?

components
    ├── edit-profile.component.ts
    ├── edit-profile.component.html
    ├── edit-profile.component.css

directives
    ├── form-validator.directive.ts
    ├── form-validator.directive.spec.ts
    ├── tooltip.directive.ts

services
    └── authorization.service.ts

Maybe it is easier to tell that this file is about a component rather than a service, if you include it in the name, but other than that is there any other benefit? 如果你把它包含在名称中,可能更容易告诉这个文件是关于组件而不是服务,但除此之外还有其他任何好处吗?

That's what it is for. 这就是它的用途。

If you create a feature than the related files should be kept together in a directory. 如果创建功能,则相关文件应保存在目录中。 To make them easy to distinguish when you have component(s), related directive(s), pipe(s), service(s) and maybe others in the same directory. 当您拥有组件,相关指令,管道,服务以及同一目录中的其他组件时,可以轻松区分它们。

This is just a way of naming convension, nothing else. 这只是一种命名对流的方式,没有别的。 Keeping component as suffix in each file that belongs to a component is just to tell the developer that hey you, this file is related to a component named 'edit-profile' . 组件作为后缀保存在属于组件的每个文件中只是告诉开发人员嘿,此文件与名为“edit-profile”的组件相关。 file extensions are there to tell you that what kind of file it is for that particular component. 文件扩展名可以告诉您该特定组件的文件类型。

If you want to know that if this naming convention envolves in application building-compiling tasks, then NO, it doesn't . 如果你想知道如果这个命名约定包含在应用程序构建编译任务中,那么NO, 它不会

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM