Open cstenkes opened 5 years ago
Hi,
first of all please let me say that I appreaciate your effort. Your intention clearly is to improve the code quality and I understand it.
Having said that I am inclined not to accept the pull request as I think it fixes not the right things. Below are the main things:
// DEMATIC
comment. I guess this is the name of your company, I'm not sure this belongs to the code.strategy
should be renamed to strategy2
.leftFieldAccessor.toRawValue(ifShouldBeSetBlock, leftField)
with leftObject.invoke(createMethodName(fieldOutline))
is not correct.The PR seems to bring a lot of trivial changes which affect code formatting and make it harder to see substantial changes. So I'm sorry but I think it will be better not to accept this PR.
Let's try it from a different angle. Apart from "unnecessary" blocks, what are the important changes you'd like to apply?
Hi,
The reason why I look in the code at all were the followings:
After googling on the blocks inside a method indicates the next things:
Look at [https://stackoverflow.com/questions/1563030/anonymous-code-blocks-in-java]
Servus,
The reason why I look in the code at all were the followings:
- Massive amount of warnings in the generated code compiling by Eclipse 4.9 and Java 8 default settings
Too general - this should be broken into actionable items.
- Unnecessary blocks in the generated code, quite hard to understand why small code blocks inside a method. If you would like to separate code blocks an empty line is more than enough for the reader meanwhile I understand your reasons, but I have never seen such code in the last almost 15-20 years.
I suggest to leave this point out of discussion. I have a rather strong opinion on this. Write me off as stubborn, if you will, but please let us save time on this one.
At the moment, removed blocks in plugin code hinder me to review the PR since the code became not-quite-diffable and that's a practical problem.
- Unnecessary variable declaration, then variable value assignment instructions
This is how field accessor work in XJC. Please see com.sun.tools.xjc.outline.FieldAccessor
. Accessing properties directly via getters or settes is not the right way in XJC.
- DEMATIC - yes It is my company (a world wide storage automatisation giant), first I did just little changes indicated by this, later I have done more changes, and unfortunately these signs were left. I will remove it in the next commit, It is now on Github.
OK.
- @override added, because in the last official release (0.12) these were not part of code base (It is standard from Java 1.5)
Not quite sure which @override
you mean, not easy to see in the PR diffs. But we can work this out.
- lots of suppress warning where these are not necessary
Ok, we can work this out.
- lots of unnecessary variable casting like byte cast to byte automatically or int cast to int etc. Some not trivial has left in the code still like byte cast to short or int
Could you please give an example?
- Overall I was not satisfied the readability of the generated code anyway.
Would be good to break this into actionable items.
- I will need more simpleXXX plugin like simpleEqualsPlugin, because I would like not put too much dependency to my code becuse of a simple method like toString...
I'd absolutely welcome SimpleToStringPlugin
etc. I've just found out that implementing it correctly, also handling special cases like JAXBElement
is at least a little bit hard without some runtime code.
But I's surely welcome a contribution here.
I've created #105 and https://github.com/highsource/jaxb2-basics/tree/issue-105 to work on improving the quality of the generated code.
Less warnings, less castings, no unnecessary blocks