What layer generates commands for dependent services?

Our business works with truck drivers making pickups/deliveries of containers. The location of containers needs to be tracked.

The drivers use mobile devices to generate a “DriverReport” (a log of their trip locations, times, container pickup/drop-offs, etc.). This is currently working with a mostly CRUD design.

We wanted to maintain good SoC so we built two services:

  • DriverService
  • InventoryService

We’ve had the DriverService take a dependency on the InventoryService. When a new DriverReport was inserted, it would generate DTO’s (based off the reports data) that could be sent to the InventoryService.

We’re not using CQRS yet, but we’re considering transitioning to it.

I’m struggling to understand the relationship between the services, commands and BLL. I seem to have lots of questions.

Who would be responsible for calling the inventory service?

Would it be good design for a NewTripCommandHandler to generate and send an UpdateContainerInventory command?

Or, would updating inventory for a new Trip be considered business logic? If yes, should a a domain entity for Trip generate and send an UpdateContainer command?

Or, should the mobile client generate both trip and inventory specific commands to send to the appropriate service?

Would it make more sense to take the parts specific to DriverReport inventory and merge it into the DriverService (so the dependency is broken)? Is that still good SoC? If we did this, at what layer might we start to think about the inventory? Would updating the inventory simply become a DB repository concern, or should there still be inventory specific commands and/or business logic?

I’m getting lost in the details, and it seems the more I read on the topics, the more confused I get.

You could consider SOA if you want to. The thing is here you’re only dealing with Commands. If you add the Publish/Subscribe pattern (message queues, service bus), you can have the serives publish events/messages, and not have to know who the subscribers were; the subscribers would all get the news and operate off the message contents.

My advice is to stop thinking about services, commands and fancy terms in OO design.

I would strongly recommend modelling your business logic without thinking about service oriented architecture, how the data will be transferred from clients to the service, etc.

You have an application. Your application clearly has two modules:

  • Module for processing a driver’s report. I really don’t care how this report gets generated and where the data comes from at this stage.

  • Module for updating inventory. Now I would not create a dependency between driver’s report and inventory processing. Instead I would create a component that would extract relevant data from the driver’s report and then pass it into the inventory processing module.

Once all this is in place I would start thinking about services (boundaries). I’d be asking questions like “Does it really make sense to create an inventory service? Will I have a client application that will call it directly?”

Finally, I would question having any business logic in the client application. I normally model and unit test all my business requirements in the domain layer. Once that’s done, I start working on the client application. This way my client application is pretty dumb, all it does is aggregate some data, pass it to the domain layer, lets domain layer work out what to do with the data, and then finally display result back to the user.

Update 1
So instead of:

var driverReport = new DriverReport();
var inventoryCoordinator = new InventoryCoordinator();
inventoryCoordinator.Process(driverReport);

I would have:

var driverReport = new DriverReport();
var inventoryUpdate = InventoryUpdateFactory.Create(driverReport);

var inventoryCoordinator = new InventoryCoordinator();
inventoryCoordinator.Process(inventoryUpdate);

In first example the inventory coordinator has a direct dependency on drivers’ report.

In second example, we extract relevant information from the drivers’ report and then pass that into inventory coordinator for further processing.

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật