Thursday, September 13, 2007

Code Style

Having a specific coding style has become more apparent to me now that I work in a team environment. I have my way, which is of course the best, and everybody else has there way, which isn't nearly as good.

I'm sure if I could make the rules, I'd have everyone writing code according to my ways. Power corrupts and all that.

I have learned to accept others' ways though. It's been difficult at times. If the code is readable and it works, I usually just bite my tongue.

Strangely, I love to type. I manually create all of my scripts. I make my code "pretty." I don't use GUI tools to auto-generate table definitions, and I especially don't use tools to format my code.

Toad Formatter, or whatever it's called, is my enemy. I'm sure Toad is not the only one with some sort of auto-formatter and I don't like any of them. For some reason I believe it is an abomination.

When I get to do the technical interview, I scan their resume for SQL*Plus. If I don't see it, I ask them what tools they use. If they don't mention SQL*Plus, I'm skeptical of their abilities...until I get to the five constraints question.

This is not to say that people that use Toad or SQLDeveloper are bad coders or anything, it's just my preference.

So what's your preference?


Anonymous said...

Coding standards is one of those areas that can have adult programmers fighting like 5 year olds.

Years ago I worked in a company where the coding standards were so explicit and defined that they actually got in the way of the 'real work'. It got to the stage where every time you went to write a line of code you had to refer to the (very copious!) coding standards documentation to check how that piece of code should be written.

I tend to think you have to use some common sense when using coding standards, it should 'complement' the code (for lack of a better expression), comment the code where it needs to be commented (I've seen people add comments to a line like 'x := 1') and use sensible names for your variables.

I have one 'rule' really, if the piece of code I'm going to write won't easily be understood by someone else reading it, then I'll add a comment (because that 'someone' might infact be me reading the code in 6 months time wondering what the heck I did).


DomBrooks said...

I thought I was the only dinosaur out there with my hatred of autoformatters, especially Toad.

I always justify handcrafting everything as an extra sanity check (on the code)...

Patrick Wolf said...

Hi Chet,

just because someone is using an IDE like TOAD, SQLDeveloper or in my case I'm using PL/SQL Developer doesn't mean that they use the Formatter of this tool.

I also don't like them and "hand craft" my code to make it pretty! Haven't found the settings yet that make it as nice as my style and formating.

But they offer some other nice feature (at least PL/SQL Developer) like auto complete of variables, zoom into the code with just a click, ... which I don't want to miss anymore.


oraclenerd said...


I was at the same company! I know it's not style that counts as much as functionality, so I do bite my tongue. 5 years old, according to my colleages, that's how old I am. ;)

BTW, how can you and Patrick be commenting? Aren't you at/running a conference or something?

I'm apparently a dinosaur, but again, I'm only 5 (IT) years old.


I do use SQL Developer on occasion to so that I can see pre-formatted data returned. I don't have a bias against those tools per-se, they can help those with a strong foundation. I start woryying when people tend to start on those tools. Yes, it's easier up front, but you miss out on a lot of things.

I guess for me it just comes down to keeping my hand on the keyboard as much as possible. I even manage to keyboard my way through many of the APEX pages!

Patrick Wolf said...

BTW, have you already used my Oracle APEX Builder Plugin? It allows you to define keyboard shortcuts for the APEX Builder. Eg. F8 to run the page, F10 to "Apply changes", ...


oraclenerd said...

I have read about it (through your site of course), but since I don't get to use APEX day to day anymore, I haven't had a chance to try it out.

The ability to keystroke out though is a huge bonus for me.

Thanks Patrick!