You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Benson Margulies <bi...@gmail.com> on 2007/12/20 23:41:40 UTC
7 parameter limit
Our PMD/checkstyle limit on the number of parameters is making me
crazy.
The process is as follows:
1) discover that a function is getting too long for the limit on the
number of lines.
2) try to refactor.
3) discover that I've really got more than 7 bits of information that
are in flight.
4) curse, and then make an extra class (it's like a SOAP wrapper class)
just to carry this stuff.
If anyone would care to look over my virtual shoulder and tell me how to
structure this code better, I'm game.
Re: 7 parameter limit
Posted by Fred Dushin <fr...@dushin.net>.
I guess it really depends on your application, but I personally try
to shy away from rigid types. Maybe it's the LISP/Prolog programmer
in me, but as a cons is the universal data structure, all you really
need is a list as a parameter. Or if you prefer, a map, which can be
expressed using cons.
You can of course make your maps "type safe", along the lines of the
CXF Message.
The next exercise for the reader is to design a similar type-safe map
which allows more than one entry whose value has the same type (which
sadly the Message type can't do).
(Hint: define a key type pair<T, S>, and instantiate keys using
pair<String, Class>.)
Call this type Foo.
You can then define one parameter of type Foo, which has all of the
expressive power and type safety of your previous one.
-Fred"NotTryingToBePedandticJustNotDisclosingIntellectualProperty"Dushin
On Dec 20, 2007, at 5:41 PM, Benson Margulies wrote:
> If anyone would care to look over my virtual shoulder and tell me
> how to
> structure this code better, I'm game.