Grails封装和命名约定 [英] Grails Packaging and Naming Conventions

查看:111
本文介绍了Grails封装和命名约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

包装控制器,服务等。即
- com.company.controllers
- com.company.services



这是一个很好的做法,还是应该尽量避免?

另一个值得一提的问题是我在命名服务时遇到的问题示例



SomthingGatewayService.groovy无法初始化这两种方式
- SomthingGatewayService somtinggatewayService

- def somtinggatewayService
我明白问题出在传统的'S'之前的大写字母'S'omthing'和'G'ateway'服务,所以它可能是因为某种春季DI问题



那么如何解决这个问题呢?

解决方案

是的,将域类,服务,控制器等放入包中是一个好主意。以后重构它可能是痛苦的。特别是在处理随时间增长的大型应用程序或应用程序时



关于第二个问题:如果您有一个名为 SomthingGatewayService 的服务,那么您可以通过以下方式引用它: def somthingGatewayService (只是第一个字母是小写)。


Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services

Is this a good practice or should be avoided by all means??

Another worth mentioning problem I encountered is in naming services Example

SomthingGatewayService.groovy can't be initialized in both these ways - SomthingGatewayService somtinggatewayService
- def somtinggatewayService I understand that the problem is in the 2 Capital Letters 'S'omthing and 'G'ateway before the conventional 'S'ervice, so its probably because of some sort of spring DI issue

So how to resolve this?

解决方案

Yes, putting Domain classes, services, controllers etc. into packages is a good idea IMO. Refactoring it later can be painful. Especially when dealing big applications or applications that grow over time.

Regarding the second problem: If you have a service called SomthingGatewayService then you'll be able to reference it by def somthingGatewayService (just the first letter is lower case).

这篇关于Grails封装和命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆