Solved

Application Logic Design

Posted on 2011-03-07
1
318 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

828 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