472,986 Members | 3,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,986 software developers and data experts.

Domain Driven Design and SaveAll()

In our domain driven design, we allow clients to consume a service
that includes a "Save Step" method (public Step SaveStep(Step
userStep). This works great for the consumers of the web service
(easy call, just send back entire step object) and for persisting the
step data to the data store (just send the step to the repos).

It gets a little more complicated when we introduce the idea that
SaveStep should, in addition to persisting data, trigger a specific
event that is captured by an outside process, such as a workflow
engine. A Step in this case is somewhat complex; a collection of
users, collection of documents, and permissions per user on the
documents. We need to trigger events such as user added, removed,
permission set added/removed, etc. Is there a best practice/pattern/
example to approaching this; basically, comparing the passed in step
to the persisted step and generating what has changed?

I could obviously write a very specific algo to compare the saved and
new steps, with hard-coded references to each component in the
Step...but this would be ugly and not very adaptable to changes in the
Step in the future.
Sep 2 '08 #1
1 1163
"Daniel C" <da************@gmail.comwrote in message
news:4a**********************************@b1g2000h sg.googlegroups.com...
In our domain driven design, we allow clients to consume a service
that includes a "Save Step" method (public Step SaveStep(Step
userStep). This works great for the consumers of the web service
(easy call, just send back entire step object) and for persisting the
step data to the data store (just send the step to the repos).

It gets a little more complicated when we introduce the idea that
SaveStep should, in addition to persisting data, trigger a specific
event that is captured by an outside process, such as a workflow
engine. A Step in this case is somewhat complex; a collection of
users, collection of documents, and permissions per user on the
documents. We need to trigger events such as user added, removed,
permission set added/removed, etc. Is there a best practice/pattern/
example to approaching this; basically, comparing the passed in step
to the persisted step and generating what has changed?

I could obviously write a very specific algo to compare the saved and
new steps, with hard-coded references to each component in the
Step...but this would be ugly and not very adaptable to changes in the
Step in the future.
If you're essentially comparing two objects for deep equality, then I see
nothing wrong with providing your own interface - IDiffable? - dimilar to
IEquatable for this, and using it, calling the corresponding method
recursively on child objects as needed. You'll still have component-specific
comparison code, but it will be neatly organized, with each
component-specific part belonging to IDiffable implementation of that
specific component; so any changes are always localized (changed component
members - change its IDiffable too). In practice, this approach is likely to
be more maintainable as any other alternative, too, because intent of the
code is very clear.

Otherwise, you could go the metaprogramming way, and use custom attributes
to mark fields in your classes as participating in the diff, and then
reflection to traverse the object graph and perform a general comparison. In
practice, this may be tricky to get right in less trivial cases, because
you'll need to special-case a lot of things which can't be just compared
field-by-field (strings, collections...).
Sep 3 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: steve.anon | last post by:
Hi - Any help or pointer on this would be greatly appreciated. I'm working on something similar to blogger.com. Users sign up and they get their own webpage, with a domain name of...
2
by: alanrn | last post by:
For all you seasoned VB programmers this is going to be a no brainer. However, as a C programmer learning VB I'm having trouble getting my arms around the event-driven nature of VB. Suppose I...
0
by: kamlesh.bafna | last post by:
Hi , I am trying to design an event manger class for my Windows application. It is sort of smart client application but doe not depend on any external factors to update itself. Better term would...
10
by: Michael B. Trausch | last post by:
Alright, I seem to be at a loss for what I am looking for, and I am not even really all that sure if it is possible or not. I found the 'pdb' debugger, but I was wondering if there was something...
14
by: Snor | last post by:
I'm attempting to create a lobby & game server for a multiplayer game, and have hit a problem early on with the server design. I am stuck between using a threaded server, and using an event driven...
9
by: Deckarep | last post by:
Hello Group, I actually have two seperate questions regarding Unit Testing with NUnit in C#. Please keep in mind that I'm new to the concept of Unit Testing and just barely coming around to...
6
by: Bart Van der Donck | last post by:
Hello, I'm presenting my new library 'AJAX Cross Domain' - a javascript extension that allows to perform cross-domain AJAX requests. http://www.ajax-cross-domain.com/ Any comments or...
8
by: Brad Walton | last post by:
Hello. First post, but been doing a bit of reading here. I am working on a project in Java, but decided to switch over to C# after seeing some of the additional features I can get from C#. One of...
25
by: pereges | last post by:
Hello, I'm trying to build a database driven website for a library management system. The database is stored on a remote server which all of my team mates can access. I've installed MySQL, PHP and...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.