Solved

Application Logic Design

Posted on 2011-03-07
1
314 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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
A short article about problems I had with the new location API and permissions in Marshmallow
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now