[
https://issues.apache.org/jira/browse/IVY-434?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12480831
]
Xavier Hanin commented on IVY-434:
----------------------------------
In third step I've "finished" the split of the Ivy class, it's now almost only a
Facade to other objects, most of them being "engines" dedicated to
each feature of Ivy.
I've also just checked in a modification on the API of the deliver
method. I took deliver as an example, but my plan is to follow the
same recipe for other methods, if feedback is positive.
What I've done is introduce a DeliverOptions class which stores most
of the parameters the deliver method was taking. Well, when I say
most, I mean all the parameters which have a default value. So now you
can easily call deliver with default values only, or setup a
DeliverOptions manually to configure the algorithm. The advantage I
see is that if we want to add a new option, we just have to add the
attribute with getter/setter, and the API of deliver does not change.
Another thing is that it improves readability, especially when you
have several boolean parameters, it's very difficult to know what
you're actually doing in your call.
For instance, compare these two calls:
Ivy 1.4:
ivy.deliver(mrid, "1.5", cache, "ivy-[revision].xml", "release", new
Date(), pdrResolver, false, true)
Ivy 1.5:
ivy.deliver(mrid, "1.5", "ivy-[revision].xml",
new DeliverOptions()
.setStatus("release")
.setPubdate(new Date())
.setCache(cacheManager)
.setPdrResolver(pdrResolver)
.setValidate(false)
.setResolveDynamicRevisions(true));
The second is longer, but I think it's much cleaner too. And note that
it's long because we set all options, but if we want to use default
values for everything except the status, for example, then we can do:
ivy.deliver(mrid, "1.5", "ivy-[revision].xml",
DeliverOptions.newInstance(settings).setStatus("release"));
The problem is that it changes the API, thus requiring a lot of work
to migrate tools using Ivy 1.4 API. That's why I've added a Ivy14
class, which provide a 1.4 compatible API, so that if you don't want
to use the new API, you can simply replace your instance of Ivy by an
instance of Ivy14, and you're done!
> refactor Ivy source code to improve readibility
> -----------------------------------------------
>
> Key: IVY-434
> URL: https://issues.apache.org/jira/browse/IVY-434
> Project: Ivy
> Issue Type: Task
> Affects Versions: 1.4.1
> Reporter: Xavier Hanin
> Fix For: 1.5
>
>
> Ivy needs some refactoring to ease the understanding of its code base for new
> developers. The migration to ASF is good moment to make this refactoring.
> Note that I open this issue really too late because most of the work is
> already done, but I want to keep track of what has been done in something
> easier to include in the release notes than the mailing lists.
> So I will copy some info from the mailing list to this issue:
> On 1/29/07, Xavier Hanin <[EMAIL PROTECTED]> wrote:
> Main focus:
> + split the Ivy class by features in:
> ++ IvySettings, which will be the result of the configure step (I do
> not use configuration to avoid confusion with module configurations)
> ++ ResolveEngine, which will be responsible for dependency resolution
> ++ RetrieveEngine, responsible for the retrieve step
> ++ and so on for each features/tasks
> The Ivy class will preserve an API similar to the existing one, but
> will only be a Facade to other classes. Moreover, methods taking too
> many parameters (like resolve) will be refactored to take a fewer
> number of parameters, using a class (like ResolveOptions for instance)
> to group those which are not first class parameters
> I will also work on the dependency resolution algorithm, and
> especially on IvyNode. I will split it into at least two classes, one
> representing the node in the dependency graph, and one with data
> related to the traversal of this graph during the resolution process.
> Another thing I'd like to address is to reduce the number of classes
> in the same package, and the number of packages of the same level
> (namely org.apache.ivy.* packages), to move to something more
> structured and hopefully less confusing.
> This refactoring will introduce many API incompatibilities, but it
> should hopefully help people to understand the code.
> This is only the big picture, I'll keep you informed of my progress,
> and try to process by steps to allow frequent feedback and
> discussions.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.