See my intermixed comments below 

 

 -----Original Message-----
From: Alan Mehio [mailto:[EMAIL PROTECTED]
Sent: 09 November 2004 10:25
To: Pilgrim, Peter
Subject: Struts Networking BOF III Summary Report please amend

 
The fifth BOF was just a meeting I slotted into the November hole. It seems
that it was too soon for many people after the last one (22/10/2004) so I have
learnt from that. The next BOF will be on the Friday 10th December 2004,
almost one month exactly, and then the next BOF VII will be probably in late
January sometime.
 
At the moment, for the Xmas BOF I have decided to try out Wagamamas in
Leicester Square. We can probably go for a beer before and/or afterwards.
 
So if you have a different suggestion for a restaurant, NOW IS THE TIME TO
SHOUT, 
SHOUT and let it all out.  Sorry been gripped by Tears 4 Fears just for a
moment, there.


 

 

The meeting was very technical and the focus was explaining different patterns
and why we use them.

Ref: http://home.earthlink.net/~huston2/dp/patterns.html
<http://home.earthlink.net/~huston2/dp/patterns.html> 

 

 

Factory 

1-     Concerning the Factory pattern, we use it to hide and centralize the
object creation 

2-     To  create different object based on some flag parameter 

3-     Flexibility to change the classes in the factory without touching
affecting the code 

4-     Can be exteranlize in an xml file using JNDI to create different object

5-     For example  the creation of the mail session below. 

 

<!-- Mail Session -->

    <Resource name="mail/Session" auth="Container" type="javax.mail.Session"/>

      <ResourceParams name="mail/Session"> 

        <parameter>

                  <name>factory</name>

                  <value>org.apache.naming.factory.MailSessionFactory</value>

            </parameter>

        <parameter> 

            <name>mail.smtp.host</name>

                <value>%SMTP_SERVER%</value> 

            </parameter> 

      </ResourceParams>

 

+1


The factory, I believe, is used to decouple the construction of the object

instance if the type is not known in advance. So you can say that it 

"hides" creation, but even better to say the factory "virualises" it.

 

We gave example about creating a wall in construction industry. Imaging you
have a factory to create a walls for you and to ship the wall to the
construction site to be assembled. If you have on site wall construction, it
will be spread on each floor of the building; as a result, if you want to
change the type of wall from concrete into bricks, you should walk through
each floor and make your changes. If you have a factory, you hide your
internal creation and centralize it. In the factory, you can change the type
of wall without any effort only you make a switch in your internal process.

 

 

    Abstract Factory 

 

The purpose of the Abstract Factory is to provide an interface for creating
families of related objects, without specifying concrete classes

Builder focuses on constructing a complex object step by step [GOF, p126]

Abstract Factory emphasizes a family of product objects [GOF, p105] 

 

 

My mind went completely blank at the meeting. I remember what the
AbstractFactory really is. The best implementation

of it is obvious the Swing JFC classes, namely the pluggable look-and-feel for
Metal, Windows, Motif and Organic.

 

If anyone with JDNC experience wants to chime in here, be my guess. 

    

Often, designs start out using Factory Method (less complicated, more
customizable, subclasses proliferate) and evolve toward Abstract Factory,
Prototype, or Builder (more flexible, more complex) as the designer discovers
where more flexibility is needed. [GOF, p136]

If we take a factory to construct a wall or a geometric shape, we define the
frame work for construction; for example, the wall: height, width, depth,
location etc..

And we leave the wall's material to the implementer class. So the material is
an abstract method.  Peter can you give the example of the Geometric shape
factory

 Tim P will probably know this from his C++ programming. The best examples I
ever saw were in Jim Coplien's "Advanced C++". 

Basically any book or paper of about OO GUI toolkit such as Swing, AWT, SWT or
even ancient OSF Motif and Xt will reveal these patterns.

 We will have a factory which build the real wall like: concrete, glass,
bricks, plastic, etc.. ; concerning the Geometric shape, we have a factory to
build circle, line, square, 3 d shape, etc..

 

Why we use the Abstract factory, it is simple since we do not know what we
want exactly to build and we only know the general idea like Geomertic shapes,
Walls so it will work like a guide lines to produce Shapes and Walls without
any specific implementation details. 

 

 

Visitor ( Behaviour Pattern)

Problem: Many distinct and unrelated operations need to be performed on node
objects in a heterogeneous aggregate structure. You want to avoid "polluting"
the node classes with these operations. And, you don't want to have to query
the type of each node and cast the pointer to the correct type before
performing the desired operation.

I gave an example of  StarBuck café where you find a chained of café shops
with head quarter, branches and sub branches. Let us say we need some object
to go through all the café shops hierarchy in order to generate a report if
the kitchen is not clean in any of the branches; For example,  branchX.clean()
= false --> generate action report where X can be any of the super, sub or
regular branch {Super,Sub, Regular, Main}

It will be very difficult if the object belongs to one of the branches  (bias
behaviour)   to make the traverse through the objects herarchy. We need an
object visitor to  make the visit as a indepent object. Peter please can you
give the space ship collision 

Alway did at the top the pile. I have seen Visitor in computer games
programming.

 

Singleton ( Creational Pattern)

Problem:Application needs one, and only one, instance of an object.
Additionally, lazy initialization and global access are necessary.

Example is the Srvice Locator  which has one instant to do the following  or
the org.apache.struts.action.ActionServlet ( Not pure Singleton ??)

1-     Srvice Locator  Create  Business Object and Data Access object

2-      Srvice Locator   Cache the above object 

Problem is that the Service Locator needs a Resource manager to get rid of the
none used cached object or to use weak hash 

 

Peter please mention that we need an object to get into global resources ( It
can be database connection pooling, or Mail Session Factory, etc..)

The service locator is different to a singleton. I think, a service locator is
a kind of programming "finder" service.

You use it to find a business object, where as a singleton is more vague
defined. The singleton may in fact also

be the global service provider (i.e. the universal laser printer )

 

Those of you who are into multi-thread programming will know that this picture
is even confused when consider

"ThreadLocal" static objects. Now are "ThreadLocal" objects really singleton
or not.

 

 

Chain of Responsibility (Behavioral Pattern)

 

Problem: There is a potentially variable number of "handler" objects and a
stream of requests that must be handled. Need to efficiently process the
requests without hard-wiring handler relationships and precedence, or
request-to-handler mappings.

1-     Decrease the coupling inside a process by making sub processes where
each are specialised in certain task ( professionalism approach like process A
is professional in dealing with caching etc..)

2-     It gives use to break the  multi task complex process into independent
processes ;

3-      More flexibility to assemble our chain of  processes  for different
usage; for example, I do not need processes A,B,C,D  in this order but rather
I need different chain and different processes like C,A,D

4-     Allow us to get rid of inheritance, let us say class B inherit from
class A, but we want to use class B with out the need of the super class
constructor way of sending parameters ( method signature). B can be a stand
along now and is highly specialized in doing a very specific task 

5-     We have the choice to assemble our main processor in different way,
which gives us different outcomes that serve different needs 

 

Hmmm I came to the CoR discussion from the point of view of the framework
developer (Expresso). 

I can see how the  Chain of Responsibilty pattern solves the "composable
request processor" riddle, 

but it also paves the way for future MVC application featuring  "micro"
command that are chained

together to form "processing line". If you are into music applications or
synthesiser you can

appreciated this form of delegation (Square wave Oscillator into Low pass
Filter into Digital Delay feedback

into oscillator).   If I understand the new architecture right, we will be all
at some point making 

some little "action chain" in our future Struts application. This is because

the current Action object can be refactored a Chain Command impl.

 

Peter, I tried to give my version please amend   

 

Grief I hate the Microsoft HTML EMail mode. I cannee control the Font Size, or
exact mark up. Sheez. 
I will blog this up later on today or tonite. Sorry for the mess.
 

--
Peter Pilgrim
Operations/IT - Credit Suisse First Boston,
10 South Colonnade, London E14 4QJ, United Kingdom
Tel: +44-(0)207-883-4497



 

==============================================================================
This message is for the sole use of the intended recipient. If you received
this message in error please delete it and notify us. If this message was
misdirected, CSFB does not waive any confidentiality or privilege. CSFB
retains and monitors electronic communications sent through its network.
Instructions transmitted over this system are not binding on CSFB until they
are confirmed by us. Message transmission is not guaranteed to be secure.
==============================================================================

Reply via email to