[
https://issues.apache.org/jira/browse/OFBIZ-6783?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15281260#comment-15281260 ]
Taher Alkhateeb commented on OFBIZ-6783:
----------------------------------------
Hi Hans,
I'm glad you're participating. FYI This is becoming more than just refactoring start as I'm also changing Config, CommonsDaemonStart and 2 build.xml files.
Anyway, back to your question, I'm a guy who's acquired TDD down to my bones. However, testing the changes here pose multiple challenges and I appreciate your feedback on them:
- The code is still horrible and messy and everything jumbled together. So I can not do isolated unit tests in most places. I still need to refactor and breakdown the code some more to make it clean and testable.
- The start component does not allow for testing (it's bootstrapping code). So the only way I can test anything is from another component (say, base).
- The magic work of commons-cli is all happening in StartupCommandUtil.parseOfbizCommands(args). However, I declared it package protected. If I want to test it, then I have to declare it public, and I'm trying as much as I can to isolate start from the rest of the framework.
I worked hard to decouple ofbiz from both the command line arguments and also from commons-cli. Start is a special component in which it is not easy to test. In fact, it was really hard work to change build.xml to make it work with the commons-cli jar.
So in summary, I'm not sure what the best course of action is, but I feel exposing my methods as public only for the purpose of testing is not a pretty solution. The same can also said about reflection.
Maybe I can create a public adapter class or something, I'm not sure. Do you have any thoughts?
> Refactor start.java
> -------------------
>
> Key: OFBIZ-6783
> URL:
https://issues.apache.org/jira/browse/OFBIZ-6783> Project: OFBiz
> Issue Type: Improvement
> Components: framework
> Affects Versions: Upcoming Branch
> Reporter: Taher Alkhateeb
> Assignee: Taher Alkhateeb
> Labels: framework, main, refactoring, start
> Attachments: OFBIZ-6783.patch, OFBIZ-6783.patch, OFBIZ-6783.patch, StartCommandUtil.java
>
>
> Looking at the main method and design of Start.java looks ugly. The things I would like to fix so far are:
> - the file is too long
> - some variables are not even needed (loaderArgs?)
> - the level of abstraction is wrong
> - main throws an exception!
> - the arguments processing logic is terrible, need to move it to commons-cli
> It's just so messy and ugly to look at. So for me refactoring starts at Start! Given that this is an important file, I will provide a patch to be reviewed by the community before committing just to be on the safe side.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)