English 中文(简体)
如何在库存管理系统中采用依赖性注射
原标题:how to apply dependency injection in an inventory management system

i 想实施销售和库存管理系统,对如何在系统中采用依赖性注射混淆不清。 我想有一个清单类别,利用数据库来维持数据,而应当有一个处理数据库链接的类别,即DBConnectionManager,然后是使用DBConnectionManager并与亚洲开发银行互动的数据库层,然后是亚洲开发银行与使用库存、用户、客户、销售等非行的类别之间的一个抽象层次。 或者,在用户、客户和客户中,应当写“q”。 班级。

最佳回答

您是否尝试了保存模式?

与移民与发展协会一道,你建立了连接和基本业务(如更新、删除等)的根本类别。

之后,扩大这一类别,以创造更具体的行为,提出更有意义的名称......

这里是这方面的一个环节。

http://nhibernate.hibernatingrhinos.com/27/the-repos-pattern

问题回答

IMO, you should have a DAO interface created for your db activities/operations. This DAO interface will have generic operations for storing/retrieving data. You can then have classes implement this DAO interface; one class would enabled database persistence, one class would enabled text file based persistence (in case you need one) etc.

你们的数据库实施部将有一个<编码>java.sql.Connection的参考资料,以便与数据库连接。 你们利用依赖机制(如春天或古冰),在操作时间为小岛分局的接口和连接物体提供适当的实例。

基本上,学会从接口的角度来思考,更喜欢从继承的构成(不回避利用继承来避免法典上的重复;只是确保超级阶级的 t构成合同的一部分,或暴露于外部世界。 I ve personal found





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签