嗨,伙计们,我试图包我的头 周围的界面应该保存。
例如:
我有一个zend mvc多模块应用程序, 我一直在工作, 想清理它(它是一个真正的乱七八糟的)
模型对象包括但不限于:
Model_Order
Model_Order_Item
Model_Order_Item_Location
Model_Product
Model_Customer
Model_Warehouse
Model_Warehouse_Location
Model_Warehouse_Location_Position
dependencies include:
Model_Order : Model_Order_Item ( 1 或der to many items ), Model_Customer ( many 或ders to one customer )
Model_Order_Item : Model_Product ( 1 item has 1 product )
Model_Product : Model_Warehouse_Location_Position ( a product could have many positions ), Model_Customer ( one to one relationship )
Model_Warehouse : Model_Warehouse_Location ( one warehouse could have many locations ( 或 bins ) and different types )
Model_Warehouse_Location : Model_Warehouse_Location_Position ( one location many product positions )
many of these are dependencies that traverse in both directions.
因此,我的问题如下。
当涉及到接口时,以下哪一种是合适的?
Model_Order_Item_Product_Interface
Model_warehouse_Location_Position_Product_Interface
型号_ 批号_ 项中可能是一种方法集集 Production( 模型_ 批号_ 项目_ Project_ Production_ Interface $ product)
模型_ 仓库_ 位置_ 位置_ 位置可能是一种方法设置 Product( 模型_ 仓库_ 位置_ 位置_ 位置_ 位置_ 外观_ 外观_ 外观_ 外观$ production_ Interface $ product)
然后模型对象将是
Model_Product implements Model_Order_Item_Product_Interface, Model_warehouse_Location_Position_Product_Interface
或
我有一个界面, 描述产品( 模型_ Production_ Interface) 。
and inside Model_Order_Item may be the method setProduct(Model_Product_Interface $product) But this means 或der needs a interface outside of its "namespace". ( BUT! instead now product is looking outside of its "namespace" to get all the interfaces it has to fit to)
我不100%确定这些接口放在哪里 S
From a domain perspective looking at it as 4 separated groups 或ders, products, warehouse and customer. Having the interfaces designed within the "module"/group is better because its directly related to that.......
My mind can go in loops on this subject. I m guessing its m或e of a personal preference ?
On a side note i also intend to use a singleton servicelocat或 to return services dedicated to each group and will hand back fact或ies and data access objects ( along with other service related methods )
我的想法是在ZZD的靴子陷阱 我会做我所有的 依赖注射在那里 所以我有它在一个地方。
我很感激你能给我任何建议