News for hackers. Stuff that matters.
Re:What should every programmer know about programming? by mpk on Wednesday September 15, 2010 @03:27PM (#1695534)
I don't have an account there, but a few things immediately spring to mind.

- Caching and cache invalidation are really hard - if you have to go there, make sure you can disable the cache at any time

- Using regular expressions for anything but processing lines of text means you're probably doing it wrong

- Few programmers can handle concurrency, provide APIs with lots of run-time checks

- Have coding guidelines and enforce them in code review

- Boring code is good code

- Lack of automated tests make every commit a crap-shoot

- Use consistent logging (with levels), if this is a major performance hit scrub the code out for the production build

- If there is no expert on the team, become the expert. If there is, learn from the expert and become one as well

- Always take responsibility for your code

- Sometimes ugly hacks are necessary. Deploy them, but make it a priority to factor them out at the start of the next cycle (don't leave this crap around for 'someone else later')

Oh man, I could go on like this for hours.

Re:What should every programmer know about programming? by spolsky on Wednesday September 15, 2010 @03:37PM (#1695570)
you don't need an account to post. Pick one of those and write it up!
Re:What should every programmer know about programming? by TheSOB88 on Wednesday September 15, 2010 @10:56PM (#1696675)
I wonder why he thought he needed one.
Re:What should every programmer know about programming? by pjscott on Wednesday September 15, 2010 @11:42PM (#1696749)
Because it's a reasonable default assumption, when you're looking at an unfamiliar discussion website?
Re:What should every programmer know about programming? by TheSOB88 on Thursday September 16, 2010 @11:39PM (#1700032)
Hmmm... maybe the opposite should be pointed out.
Re:What should every programmer know about programming? by silentbicycle on Wednesday September 15, 2010 @05:16PM (#1695879)
> Using regular expressions for anything but processing lines of text means you're probably doing it wrong

And since half the people noting this usually just handwave about the jwz quote* : Regular expressions have very definite limitations, which is why complex parsing is usually done with a second layer on top of REs. Regular expressions for tokenizing (AKA "lexing": breaking a stream of characters into individual tagged tokens - this is an operator, that's a floating point number, etc.), and then a grammar is made for those tokens with a parser.

If you aren't aware of the limitations of REs, you can just keep adding layers and layers and eventually end up with madness like this RE to recognize RFC822-valid e-mail addresses (http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html).

* "Some people, when confronted with a problem, think 'I know, I'll use regular expressions.' Now they have two problems." -jwz. Funny for people who already know, but not very enlightening otherwise.

Re:What should every programmer know about programming? by eru on Thursday September 16, 2010 @05:19AM (#1697300)
> Using regular expressions for anything but processing lines of text means you're probably doing it wrong

Depends. The theory of regular expression works for all semirings (http://sebfisch.github.com/haskell-regexp/regexp-play.pdf).

On the other hand, if you are using backreferences or something crazy like that, you have left regular expressions.

Re:What should every programmer know about programming? by MartinCron on Wednesday September 15, 2010 @05:31PM (#1695939)
Lack of automated tests make every commit a crap-shoot

The last thing I want to do is start another broad TDD flamefest, but I honestly believe that if a programmer hasn't even tried a test automation framework (xUnit or similar) then they are being professionally negligent. Would you want to work with a surgeon who was too set in his ways to sterilize instruments?

The last time I was doing developer candidate interviews, I would start the phone screen with "what test automation frameworks do you enjoy using and why". If they couldn't answer that, I did my best to make it a very short phone call.

Re:What should every programmer know about programming? by keyist on Wednesday September 15, 2010 @05:44PM (#1695972)
You are misusing the term, and the conflation around definitions of TDD make up half of every 'TDD flamefest'.

http://c2.com/cgi/wiki?TestDrivenDevelopment

TDD specifically calls not only for unit tests, but for writing them first, ie the test _drives_ the development. You write a test that fails, then write code to pass the test.

One can be anti-TDD but still believe in unit tests, full coverage, etc.

Re:What should every programmer know about programming? by silentbicycle on Wednesday September 15, 2010 @06:25PM (#1696087)
Indeed. I've never seen a TDD debate that has focused specifically on whether tests upfront are sufficient for designing good APIs, etc., though (ironically, the most important part of TDD!). Usually, one side is aghast that the other side doesn't believe in testing (when they usually do, just not to an eXtreme), and the other isn't convinced that letting tests do all the design work makes sense. They're usually talking (or firing cannonballs!) past each other, mistaking disagreement for mutually extremist positions. (And then the "us vs. them" feelings kick in...)

I'm in very strong agreement that automated testing (unit, regression, integration, etc.) pays for itself in most sufficiently large projects, but skeptical of TDD specifically - testing during exploratory programming often gives good feedback, but it's just one of many tools.

Re:What should every programmer know about programming? by c00p3r on Wednesday September 15, 2010 @10:36PM (#1696645)
Writing a test-cases based on business cases (domain knowledge) before any code is a good practice. It is that simple.
Re:What should every programmer know about programming? by silentbicycle on Thursday September 16, 2010 @02:41PM (#1698694)
I think it's better to have the spec be the code, as much as possible.
Re:What should every programmer know about programming? by MartinCron on Wednesday September 15, 2010 @06:36PM (#1696114)
I just wanted to throw in "test automation, yes!" without starting any controversy.

Although I've been operating with a slightly different (and hopefully less controversial) TDD definition. Instead of getting all hung up on sequence and test-first, I ask "are you using automated tests as the primary way of executing your code as you're working on it". If the answer is yes, then at least that part of the code is test-driven. If the answer is no, then at least that part of the code is not test-driven.

You can write the tests first all you want, but if you're not running them, often, and doing all of the "does this work" through the UI or the debugger, how test-driven are you really?

Re:What should every programmer know about programming? by wariola on Wednesday September 15, 2010 @07:03PM (#1696182)
Realizing that this post might just cause another flame out about unit testing, test-driven development (TDD) and policy-driven development I wanted to post what I think is a useful link about a platform that can assist you to "maintain" the human commitment to TDD:

http://www.parasoft.com/jsp/products/article.jsp?articleId=3...

Hope this helps.

Re:What should every programmer know about programming? by stuhacking on Thursday September 16, 2010 @04:11AM (#1697170)
Some people can write all the test cases in the world but not get their Sudoku Solver functionally working.

Should you really be looking for people who enjoy using testing frameworks? Testing is a necessary part of development, sure. Enjoyable? No.

Re:What should every programmer know about programming? by eru on Thursday September 16, 2010 @05:14AM (#1697295)
You can probably enjoy testing in the same way you enjoy programming.
Re:What should every programmer know about programming? by rikthevik on Thursday September 16, 2010 @02:37AM (#1697008)
My old boss had a good saying:

If it isn't tested - it doesn't work.

Re:What should every programmer know about programming? by gaius on Thursday September 16, 2010 @04:07AM (#1697163)
A former cow-orker had in her .sig, next time you release untested, why not release undeveloped too?