Hacker News new | ask | show | jobs
by moocow01 4939 days ago
I guess what Im saying is if you could have a tool that could compare 2 pieces of source code, be able to merge them, and maintain the formatting of each persons local copy it would be great. Its probably a pipe dream because your version control would have to have an intimate knowledge of the specs of any particular language used in the source code (nevermind the version of the language you are using)
1 comments

Yes, for merging, that would be incredibly helpful.

But what I'm saying is that the formatting of a file may contain contextual clues that will help someone reading the code to understand what it does. Formatting isn't just chrome around the code.

Example: In Java, when writing a custom predicate to filter by foos that are bars, I prefer

        filter(myList, new Predicate<Foo>() {
            @Override public boolean apply(Foo foo) { return foo.isBar(); } });
to

        filter(myList, new Predicate<Foo>() {
            @Override
            public boolean apply(Foo foo) {
                return foo.isBar();
            }
        });
(filter is statically imported from Collections2 in Guava)

especially when there are multiple of them and they line up neatly underneath each other.

Any meaningful autoformatter would change the latter to the former, and in the process loose readability.

EDIT: Another example would be when using the builder pattern - getting those methods to line up to be neatly readable often takes some none-standard indentation.