471,306 Members | 1,260 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Facade Classes ????

I had a problem in my OO Design, the idea
is that i have a DataRepository Class That i want to only inherit from
it speacial methods accourding to the child class, like i want the
Client Class to just inherit GetClientInfo() from the DataReposiotry
Class and the Order Class just inherits GetOrderInfo() and so on

any ideas how to do this, it has been suggest to use facade classes!
would you be able to show how it can be done in a couple of lines of
code for demonostration as i am totally new to Facade Classes or suggest
any other approach!??

Thanks,


Sharing makes us all Better

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Dec 11 '05 #1
1 1448
Facade classes are interfaces that simplify the actual object by
limiting what you see. (that's just my interpretation...I could be
wrong.)

For example, a "StudentRecord" could have grades, majors, advisors,
gpa, etc. But all that you may want to deal with is "Contact
Information." How would you determine what functions/properties deal
with the "Contact Info." Some people might put prefixes on their
function names, but that only goes so far. My preferred solution for
this a "IContact" interface.

I'm just going to give a quick step by step description... and there is
code snippet below. I used your "DataRepository" and "OrderInfo" as an
example.

1) I would create an "IOrder" interface that has a function called
"GetOrderInfo()". I would also suggest a function called
"GetOrderFacade()", which returns an instance of "IOrder".
2) Then have the DataRepository implement that interface.
3) To use the IOrder interface .... just say

orderObj = dataObj.GetOrderFacade();
orderObj.GetOrderInfo();
//************** Start Code *********************\\
public interface IOrder
{
object GetOrderInfo(); //Change the "object" to your liking.
IOrder GetOrderFacade();
}

public class DataRepository
: IOrder
{
public object GetOrderInfo()
{
return "Some Order data";
}

public IOrder GetOrderFacade()
{
return (IOrder)this;
}
}

//************** End Code **********************\\

So, whenever you want to deal with the "Order" infromation only, just
use the "GetOrderFacade()" and it will only return to you functions
related to "Order".

The benefits of this is that it limits the users accessible functions.
A "sales person" can only deal with "orders"...so just return them an
"IOrder" interface :)

Good luck... I hope this helps :)

josh

Dec 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by bdinmstig | last post: by
1 post views Thread by bdinmstig | last post: by
1 post views Thread by Daniel Kabs | last post: by
reply views Thread by Dave Johnson | last post: by
1 post views Thread by Dave Johnson | last post: by
1 post views Thread by anonymous.user0 | last post: by
6 posts views Thread by =?Utf-8?B?TWFyaw==?= | last post: by
7 posts views Thread by splendid9 | last post: by
reply views Thread by rosydwin | last post: by

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.