0

I have Meeting objects that form the basis of a scheduling system, of which gridviews are used to display the important information. This is for the purpose of scheduling employees to meetings, and for employees to view what has been scheduled.

I have been trying to follow DDD principles, but I'm having difficulty knowing what to pass from my service layer down to presentation area of system. This is because the schedule can be LARGE, and actually consists of many different elements of the system. Eg. Client Name, Address, Case Info, Group,etc, all of which are needed for the meeting scheduler to make a decision.

In addition to this, the scheduler needs to change values within this schedule and pass it back up to the service layer (eg. assign employees from dropdowns, maybe change group, etc). So, the information isn't really "readonly" - it needs to be interacted with. ie. It's not just a report.

Our current approach is to populate a flattened "Schedule Object" from SQL, which is constructed from small parts of different domain objects. It's quite a complex query. When changes have been made, this is then passed back up to the service layer, and the service will retrieve the domain objects in question, and fire business methods on the domain objects using information from the DTOs.

My question is, is this the correct approach? ie. Continue to generate large custom objects from SQL, and then pass down from Service Layer to Presentation Layer objects that feel a lot like View Models?

UPDATE due to an answer

To give a idea of the amount entities / aggregates relationships involved. (this is an obfuscated examples, so relationships are the important things here)

  • Client is in one default group

  • Client has one open case but many closed

  • Cases have many Meetings

  • Meeting have many assigned Employees

  • Meeting have many reasons

  • Meeting can get scheduled to different groups

  • Employees can be associated with many groups.

The schedule need to loads all meetings in open cases that belong to patients who are in the same groups as the employee.

Scheduler can see Client Name, Client Address, Case Info, MeetingTime, MeetingType, MeetingReasons, scheduledGroup(s) (showstrail), Assigned Employees (also has hidden employee ids).

Editable fields are assign employee dropdowns and scheduled group.

  • Schedule may be up to two hundred rows.
  • DTO is coming down from WCF, so domain model is accessed above this service layer, and not below.
  • Domain model business calls leveraged by service based on DTO values passed back, and repositories deal with inserts/updates.

So, I suppose to update, is using a query to populate an object which contains all of the above acceptable to pass down as one merged DTO? And if not, how would you approach it? ( giving some example calls to service layer, and explaining a little bit about how you conceive the ORM fetching the data keeping in mind performance)

3
  • This question covers way too much, you'd be best asking one question and cutting the content down to a quarter at least. I'd forget about DDD and SOA for now, what you've described above isn't DDD or SOA. Your solution of exposing the application layer over web services (particularly WCF) comes with many side-effects, if you're going down this route, then I'd design a solution that works (at least in the interim) and forget about all the acronyms. Have you looked into building a responsive website instead? This would give you a solution that works on desktops, mobiles and tablets. Feb 7, 2014 at 11:17
  • Hi, we already have a website which works across all devices. Decision has been made to take advantage of native on mobile devices (not my decision), and so since it will be another team, we are providing a service layer.
    – Milambardo
    Feb 7, 2014 at 11:46
  • Also - I'll edit question down.
    – Milambardo
    Feb 7, 2014 at 11:47

1 Answer 1

0

In the service layer and below, I would treat each entity (see aggregate roots in DDD) separate with respect to it's transactional boundary. I.e. even if you could update a client and a case in the same UI view, it would be best to transactionally modify the client and then modify the case. The more you try to modify in one transaction, the more you can conflict with other users.

Although your schedule is large and can contain lots of objects, the service layer should again deal with each entity (aggregate root) separately and then bundle them together into a new view model. Sadly, on brown-field projects, a lot of logic might be in the SQL and the massive multi-table joins might make this harder to refactor into more atomic queries that do exactly what is needed. The old-school data-centric view of 'do everything you can in the database' goes against everything DDD.

Because DDD is a collection of design ideas and patterns and not particularly a methodology or an architecture, it sounds that it might be too late to try shoe-horn your current application into a DDD application-centric design. It sounds as though your current app is very entrenched in the data-centric view.

If everything is currently being passed up through the layers in one monolithic chunk, it might be best to keep with this style and just expose these monolithic chunks to the people in the other team who wish to consume them, for use in their new app. You might be able to put some sort of view model caching in place (a bit like the caching view model element in CQRS).

In my personal opinion, data-centric, normalised data apps have had their day (they made sense in the 1970s when hard disk space was expensive) and all apps should be moving toward more modern practices. In reality, only when legacy systems are crawling on their knees, will stakeholders usually put up the cash to look for alternatives (usually after stuffing every last server with RAM). It might be possible or best to convince them to refactor small sections at a time.

2
  • Not everything is being passed up in large chunks, just the schedules due to the large amount of relationships between entities/aggregates (client, cases, teams, employee teams), and the amount of collections within the Meetings objects (assigned, meeting reasons, scheduledgroups, etc). If I have a schedule that is say, 200 long, there will be a performance issue if I lazy load through Nhibernate.
    – Milambardo
    Feb 7, 2014 at 16:54
  • To be a bit clearer, the client and case info is there to help facilitate the scheduler. The DTO passed back up the way will only affect the Meetings aggregate, as it is fetched from DB and it's business methods called providing values drawn from DTO values. So updates are still transactional.
    – Milambardo
    Feb 7, 2014 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.