2

I'm looking at a very large (5-6 digit LOC), very complex, code-base, full of interacting bulky, interdependent, views and stored procedures (multiple 4-5 digit count silos).

The source SQL has been touched many times, by many different people, and no formatting constraints have been enforced. This led to wildly differing formatting for SQL, even within single stored procedure/view definitions.

The code continues to be worked on by several groups of, mostly, senior programmers, and sees a steady stream of small changes and improvements.


Under these conditions:

a. what is a sane standard to conform to for formatting (eg, should we use all caps for keywords? seems like the small benefits from having so many programmers not have to press Shift actually add up to significant time/cost savings)

b. is it worthwhile advocating for a major refactor to standardize the formatting (ie, is the cost of training a large body of programmers/changing their behaviour/ill will at enforcing a new constraint worth the benefit in the long-term?)

    2 Answers 2

    6

    Agree to a sensible coding standard for future work, and fix the problem SQL as needed during refactoring. Leave intact all of the code that is working that otherwise doesn't need to be touched.

      0

      what is a sane standard to conform to for formatting [SQL] ?

      Something that you can express in programmatic form, so that you can send a text file to a program and know if the format is "standard" or not.

      Ideally, the rules you care about will be the kind you can automatically impose on a non-standard file or block of text, such as "capitalize all keywords" or "wrap each field on its own line."

      is it worthwhile advocating for a major refactor to standardize the formatting?

      No. If the code isn't broken, and you're not making an improvement in the final result, you don't want to touch it and risk breaking it.


      As an aside, the benefit of code standards is NOT to increase write-time productivity. Rather, a good formatting standard will reduce the time it takes for a programmer to look at code they haven't touched in awhile, if ever, and see what's going on.

        Start asking to get answers

        Find the answer to your question by asking.

        Ask question

        Explore related questions

        See similar questions with these tags.