Posted by vbrabant
on November 9, 2003 at 7:12 AM PST
I, as you certainly, like freedom. Especially in the style I am writting my code. But it's not compatible with a team approach and certainly not with Versionning tools. So, how to keep our freedom ?
I like freedom. And certainly freedom in coding style.
Why am I obliged to follow the team convention
public static final String hello = "HelloWorld";
in place of my convention
final static public String hello = "HelloWorld";
Why am I obliged to declare variables of the class before the constructor and methods, and not after ?
Why am I obliged to put open brackets on the same line than the declaration method, If I prefer the other style where I put the open brackets on the next line.
Why have I to indent my code with 8 spaces, if I prefer two spaces only ?
Why, why, why ?
Because you are working in a team, and when you are working in a team, you are obliged to follow somes rules, otherwize it's the chaos.
I can agree with that, but I think it's possible to solve that in another way than oblige people to lose their freedom.
i agree that it's really important that the code you share with other people follows somes code style rules, otherwize, it will be a nightmare when you have to merge, or patch, or diff two different versions of the class.
So, hereafter my proposition of a way of work.
- Take a source formatter product, like jalopy and customize it to format your code in your style.
- Create also another customization file, respecting the code convention of the team.
So, each time you receive a source from someone,
- just execute jalopy with your rules file and you will have a nice and readable source (in your mind).
Do, your modifications.
Before give it back to the team; reexecute jalopy with the rules file of the team, and you will have a ugly and unreadable source (in your mind) that will enjoy the others.
Thanks to the fact that jalopy can be integrated into NetBeans, it become really easier to do that. And by doing so, you keep your freedom of coding and your team leader continue to be happy