Solved

Application Logic Design

Posted on 2011-03-07
1
319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

726 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