Re: Seven habits of highly careful coders
by gryphon (Abbot) on Sep 13, 2003 at 22:58 UTC
|
Greetings mandog,
At my job, I've instituted a lot of standard coding practices for our department. Here are a few that I think are habits of careful coders:
- use strict;
- use warnings;
- Use CPAN for as much of the work as possible
- Use tainting when dealing with CGIs
- POD or otherwise document everything (if not in POD, have a good reason why)
- $CGI::DISABLE_UPLOADS = 1;
- $CGI::POST_MAX = 4092; (or some other appropriate number)
gryphon
code('Perl') || die;
| [reply] [Watch: Dir/Any] [d/l] [select] |
Re: Seven habits of highly careful coders
by adrianh (Chancellor) on Sep 13, 2003 at 23:23 UTC
|
Did I read what is on the screen
After some particularly egregious mistake I made about ten years ago I added the following to the end of my .login script:
echo "REMEMBER: place brain between eyes and fingers before beginning
+to type..."
It's advice I still need to read on a daily basis :-) | [reply] [Watch: Dir/Any] [d/l] |
Re: Seven habits of highly careful coders
by Plankton (Vicar) on Sep 14, 2003 at 03:25 UTC
|
When writing code, imagine that programmers that will have to maintain your code are psychotic axe murders that know where you live!
Plankton: 1% Evil, 99% Hot Gas. |
| [reply] [Watch: Dir/Any] |
|
Personally, I find it better to imagine that I will have to maintain my code, six months from now. Finding the intersection between yourself and the psychotic axe murderer is left as an exercise for the reader...
Chris
M-x auto-bs-mode
| [reply] [Watch: Dir/Any] |
Re: Seven habits of highly careful coders
by dthacker (Deacon) on Sep 15, 2003 at 02:37 UTC
|
"...We usually answer. “That is up to you to figure out”
Speaking as a person who always wants to improve, I would raise this simple point:
- The person who is asking you wants to be a better coder.
- You have information that will make him a better coder.
- Your irritation level will likely decrease if his code is better.
- His frustration level will likely decrease if his code is better
- Your workplace needs better coders.
- The universe in general needs better code.
- You gain nothing by withholding this information and much by passing it on.
Dave Code On! | [reply] [Watch: Dir/Any] |
Re: Seven habits of highly careful coders
by Theo (Priest) on Sep 15, 2003 at 01:13 UTC
|
There are some folks who seem obsessed with the details of whatever they are doing and others that really don't even see that level of detail. It can be a personallity trait. Those who see only the details are not generally good at being in charge of a bunch of others, and those who are good leaders are frequently poor at details. It's important for people to work in areas where there personalities fit what they do.-ted- | [reply] [Watch: Dir/Any] |
Re: Seven habits of highly careful coders
by bwelch (Curate) on Sep 15, 2003 at 15:08 UTC
|
Relating this to recent projects involving updates and additions to other people's code, it reminds me of ways to both test legacy code and document my own.
In testing legacy code:
- Is it still in use? If not, why?
- What's the scope? Exactly where will this work and where will it fail?
- Is the author still around so I may ask questions?
- Is it worth figuring this out and updating it, or would I be better off starting over?
In documenting my own code:
- What does this code do and why was it created?
- Include a history section that documents changes and dates.
- Add a simple outline if it's complex so it's easy to understand it without studying all the code.
- Document the code assuming you'll be trying to understand it two years in the future and you don't remember anything about it. | [reply] [Watch: Dir/Any] |
|
- Include a history section that documents changes and dates.
Isn't this what change-control (such as CVS or SourceForge) is for? I would use CHANGES sections for release notes and keep version changes relegated to source control. Otherwise, the source file gets too cluttered up!
------ We are the carpenters and bricklayers of the Information Age. The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6 Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
| [reply] [Watch: Dir/Any] |
Re: Seven habits of highly careful coders
by Anonymous Monk on Sep 14, 2003 at 15:30 UTC
|
When I first read this title, I thought it was going to be a meditation on "defensive programming". When I think "careful", I think of safe practices. Wearing condoms, chroot()ing daemons and such.
7. Did I read what is on the screen?
This is tough to take seriously.
-- am | [reply] [Watch: Dir/Any] [d/l] |
|
| [reply] [Watch: Dir/Any] |
|
By experience, I found out that my best coding used to come at ocassions when I lost my papers and I had to write all over again by memory...
| [reply] [Watch: Dir/Any] |
|
|
| [reply] [Watch: Dir/Any] |
Re: Seven habits of highly careful coders
by johndageek (Hermit) on Sep 16, 2003 at 14:35 UTC
|
Is the question "How to be a more careful coder" or the more general "How can I be more careful in my work?". One is much broader than the other.
let's try a few broad rules
1) Put the user's shoe on.
Listen and understand what is being requested of you, and why it is imoportant to the requestor.
2) First do no harm. Does everything you didn't intend to touch work just like it did before?
3) Make personal back ups of all things to be changed BEFORE working on them. Paranoia is the basis of good programming, trusting backups of others is like asking someone else to do your tiedown in mountain climbing.
4) Users shoes again - Test the software pretending you will be able to do your job ONLY through this software. test over and over. Remember those little annoyances that would make you crazy, will make the user crazy.
5) No surprises. Pretend I am doing some work for you. When would you prefer to hear the following:
I'm running late.
It works differently than discussed.
It's slower than anticipated.
Your changes will affect the due date
** bad news early allows the user to plan accordingly, bad news late allows/forces the user to blame you.
Good luck
dageek | [reply] [Watch: Dir/Any] |
Four habits of somewhat careful sysadmin :-) [Re: Seven habits of highly careful coders]
by bronto (Priest) on Sep 18, 2003 at 07:27 UTC
|
System administration is sometimes the art of solving problems of which you don't know the source. For that kind of problems, I wrote my own checklist based on my personal experience: it's a four-phase analysis I run through until I find the problem.
- at first, don't trust the user;
- then, don't trust the computer;
- then, don't trust the OS;
- if all this fails, don't trust yourself.
Ciao! --bronto
The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
--John M. Dlugosz
| [reply] [Watch: Dir/Any] |