Solved

Application Logic Design

Posted on 2011-03-07
1
317 Views
Last Modified: 2012-06-21
Hi experts,
I need some suggestion helping me to have a good logic design.
My problem is this:
there is a web service (WCF) that exposes my business logic.
On the web service there is a method, for istance: public User CreateUser(User user);
When a consumer invokes this method I need to performe some step in order to create this user. For example:

1) create a new entry on the db (there is a data access layer that implements UnitOfWork and repository pattern);
2) Create some dns entry
3) Create a folder structure
and so on..

I need to make sure all these steps are successfully completed and in case of error I need to rollback.
My question is this:
What the best method (maybe using some design pattern) to help me to:

1) Send back the response to the caller only if all the steps are completed without errors;
2) Make the code flexible, testable and maintable (for example if a future step is needed I don't want to modify the web service bu just the business logic layer)
3) Is it better to pass back to the consumer an object that containes an error status ( zero if no error or some error code in case of error plus the response object like for istance responseObject.ErrorCode; responseObject.UserResult) or some object able to expose all the steps with their status (responseObject.DBSave = true, responseObject.DnsCreation = true and so on)?

Hope my question is clear and thanks in advance
0
Comment
Question by:xtremereality
1 Comment
 
LVL 6

Accepted Solution

by:
t-max earned 500 total points
ID: 35056608
Here you have a good resource for design patterns and sample codes:
http://www.dofactory.com/Patterns/Patterns.aspx

Regarding your question, I think you can use a factory for creation (if you create more things other than just a user) and a facade might give you the flexibility to create more underlying subsystems, while keeping the same external interface.

Perhaps other patterns might suit you, but you should consider if it's worth to implement them or not, according to what you expect from your app in the future.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is about my first experience with programming Arduino.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question