The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: [OT] Coding style nazis



I guess coding style is all about readability.  what readable to a
proficient programmer could seem like tangled spaghetti to a novice like
me. Enforced coding standards are especially important if you have a large
turnover of consultants/contractors as we seem to.
Here we have a 30 page coding standards document which you *have* to
follow, sometimes you can escape it, but for a proper program any mistakes
get picked up on a code walk though! grr!
after a while you get used to coding as required I guess. here they are
big on whitespace, so you use tabs in SQL and declarations like:

SELECT		*
FROM		Customers,
Orders,
OrderLines,
WHERE		Customer.x = Orders.x
AND	Orders.y = OrderLines.y
/

stuff like that.  or

int 		x = 0;
std::string 	y = "test";

of course, using variables like 'x' and 'y' will get you shot! the like
long names like innerIteratorCounter whereas I'd just use 'i'.

makes it all readable though, and when people have stuck to it, my life
has been a lot easier too.  comments are included in our coding standards
to, but its pretty much, "you don’t need comments as you code should
be
self explanatory"!

take a while to get used to, but as people are brought in, they are given
a copy, and have their code checked to make sure they follow it.  It
covers everything from when to use a for loop over a while, to indentation
size (must use spaces not tabs!)

I get particularly told off for my inline if statements, but I love them :p


If (x=y) doSomething(); //neat 1 liner
If (x=y)
{
doSomething();
} //waste of space!

I would say on your example, number 2 is better, but we'd have the braces
unindented. all fun stuff!

ali


UKHA said:
> Ok,
>
> Totally OT, but there you go.
>
> I'm looking for some decent resources that will explain why my coding
> style is "wrong", anyone have any?
>
> I'm referring to stuff like why:
>
> for (my $x=0;$x<@_;$x+=2) {
> somestuff;
> somestuff;
> somestuff;
> somestuff;
> somestuff;
> }
>
>
> is better than:
>
> for (my $x=0; $x < @_; $x+=2)
> 	{
> 	somestuff;
> 	somestuff;
> 	somestuff;
> 	somestuff;
> 	somestuff;
> 	}
>
>
> (assuming yahoo doesn;t make a right old pigs ear of it)
>
>
> Andy
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
> ---
> [This E-mail has been scanned for viruses but it is your
responsibility
> to maintain up to date anti virus software on the device that you are
> currently using to read this email. ]
>
>
>

---
[This E-mail has been scanned for viruses but it is your responsibility
to maintain up to date anti virus software on the device that you are
currently using to read this email. ]




UKHA_D Main Index | UKHA_D Thread Index | UKHA_D Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.