473,692 Members | 2,470 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1540
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 "StudentRec ord" 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.GetOrde rFacade();
orderObj.GetOrd erInfo();
//************** 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1820
by: bdinmstig | last post by:
I am building various framework components for my team to use in development, and one of those components is a Facade for reading/writing user preferences. The idea is that preference settings are stored in a free-format XML document (in memory for the life of the session) and persisted to a database (as free text) on exit. I have taught my developers the basics of XPath, however I don't want to have to review XMLDOM code all over the...
1
6821
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for elements, attributes, ".", and "..", plus also the "" predicate format is supported - however, only one predicate per path step is supported, and expr must be a relative path. 2. Poor performance
1
1636
by: Daniel Kabs | last post by:
Hello, loading images or refreshing IFRAME content is done asynchronously in Javascript. You just assign a value to the src attribute of the object and you are done. Once loading is finished, the event handler will inform you. This is wanted behaviour in most situations but sometimes its just a pain. Imagine, you have this kind of "call" in a deeply nested function. As it will return immediately, how do you wait for the result? You...
11
4300
by: FluffyCat | last post by:
In Febraury - April of 2002 I put together in Java examples of all 23 of the classic "Gang Of Four" design patterns for my website. Partly I wanted to get a better understanding of those patterns. They are still online at http://www.fluffycat.com/java/patterns.html Since September 2003 I've mainly been using PHP, and now that PHP 5 is becoming more available I am going to try the same thing I did in Java with PHP.
0
1193
by: Dave Johnson | last post by:
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...
1
1190
by: Dave Johnson | last post by:
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...
1
3990
by: anonymous.user0 | last post by:
I'm a little confused about the Facade pattern. As I understand it, it's supposed to be a single, simplified interface into a larger amount of subsystems. The question I have is basically how simple and interface is it supposed to be? Lets say I've got an application with multiple layers in differenct projects. I've got a Core project that contains the core business objects and Managers for those objects. Managers are responsible for...
6
1787
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... Tried posting this on Build Controls but then saw that's a pretty slow group... Kind of a typical request from product management - they want to be able to swap in different 3rd party controls depending on their whim and the day. In this case, they want to support FreeTextBox and Cute Editor interchangably. I've been trying to put together a container control derived from
7
1649
by: splendid9 | last post by:
hello all, i am wrinting unittest for my webservice facade, i could not directly pass the object that i am passing in my original webservice facade in my unit test, so i am trying to create a mock object(class which contains all the properties that are used by my original facade) and pass that into my unit test method, but i dont know how to do that, i mean how to create a mock object uin my unittest and pass that in my unittest method, could...
0
8547
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9090
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8812
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7639
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5822
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4329
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4564
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2242
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1962
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.