1

With no time to refactor, when you are working on legacy code, with the most awful conventions, what is the best practice?

Will trying to follow better coding style would improve readability or actually hurt it?

For example, in java method names are usually camel cased:

myGoodNamedMethod

But in the repository there are code with methods like this (not all, but the majority)

my_c_style_method_that_looks_off_in_java

asked May 9, 2013 at 22:30
1
  • 11
    Stick with what's there. No programmer likes another programmer's coding style Commented May 9, 2013 at 22:32

3 Answers 3

17

No matter how odd you find the existing conventions, FOLLOW THEM. Having some conventions, even if you don't like them, is FAR FAR better than not having any.

Obviously that's not always true (some conventions are outright hostile to getting work done, like limiting all names to 8 characters for no good reason), but except in the most extreme cases, just follow what's there.

answered May 9, 2013 at 22:49
3

Follow the existing standard.

However, if there's a genuine need to fix it (it's becoming a major problem), take a deep breath, man up and refactor the entire code base to follow a new standard. But only do this if it's truly necessary, have everyone's approval and if you have the time. It probably won't take as long as you might think, but do your research first.

answered May 10, 2013 at 0:54
1

Follow the existing standards. Maybe they're outdated/odd/wrong/unpleasent. (as long as they're not being hostile as @Michael Kohne mentioned).

There could be reasons outside of the language standards to be using the naming style. I have heard of people running 3rd party applications over the code base to pull out names for use later. Eg test names as requirements or auto building api documentation.

answered May 9, 2013 at 23:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.