[stats-dev] Formatting

Jim C. Nasby decibel at distributed.net
Sat Sep 13 10:52:05 EDT 2003


On Thu, Sep 11, 2003 at 10:54:57AM -0700, Benjamin Gavin wrote:
> Well a large bit of the 2-space indentation comes from me :)  I could care
> less what format we use, but it needs to be easy to do in vi. ;)

OK, let's go with 4 then since it's easier to read in.

> As far as SQL formatting goes, I fail to see how either of the two
> examples you gave are any harder than the other...  Personally I would
> vote for the version that's easier to read (and because that's the
> standard I tend to use), but again, I could really care less since they
> are both equally difficult (or easy) to code.
 
The first example is *much* easier to code, because every line begins at
a tabstop. To do the second format you have to line everything up by
hand.

Since it might not be obvious, the formatting for the first is 2 tabs
for extended select list, 1 tab for FROM/WHERE/GROUP BY/ORDER BY/etc.,
and 2 tabs for extended WHERE clause.

As for using a tool, I'm fine with that so long as it doesn't produce
code that's ugly or is hard to work with.

> Ben (TheJet)
> 
> --- "Jim C. Nasby" <decibel at distributed.net> wrote:
> > Now that we have a shiny-new codebase, I'd like to standardize on some
> > formatting. I'm not suggesting a big clean-up of the formatting at this
> > point, but we should at least standardize going forward. Right now, the
> > PHP seems to be a mix of 2 space and 4 space indentation. I think the 2
> > space code might be a holdover from the old codebase, but I'm not sure.
> > Also, there are sections of code that aren't indented to a proper
> > boundary at all; these should be cleaned up relatively soon ihmo.
> > 
> > Generally, we don't seem to have a lot of indentation levels, so I'd
> > personally prefer 4 space.
> > 
> > For query strings, I generally do this:
> > 
> > SELECT blah blah
> >         blah
> >     FROM table
> >     WHERE
> >         AND
> > 
> > and not this:
> > 
> > SELECT blah blah
> >        blah
> >   FROM table
> >  WHERE blah
> >    AND blah
> > 
> > The second form might be slightly easier to read, but I don't think it's
> > worth the added hassle.
> > -- 
> > Jim C. Nasby, Database Consultant                  jim at nasby.net
> > Member: Triangle Fraternity, Sports Car Club of America
> > Give your computer some brain candy! www.distributed.net Team #1828
> > 
> > Windows: "Where do you want to go today?"
> > Linux: "Where do you want to go tomorrow?"
> > FreeBSD: "Are you guys coming, or what?"
> > _______________________________________________
> > stats-dev mailing list
> > stats-dev at lists.distributed.net
> > http://lists.distributed.net/mailman/listinfo/stats-dev
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
> _______________________________________________
> stats-dev mailing list
> stats-dev at lists.distributed.net
> http://lists.distributed.net/mailman/listinfo/stats-dev
> 

-- 
Jim C. Nasby, Database Consultant                  jim at nasby.net
Member: Triangle Fraternity, Sports Car Club of America
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"


More information about the stats-dev mailing list