保存代码生成的字符串层次结构
我有一个关于字符串存储的问题。
我使用一个代码生成框架(在java中,生成java),它使用了很多我想以某种方式组织的字符串。
我正在考虑将字符串放在函数中,这将允许我将 javadoc 等添加到字符串中。将会有很多函数,我计划根据类型将它们分成不同的类(例如方法或类)。我没有任何数据库,所以它必须在项目中。
我怎样才能最好地做到这一点? 在所有内容上使用静态最终,它会很容易访问,但是这有什么缺点吗?(顺便说一句,我不使用多线程)
I have a question about String storage.
I use a code generation framework (In java, generates java) which uses a lot of strings that I want to organize in some way.
I was thinking of having the strings in functions, which will allow me to add javadocs and such to the strings. There will be a lot of functions, I planned to split them in different classes depending of the type (like methods or classes for example). I do not have any database so it must be in the project.
How do I best do this? With static final on everything it would be easy to access, but is there any downside to this? (I don't use multithreading btw)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果它们是常量字符串,那么肯定通过将它们声明为静态和最终来使它们恒定。并在它们逻辑上所属的位置声明这些常量,即在其逻辑依赖于该常量的类中。
相反,我不认为有任何缺点。
I they are constant Strings, then definitely make them constant by declaring them static and final. And declare these constants where they logically belong, i.e. in the class that depends on this constant for its logic.
I don't see any downside, on the contrary.