Facade Pattern

I am having one bean whichis having

methods=========>

setName()

setAddress()

setPhoneNo()instead of setting individulaly

i am writingdatafacde(string name,String address,String phoneNo)

{

//doing initialization with this

}

My approach is calling datafacde() method with the attribute instead of calling individual setXXX methods.

Does this suffice the facade Pattern.

Pl help

[467 byte] By [rajpuniaa] at [2007-10-2 16:32:23]
# 1
From GOF...Facade: Provides a unified interface to a set of interfaces in a subsystem.One class is not a set.
jschella at 2007-7-13 17:36:24 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

Dear Friend,

I have two answers to your query

1) No writing a single method replacing a few other methods doesnt exhibit facade characteristics.

Any pattern come into existence with the way a few clalses are used,you have just written a method and it cant be considered as exhibiting the Facade patterns characterics.

read a briefing on facade pattern

Facade as the name suggests means the face of the building. The people walking past the road can only see this glass face of the building. They do not know anything about it, the wiring, the pipes and other complexities. The face hides all the complexities of the building and displays a friendly face.

This is how facade pattern is used. It hides the complexities of the system and provides an interface to the client from where the client can access the system. In Java, the interface JDBC can be called a facade. We as users or clients create connection using the 搄ava.sql.Connection?interface, the implementation of which we are not concerned about. The implementation is left to the vendor of driver.

2) Yes, your code fragment can be considered as exhibiting a facade pattern behavior. but with the following updations to ur code.

I assume that you have two programs 1)Class B - is that has this code fragment and other is ( class A )the class from which your invoking this code fragment

I also assume that you were making 3 subsequent calls the Class A to Class B.

Now your trying to incorporate a new method in class B which in turn invokes the 3 methods in it.

This is not facade pattern.

Now introduce a new class with the name C, in that write down the method which u were trying to write in Class B, from this new method make all ur invocations on class B.

conclusion with this the client can complete all its intendent operation with a single method call itself. The class which is actually maniputating the Person in untouched with the introduction of a new class.

vmaheshrajaa at 2007-7-13 17:36:24 > top of Java-index,Other Topics,Patterns & OO Design...
# 3
Thanks a Lot for Very Valuable Information.If You can Liitile more Explain with the help of code .It will be great HELP.Once Agian Thanks!!!!!!!!!!!!!!!!
rajpuniaa at 2007-7-13 17:36:24 > top of Java-index,Other Topics,Patterns & OO Design...
# 4
http://www.allapplabs.com/java_design_patterns/facade_pattern.htm
kilyasa at 2007-7-13 17:36:24 > top of Java-index,Other Topics,Patterns & OO Design...