Here's What You Can Learn In 10 Minutes That Will Be Useful For The Rest Of Your Programming Career

Ken Mazaika on March 01, 2017

There is one remarkably simple trick you can learn in only a few minutes that will be useful for the rest of your future as a programmer. And the... [Read Full]
markdown guide
 

When this happens, it is your job to put on your detective hat and determine exactly which line of code is doing the wrong thing.

Or set security guards on the doors to stop the crime taking place. Use Design By Contract, and place preconditions at the start of methods and postconditions at the end. They will catch 95% of your bugs.

 

In addition to the tips above my contributions are:

  • Use an IDE, it will often understand the problem much before you and help you with everything you need to do as a programmer.
  • Learn to use a debugger. Forget console.log, forget puts, forget echo, fire up that debugger and see exactly what is going on.

Almost all programming environments support a real-time debugger, allowing you to step through every line of code in your application while monitoring the state. Way too few programmers know these tools exist, know how to use them, and then use them to find out what your program is actually doing and where it actually fails.

 

Debugging actually takes a long time. There is a famous quote.

"The most effective debugging tool is still careful thought, coupled with judiciously placed print statements." - Brian W. Kernighan

I find that more to the point.

 

Kernighan said that in 1979. I don't know if you've noticed, but software and tools have evolved a little bit since then.

 

It should not. However, I do see there are languages and environments, where setting up a debugger may be hard.
But most people are application developers and don't do embedded etc. Those folks should really only use a debugger if possible (yeah, parallel programming indeed is a prob here) because usually it's even faster than printing, gives a lot more info, you can usually change stuff in the process and you don't forget print statements which may find their way into a public release.

I am working mostly with .NET Core and starting to debug is a matter of pressing one single keyboard key. Writing a debug print statement is actually more effort to me.

 
Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

"Famous quote" doesn't mean it's right. I know a lot of famous bullshit quotes.

And yes, of course you need a working brain to do effective debugging, but a debugger sure helps a lot. Especially when your application requires recompilation to add your print statements just hooking in the debugger and seeing what's going on is often a LOT faster.

Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

I don't agree. I'm actually so much lazy I rarely use the debugger. That gives me a whole lot more time to work on other things instead. If you spend too much time on it you are not productive. You are just messing about.

And one more thing. This is not a bullshit quote from the author of C as he definitely knows more about programming wisdom than anybody here combined.

Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

I really don't know what you do when you mess about with debuggers, I use the debugger to find out what's wrong with my application instead of messing about with print and guessing, fix the issue, and move on

Good job, you almost made a good argument there: yourlogicalfallacyis.com/appeal-to...

Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

That's the fallacy there. I don't appeal. I respect. Which you don't. No one really likes a wannabe smartass. Plus I have much experience in Software Development to think of my own and to have a pragmatic view of things that work and things that not. I suggest you try that in your life and maybe you will get more free time and less time to be cocky.

Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

Your whole comment is a big "lol". Thanks for the boring conversation, I'm done wasting my time on you.

Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

Thank you for verifying my assumptions to the world. Go on debug something now.

Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

Uh.... Dennis Ritchie was the father of C along with Ken Thompson. The fact you're quoting Brian Kernighan as the author and acting haughty about it kind of kills all weight and credibility to your responses.

Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

He made a mistake with citation. Other than that mistake he was not the one who was rude. He didn't claim that the other guy was offering 'bullshit' and he didn't resort to being rude until Janne was a douche about it. Janne is the dickhead in this situation. Not Theofanis for making a mistake on who said something.

Edit: Just realised how old this is! Apologies for piping up but my point still stands in my opinion so I'ma leave it thurrr

Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

Again, whoever made the statement is irrelevant. Appeal to authority is a shit argument as well. Rudeness also matters exactly none at all to the correctness of the statement.

Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

Well it does hold relevance when that was the turning point of this particular conversation turning sour. I didn't say anything about appealing to authority. Your last statement was the only thing you said that is true. You can be correct and not a cunt simultaneously though.

Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

Sure seems to me that you are the cunt and dickhead in this conversation if that's all you've come here to do, to fling random insults without making a point.

Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

I did make a point. You can be correct without being a cunt. Something you clearly struggle with.

 

I really have to agree on both points, however I have the opinion that one should not throw print functions entirely out of the window. The print function can be extremely useful when for instance one is debugging a multi threaded program. It can reveal the sequence of actions that happened, and the programmer can respond accordingly to that.

A debugger in the above case can sometimes miss this sequence, and one definitely misses the overview of this sequence with a debugger.

In my opinion, this is a "pick the right tool for the job" case. A debugger is extremely helpful, but is not everything.

 

Thanks Duke! To me, using an IDE was a personal preference, till I started working on projects which deal with large scale code. I cannot emphasize this more, that using an IDE has a lot of advantage over a pure editor. Simply stated, makes life easier for developers and saves them from many pitfalls, and improves overall productivity.

 
 

When I was in college, a prof once said, there is no engineer that knows everything, that never needs to consult a reference. Good engineers keep their references close at hand, and know when to consult them.
he then went on to detail a bunch of desk refs which are not salient to this article.
This was of course before Google was a thing. But I think the sentiment applies. A good engineer knows when to stop bashing their brains out on the keyboard and just look it up.
My Uncle once said, if it's built by people, people can fix it. Which is a deceptively simple sounding idea. But when you crack it open and start applying it is a gamechanger.

 

Does someone know the first who face a given problem?
I mean, the moment when you google something and "No records found".

 

It's SO rare to run into an originally new problem. 99.999% of the times it's probably a different manifestation of a problem somebody has faced before, so you just need to rethink and rephrase to get answers.

 

this is not always true. based on the tool you use (could be the language, framework or anything else) you could get face some wired situations no one else ever faced before.

last semester our parallel programming prof asked us to do the homework with multi-pascal and apparently it's community dose not exist (and he knew it). so, we had to figure out what to do without any help.

God it was hard

 
 
 
code of conduct - report abuse