如何在Java中打包工厂 [英] How to package Factories in Java

查看:101
本文介绍了如何在Java中打包工厂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何打包我在应用程序中的工厂。工厂是否与使用它的类在同一个包中,与其创建的对象或其自己的包中的包相同?



感谢您的时间和反馈

解决方案

通常工厂与他们创建的对象在一样的包中;毕竟他们的目的是创造这些对象。通常它们不在一个单独的包中(没有理由)。还有工厂与他们创建的对象在同一个包中,可以利用包的可见性。


I was wondering how to package the factories that I have in my application. Should the Factory be in the same package as the classes that use it, in the same package as the objects it creates or in its own package?

Thanks for your time and feedback

解决方案

Usually factories are in the same package as the objects they create; after all their purpose is to create those objects. Usually they are not in a separate package (there is no reason for that). Also having the factory be in the same package as the objects they create allows you to exploit package visibility.

这篇关于如何在Java中打包工厂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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