View unanswered posts | View active topics
It is currently Wed May 14, 2025 8:03 am
|
Page 1 of 1
|
[ 13 posts ] |
|
Things that every programmer should know
Author |
Message |
Fogmeister
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 7:35 pm Posts: 6580 Location: Getting there
|
Regardless of operating system, language, team size, project size, etc... there are some things that every programmer should know.
What are your little pieces of knowledge that you have picked up or come to realise that help you when programming.
For a start, I learnt very quickly to take constructive criticism of my code and use it to help better my code in the future. I never take criticism personally now or try to be too protective of my code as I know that it's perfectly possible that there are several better/alternative solutions.
|
Thu Sep 16, 2010 9:54 pm |
|
 |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
A good idea of what is needed and how it's put together is always great, if you don't have that luxury then a process I call 'iterative prototyping' can be just as good though takes longer - Program everything you can by hacking stuff together, when you have something that works how you want it to, reprogram it with good practises in mind.
If you ever find yourself thinking "this would be much easier in X language" then you probably haven't learnt the language you are using well enough or are using the wrong language for the job.
If you put your mind to it and don't mind it being slow, particular, and rather long winded, you can do almost anything in Bash!
|
Fri Sep 17, 2010 12:40 am |
|
 |
jonlumb
Spends far too much time on here
Joined: Thu Apr 23, 2009 6:44 pm Posts: 4141 Location: Exeter
|
I'm not much of a programmer tbh, but something I've seen time and again on DWTF can be rectified by "check there isn't already a function that does this"
_________________ "The woman is a riddle inside a mystery wrapped in an enigma I've had sex with."
|
Fri Sep 17, 2010 7:13 am |
|
 |
big_D
What's a life?
Joined: Thu Apr 23, 2009 8:25 pm Posts: 10691 Location: Bramsche
|
1) always write your test scripts, before you've written a line of code 2) always write the function/method header comments before you start writing the code. 3) make sure that the comments are updated to reflect changes in the design of the system, before you implement the changes 4) for compiled languages, always comment out redundant code, don't just delete it, you never know  5) use a code management system, like SourceSafe, SVN or CVS (see 4 above).
_________________ "Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari
Executive Producer No Agenda Show 246
|
Fri Sep 17, 2010 8:30 am |
|
 |
finlay666
Spends far too much time on here
Joined: Thu Apr 23, 2009 9:40 pm Posts: 4876 Location: Newcastle
|
Things the junior at work can't do but every dev should:
Know how to debug code Know how to respect a tester, for they are the ones that WILL break your code Know how to view a stack trace Know how to write out in some form of logging Know how to make a meaningful error message Know that it takes someone else to test & validate code/bug fixes to the person that wrote it Write code comments (the "It's a small business, I can just ask" doesn't work when people leave) Generate a functional spec, especially for things that are used multiple times (especially when there are consistent failings because they don't get fixed) Then on failure to make a functional spec to not whine when bugs are found because "The customer didn't ask for it" (I doubt the customer should have to ask to not get null reference exceptions on deleting items)
If you use it more than 3 times and needs a comment to describe how it works, write a method for it
_________________TwitterCharlie Brooker: Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.
|
Fri Sep 17, 2010 2:09 pm |
|
 |
big_D
What's a life?
Joined: Thu Apr 23, 2009 8:25 pm Posts: 10691 Location: Bramsche
|
ALWAYS test the positive result in a decision (if...then, while, repeat etc.) rather than the negative result, where possible, as it is faster and more efficient. E.g. is more efficient than:
_________________ "Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari
Executive Producer No Agenda Show 246
|
Fri Sep 17, 2010 2:30 pm |
|
 |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
Putting the negative first can make your code more readable in some situations. I know one shouldn't say it, but with todays computers, with small knock on performance is probably worth it for readability later.
|
Fri Sep 17, 2010 2:43 pm |
|
 |
Fogmeister
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 7:35 pm Posts: 6580 Location: Getting there
|
I did a test of this at work the other day. It took about 30% longer for the computer to check if a boolean was negative than it did to check if it was positive. I couldn't believe it!
|
Fri Sep 17, 2010 2:58 pm |
|
 |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
I've tried it in Java and Perl and it's not that much in it: Java: Time: Time: - Yes, I did recompile  Perl: Time: Time:
|
Fri Sep 17, 2010 6:51 pm |
|
 |
Fogmeister
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 7:35 pm Posts: 6580 Location: Getting there
|
Ah, I only skim read Dave's post.
My test was checking an actual boolean.
In pseudo code it was...
assign a boolean value. if boolean then print "Here". else print "Here".
this was compared to...
assign a boolean value. if not boolean then print "here". else print "here".
if that makes sense.
I also looped it about 10,000 times so I could get a sensible answer out of it as our system was too quick for anything up to 100 iterations and gave a time of 0.
|
Fri Sep 17, 2010 7:47 pm |
|
 |
big_D
What's a life?
Joined: Thu Apr 23, 2009 8:25 pm Posts: 10691 Location: Bramsche
|
Processors are designed to test for true, testing for false requires more processing power.
With a modern processor, with a single user, it doesn't make much difference. Add in thousands of tests in a script, multiplied by hundreds of users on the same processor (e-shopping sites, for instance), it can make a big difference.
We had an e-shop with 4 load balanced servers, when it got more than 250 customers, it would grind to a halt - part of it was also poorly optimised SQL queries as well, changing those, and optimising the code meant that it was running fine with 1000 users afterwards. A lot of the SQL optimisation was also changing WHERE statements to check for positives, instead of negatives, plus re-ordering the joins.
_________________ "Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari
Executive Producer No Agenda Show 246
|
Sat Sep 18, 2010 7:17 am |
|
 |
finlay666
Spends far too much time on here
Joined: Thu Apr 23, 2009 9:40 pm Posts: 4876 Location: Newcastle
|
Nothing to stop a if (something) { // do nothing } else { // do stuff }
_________________TwitterCharlie Brooker: Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.
|
Sun Sep 19, 2010 8:19 pm |
|
 |
big_D
What's a life?
Joined: Thu Apr 23, 2009 8:25 pm Posts: 10691 Location: Bramsche
|
Totally.
_________________ "Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari
Executive Producer No Agenda Show 246
|
Mon Sep 20, 2010 7:09 am |
|
|
|
Page 1 of 1
|
[ 13 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum
|
|