I recently hired into a data analytics team for a hospital, and we don’t have a style guide. Lots of frustration from folks working with legacy code…I thought putting together a style guide would help folks working with code they didn’t write, starting with requiring a header for SQL scripts first as low hanging fruit.

Or so I thought.

My counterpart over application development says that we shouldnt be documenting any metadata in-line, and he’d rather implement “docfx” if we want to improve code metadata and documentation. I’m terrified of half-implementing yet another application to further muddy the waters–i’m concerned it will become just one-more place to look while troubleshooting something.

Am I going crazy? I thought code headers were an industry standard, and in-line comments are regarded as practically necessary when working with a larger team…

  • @[email protected]
    link
    fedilink
    11 year ago

    Your friend may have a point.

    It depends where the SQL is.

    Is the SQL in a data model in an analytics platform? Some platforms will happily carry comments around like last week’s pizza during query generative phases of visualization, so it may not be appropriate to put comments inside a data model, as those comments could become bugs if the analytics platform is lame, like most are.

    Others, certain flavors of SQL DDL (Tables, views, etc), comments outside the DDL don’t make it inside the resulting object, so headers may not be the right place either. Most RDBMS have meta-descriptors that can apply to DDL so those might be good to look at.

    For arbitrary SQL, outside a brief inline comment describing why it exists, and what invokes it, your next best bet may be a link to a more descriptive data architecture diagram that shows how this unit of SQL integrates with others. You might prefer hyperlinked descriptions from that data architecture over searching thru code.

    As long as comments don’t require continual parsing (a one-time tax is inconsequential), definitely add details that you have figured out so others don’t have to re-learn the tribal mysteries of long-deceased ancients.