Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] JGit Client API

On Sun, Apr 18, 2010 at 1:13 PM, Christian Halstrick
<christian.halstrick@xxxxxxxxx> wrote:
> And for me the next best alternative is option b) , the Builder
> proposal from Shawn. I would hate to be forced to explicitly
> instantiate <command>Options classes when just want to fire a simple
> git command with one parameter.

Well, really common cases we can try to overload.  commit() to create
a builder, versus commit(String message) to create the builder, set
the message, and execute immediately with the rest of the data
assumed, just like `git commit -m message` behaves.  But we do have to
be careful, we can't overload too much.  I wouldn't suggest
overloading commit more than just the String message case, anything
else just gets to complex too fast.

The only problem with the builder approach is, its easy to forget that
final verb method to fire the actual action.  With the more
traditional Java approach, that's less likely.  I still kind of prefer
it though, its easier to work with inside of an IDE where completion
is available based on context, and it can often produce shorter code
in the hands of a novice.  It also plays somewhat nicely with
dependency injection, since the library code controls construction of
the builders, not the user code.

-- 
Shawn.


Back to the top