Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Collective memory (was: Good code patterns in Python)

Reply
Thread Tools

Re: Collective memory (was: Good code patterns in Python)

 
 
Michael Sparks
Guest
Posts: n/a
 
      07-06-2003
On Fri, 4 Jul 2003, Charles Shannon Hendrix wrote:
> if <something>
> <work>
> <more work>
> <add numbers>


If this is solely tabs, this is unambiguous with no special rules needing
invocation. If this is spaces, again, this is unambiguous with no special
rules needing invocation.

If this is tabs and spaces mixed, then this looks ambiguous, and you need
to look at special rules. That said, if you have one user who uses // for
comments in C++ and another who exclusively uses /* */ what happens when
the first user attempts to comment out the block of code by the second
user?

Also C has more corner cases due to allowing its block structure
delimiters being slightly inconsistant than anything else.

After all without checking how many C programmers could say what this
means:

if (<test>)
if (<another test>)
<do something>
else
<do otherthing>

Is that:
if <test>
if <test>
<do something>
else
<do something>

Or is it:
if <test>
if <test>
<do something>
else
<do something>

The "problem" really boils down to choosing to use language features
inconsistantly. This applies to C, C++, Python, Perl (eg allowing
whitespace in regexes or not), and even functional languages. You might
choose to always use braces for blocks even where not necessary, always to
use tabs rather than spaces (or vice versa) and so on.

In python I personally tend to find that only having one major decision to
make - spaces vs tabs actually makes interaction with others code a lot
simpler.

> One really funny problem was when I guy reformatted his Python code,
> around 15K lines of it, and basically unindented *ALL* of the code to
> column 1. It was the only recoverable copy of the code too.
>
> He had to read the entire program line by line to recreate the logic.


I changed all the permissions in /etc once by accident as well. (to 777
IIRC) This quite spectacularly busted my system, and that took a long
while to sort out. At the time that was probably a similar number of lines
affected by a pretty stupid simple action.

What's the moral? Backup regularly and often and especially before doing
something that touches a significant amount of stuff. (Where significant
means >2 hours to fix) It certainly isn't "permissions are bad", nor
"whitespace is bad".

Inconsistent functionality abuse combined with stupidity is pretty hard
for any system to cope with...

Regards,


Michael.


 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      07-07-2003
Michael Sparks wrote:
>
> > One really funny problem was when I guy reformatted his Python code,
> > around 15K lines of it, and basically unindented *ALL* of the code to
> > column 1. It was the only recoverable copy of the code too.
> >
> > He had to read the entire program line by line to recreate the logic.

>
> I changed all the permissions in /etc once by accident as well. (to 777
> IIRC) This quite spectacularly busted my system, and that took a long
> while to sort out. At the time that was probably a similar number of lines
> affected by a pretty stupid simple action.
>
> What's the moral? Backup regularly and often and especially before doing
> something that touches a significant amount of stuff.


Actually, the moral is "use a revision control system". Anyone not doing
so should not be programming professionally.(*)

-Peter

*) I speak as someone who programmed professionally without using a good
revision control system, for a while, and made some serious mistakes
as a result. Backups are *not* sufficient, but merely a slight step
up from doing nothing at all.
 
Reply With Quote
 
 
 
 
Max M
Guest
Posts: n/a
 
      07-07-2003
Peter Hansen wrote:

> Actually, the moral is "use a revision control system". Anyone not doing
> so should not be programming professionally.(*)


> *) I speak as someone who programmed professionally without using a good
> revision control system, for a while, and made some serious mistakes
> as a result. Backups are *not* sufficient, but merely a slight step
> up from doing nothing at all.



Arh ... that will never happen to me ... If you start using CVS systems,
whats next? Anti Virus software? Raid systems? backups? It will never
end. It's all just expenses.


regards Max M

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asking for an opinion from the collective wisdom here Devon Null C++ 24 06-14-2007 02:50 PM
seeking an opinion from the collective wisdom here Devon Null C++ 15 06-08-2007 11:40 AM
Council Complaints Clips (Collective) EricP Computer Support 0 02-02-2006 12:05 AM
where to find good patterns and sources of patterns (was Re: singletons) crichmon C++ 4 07-07-2004 10:02 PM
Good code patterns in Python Will Stuyvesant Python 10 07-02-2003 11:30 PM



Advertisments