Helper classes

Luc Duponcheel luc.duponcheel at gmail.com
Mon Apr 15 13:49:13 PDT 2013


Hello,

Here is my opinion on this:

Functionality naturally belongs to interface, say Zyx, if one of it's
parameters is of type Zyx
(and if an argument passed to it is, naturally, eagerly evaluated).

Other functionality naturally belongs to helper class. say Zyxs (or
ZyxStatics for that matter).

for example:

 - transforming an element to a singleton list containing it naturally
belongs to the helper class
 - joining a list of lists naturally belongs to the helper class

On the other hand it is sometimes useful to have static versions of methods
in Zyx in Zyxs because they can naturally be used as method references.

About discoverability:

When, for example, working with lists, I hope that there will be zipper
functionaity transforming a tuple of lists into a list of tuples. That
functionality naturally fits in the interface Zyx (maybe with a copy in the
class Zyxs). I also hope that there will be unzipper functionality
transforming a list of tuples into a tuple of lists. That functionality
naturally fits in the class Zyxs. So, if you know what method you are
looking for (also in terms of its signature) you often know where to look
it for.

By the way:
my experimental JavaZ library (https://github.com/JavaZ) contains many
examples:

 e.g. bindF (a.k.a. map) in Zyx has a version liftF in ZyxStatics (its
method reference is used in foreach)

Luc

-- 
   __~O
  -\ <,
(*)/ (*)

reality goes far beyond imagination


More information about the lambda-dev mailing list