473,395 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Separating business logic from UI

I have a couple of questions, hopefully someone has come across this
before and can help me. (1) What are the various ways i could separate
my apps UI from business logic - could you provide bare bone example?
(2)I am using a third party supplier library and one of the requirements
is to be able for the app to have the capability to plug in various 3rd
party supplier libaries. i.e. if we go with company X, later when
company Y has a similar product, we can do minimal or no changes and use
the company Y's library instead of the one from company X.

I know these two question may somewhat be related. I appreciate any help
you could provide.
thanks,
BRAMOIN

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
3 2493
Hi,

I assume your supplier library is one on UI. If yes, then the following
might answer your question. If no, then please tell me what they are used for.

I usually follow this approach:
1. I define business 'Model' classes. These classes would represent biz
entities.
2. The presentation tier would bind only to such Model instances and their
properties
3. the business layer would provide the UI the model instances

Since the UI knows only about models, inner details are abstracted.

--
HTH,
Rakesh Rajan
MVP, MCSD
http://www.msmvps.com/rakeshrajan/

"Meya-awe" wrote:
I have a couple of questions, hopefully someone has come across this
before and can help me. (1) What are the various ways i could separate
my apps UI from business logic - could you provide bare bone example?
(2)I am using a third party supplier library and one of the requirements
is to be able for the app to have the capability to plug in various 3rd
party supplier libaries. i.e. if we go with company X, later when
company Y has a similar product, we can do minimal or no changes and use
the company Y's library instead of the one from company X.

I know these two question may somewhat be related. I appreciate any help
you could provide.
thanks,
BRAMOIN

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #2
My supplier library provideds some of the computation necessary in the
business logic.
I am using C#. The problem i have is not understanding the concept but
it is the implementation. That is why i need to look at examples. It
would be good if you could point me to material which provide not only
an example but also an explanation of what is happening.
thanks,
BRAMOIN

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #3
1. For the library independance part

You could create an interface that wraps the library's provided
functionality, that declares methods that you are going to need. You
may also have to create objects that support this functionality. Then
you can create implementations of this interface with any library. e.g.
for an application that returns Customers

// the interface declaring the needed methods
public interface ICustomerProvider
{
Customer GetCustomer(int customerID);
}

public class Customer
{
public string CustomerName;
}

/// Implementation of the interface for XCompany library
public class CompanyXCustomerProvider:ICustomerProvider
{

private XCompanyLib_instance;
public CompanyXCustomerProvider(XCompanyLiblibInstance)
{
_instance = libInstance;
}

public Customer GetCustomer(int customerID)
{
CompanyXCustomer customer = _instance.GetCustomer(customerID);
Customer retCust = new Customer();
retCust.CustomerName = customer.Name;
return customer;
}
}

You can create a Factory for these implementation classes, sealing your
code totally from them ... something like :

public class CustomerProviderFactory
{
private CustomerProviderFactory()
{
//private because we do not need to instanciate the class
}
public ICustomerProvider GetProvider(string company)
{
//based on a key pick the appropriate library
if (company.Equals("XCompany"))
{
return XCompanyCustomerProvider(new XCompanyLib());
}
}
}

2. For the UI/Business Logic problem, .NET provides a pretty good model
of seperation with ASP.NET and COM+. You should check the
documentation.

The posted code is not tested or even compiled... it's just an
expression :)

Tasos

Nov 17 '05 #4

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

Similar topics

4
by: Simon Harvey | last post by:
Hello Chaps, Me and a collegue have been talking about where the best place to put business logic is. I think that the best place is where Microsoft suggest - in a seperate business logic...
5
by: Shibu | last post by:
Hi, I have a situation where I need to convert business objects to a flat table. The reverse is also required. I am using c# and Oracle ODP. I am looking for an easier method to do the below...
25
by: Stuart Hilditch | last post by:
Hi all, I am hoping that someone with some experience developing nTier apps can give me some advice here. I am writing an nTier web app that began with a Data Access Layer (DAL), Business...
3
by: mca | last post by:
Hi everyone, I'm new to asp.net and i have a question about separating the html code from the programming code. i have an unknown numbers of entries in my table. I want to make a hyperlink...
8
by: Jeff S | last post by:
Please note that this question is NOT about any particular pattern - but about the general objective of separating out presentation logic from everything else. I'm trying to "get a grip" on some...
4
by: randy1200 | last post by:
I have a WinForm class that has accumulated a tremendous amount of logic code. Can anyone point me toward a good article on factoring logic code out of a WinForm class? Thanks, -- Randy
5
by: Ronald S. Cook | last post by:
We have a Windows app which contains UI code and all classes that perform business logic and make calls to database stored procs (located on a database server - i.e. not local to the app). My...
2
by: Chris Zopers | last post by:
Hello, I would like to know what's the best way to implement a business logic layer between my user interface and my database. I would say I'd make a dll-project for the business logic layer...
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.