directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ole Ersoy <ole_er...@yahoo.com>
Subject Re: Class + Class Helper Pattern
Date Tue, 13 Feb 2007 19:57:04 GMT
There's no coupling in the Class + ClassHelper
pattern, except for the coupling between the Class and
the ClassHelper.

If someone were to do use ClassA's helper ClassAHelper
for ClassB, they are breaking the pattern.

The process for doing that would be to move the method
they are using on ClassAHelper into a utility library.

So the Helper works like a utility library that is
specfic to a single class.

This makes it easier to refactor the code base and
move Helper methods into utility libraries later.

Cheers,
- Ole


--- "John E. Conlon" <jconlon@verticon.com> wrote:

> Emmanuel Lecharny wrote:
> > Hi Ole,
> >
> > I will give you my opinion about unit tests and
> method protections. Do 
> > not consider it anything else than my personnal
> opinion, based on my 
> > own feeling and 25 years of coding experience (not
> always happy).
> >
> > On 2/13/07, *Ole Ersoy* <ole_ersoy@yahoo.com 
> > <mailto:ole_ersoy@yahoo.com>> wrote:
> >
> >     Hey Guys,
> >     <snip> 
> >
> >
> >     You'll notice that I used a
> >     Class + ClassHelper pattern.
> >
> >     So I can have all the methods public on the
> Helper,
> >     thus I could easily test them all.
> >
> >     I asked others one the JUnit list if there are
> any
> >     security risks to having all public methods.
> >
> >     They said not really. 
> >
> >
> > if you ask people who never add any accident
> driving without a seat 
> > belt, they will tell you that the risk is very
> limited. private 
> > methods is a kind of seat belt you like to have
> when you hit a wall.
> If God (See below) wanted all methods public he
> would have not inspired 
> his prophet Gosling to make some private. 
> 
> Seriously the more private our classes the less
> external coupling, the 
> less coupling the faster we can adapt to change.  We
> have a large code 
> base right now.  The more it grows without
> introducing the idea of 
> decoupling the harder it will be to change it in the
> future.  Adding 
> more classes for testing and introducing the idea of
> all public methods 
> is moving in the opposite direction then IMHO we
> need to go.
> 
> >
> > IMHO, trying to cover all the code with test (ie,
> 100% test coverage) 
> > is useless, because it's simply impossible to
> guarante you will get a 
> > 100% coverage (
> http://en.wikipedia.org/wiki/Kurt_G%C3%B6del)
> >
> > The more that we can do is to do our best.
> >
> > Now, that being said, about helper classes :
> > 1) a method is private because we don't want to
> expose it to the 
> > public. When you write such methods, as you can't
> test them easily, 
> > you have to be very carefull. The parameters
> should be tested, and 
> > 'assert' is a good way to do so. At some point,
> ypou can also test 
> > those methods simply by testing the public method
> which use it.
> > 2) having 2 classes instead of one drive you to
> double the number or 
> > bugs. This is mathematic.
> > 3) Sometime, tests are simply wrong. You may have
> to double check the 
> > tests, and fix them if needed. If you have a
> classhelper  in between, 
> > you may have to check two classes instead of one
> (the test plus the 
> > helper class). This is adding some burden.
> > 4) Having two classes to maintain is really
> problematic. The more 
> > classes you have, the more work you will have to
> do. All this work 
> > won't be put into the single class, so one can
> think that this 
> > helperclass drives the developper to loose focus
> on what is really 
> > important.
> > 5) If the developper has choose to declare a
> method as private, 
> > public, protected, or with a default protection,
> it is because he 
> > sometime has good reason. This is somehow the
> basis of OO design. I 
> > don't want to loose this, I don't want to go back
> to C or, worse, Basic.
> > 6) From a user friendliness point of view, I
> really like to see at 
> > first glance which are the public methods of a
> class (they are green 
> > in Eclipse).
> >
> > Ok, now, this is not only my opinion. It's also
> somthing I will push 
> > strongly if voted. I must tell that I will veto
> such a decision (to 
> > have all methods public) if asked. Of course, if
> i'm the only one to 
> > veto such a decision on the project, I will
> dismiss, naturally. I'm 
> > not threaten anyone, I'm just saying that I don't
> think we should 
> > change the way we are coding. I try to be
> pragmatic : we are writing 
> > an Ldap Server, not a giant unit test system
> around an LdapServer. We 
> > are already have somthing like 3 000 tests, and we
> add a few every 
> > single day, I'm confortable with it.
> >
> > Trying to reach perfection is insane. Even God
> can't do everything 
> > perfect : he created mankind :) (ok, for people
> like me who don't 
> > believe in God, think about the Chaos Theory... )
> Emmanuel your viewpoints do not appear to originate
> from a chaotic 
> source, nor I think, if we followed them would lead
> to a chaotic source. 
> :-)
> 
> cheers,
> John
> 



 
____________________________________________________________________________________
No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail 

Mime
View raw message