March 2012
53 posts
Pesky bugs. How I smack them:
- Code review. After writing anything I check it myself (don’t waste someone else’s eyes before you reviewed the code yourself). This catches most typos (things like = for ==, variables with typos in interpreted languages, etc). I also simulate code in my head, which makes sure simple logic errors that may have been made are caught early, before even running anything.
- Plenty of logs. I start any project by having a good Log class, with multiple log levels with filtering, information about the line and file that called the log, sometimes even automatic backtracing in cause of errors (in Python I automatically fall into a . I usually can get a pretty good idea of what went wrong just by checking these logs. Many times adding a few extra log() calls with detailed information about variables is quicker and simpler than using a debugger. And in some cases (websites, for example) setting up a debugger is not trivial, so this has to solve the problem.
- Tests. This is 2a), in fact, because you can only test properly if you have a test suite. I’ll write someday about how I write test suites, but the basic needs are universal:
- tests should be as simple as possible;
- should cover all of the code;
- should be completely automatic when viable (3D graphic applications are not that easy to write automatic tests, however);
- and should test for both the “good cases” and the “bad cases”.
- If things are looking complicated and logs did not help enough, call that faithful debugger. These days my use of debuggers is quite simple: I often set breakpoints in the code itself (debugger for javascript, raise(SIGINT) for C/C++ and gdb), since it’s usually faster than navigating through the code in the debugger if I know where I want to stop. When the breakpoint is hit, I print all variables to check if their values are correct, and if necessary I step through a few calls.
- Stack traces are your friends. In C/C++ I let the program run until it crashes, run a backtrace (bt) and start to move up in the call stack until I get to the culprit — usually it is pretty obvious.
- In JavaScript and Python you can fall into an interactive terminal when the debugger stops that is just as good as the real program: so you can pretty much type any code there, which is run instantly. Then you see immediately if it fixes the code. I’ve come to love this: interactive programming can be extremely useful (great for testing complicated selectors in javascript, for example!). gdb can do some of that, but has several limitations due to C++ being compiled. But use STL support at least for decent printing of STL structures.
- After the bug is fixed, make sure it becomes a test in your suite!
90% of computer science TAs are the same. They hear your problem. They smirk. They lean back and release a hearty laugh. They say big words to make sure you understand how stupid and ignorant you are. They speak loudly to make sure the whole room know you’re dumb and they are the most intelligent, attractive, and perfect specimen to walk the Earth. They grab your keyboard, kick you out of your chair, and fix the problem, pulling a few lean-and-demean looks along the way.
Then they run the program.
Seg fault.
What was that you were saying earlier??
lol, gpoy my freshman year.
I usually just ask one of the compsci bros in my class who’ve been programming long before uni. They’re the best. XD;
MOST BADASS BLOG EVER.
i wish it were a tumblr; i’d follow the shit out of it.
lmfao, same here! XD
Hi, guys. :D
I just found an interesting simulation program IBM made. It’s a free simulator that teaches you how to program a robot and simulate it to battle robots made by other people!Here’s the link: http://www.ibm.com/developerworks/java/library/j-robocode/
Learning to code with fun…
Those screenshots are really, really old. Better to go straight to the sourceforge site: http://robocode.sourceforge.net/
There’s also a wiki to help newbie robocoders find their feet: http://robowiki.net/
It now supports eclipse and netbeans integration too, by the way, there are articles on the wiki about it; it’s much easier to use eclipse/netbeans than their built-in “IDE”.
But yeah, this thing is awesome. Bloody difficult to get anything worthwhile to happen though, so probably not as great an introduction to Java as it first seems. Mind you, I am the sort of person who always starts on “hard mode” and therefore I wrote my first AdvancedRobot before I’d touched the BasicRobot class (still haven’t touched that class) - I eventually got it Wave Surfing and Pattern Matching but my implementations of those were so terrible that it was hardly worth it.
Anyway, if anyone has any questions for an intermediate robocoder, my ask is always open :)
Hi, guys. :D
I just found an interesting simulation program IBM made. It’s a free simulator that teaches you how to program a robot and simulate it to battle robots made by other people!
Here’s the link: http://www.ibm.com/developerworks/java/library/j-robocode/
Learning to code with fun things like this in your spare time is a great way to learn programming languages. Once you get the basics down, you’ll definitely be able to move on into more interesting and challenging projects with code.
Hope this helps some of you.
No problem! Thank you for making that blog!
EVERYONE, FOLLOW http://lifeandcode.tumblr.com! She has many awesome programming tutorials and posts. :D
Yup! :3 Well, a lot of these are blogs run by programmers, but they do talk about programming a lot. mrlinux xplusplus syntaxcoloring codus jdeveloperblog 42codes mkstl Hope this helps. :D *If anyone runs any programming/design blogs, feel free to message me and I can add you on a blogroll or promote you. Thanks! <3
![]()
I LOVE YOU ALL.
deliarious, congrats on being the 200th follower! :D
“Problems” vary according to the person.
Usually it’s just something sentimental everyone experiences while programming. The concepts may seem simple, but applying them to certain assignments/exercises in class are what can make them difficult. I personally am not a fan of using recursion in Java. It’s not efficient at all, and most developers avoid using it.
Well, you seem pretty knowledgeable. Maybe you should make a tutorial site for all of us. ;D
“We’re switching to Waterfall next week…”
“Time to upgrade Eclipse!”
“3+ years of experience with Visual Basic, 3+ years of…”
“public static void ….”
“On the whiteboard, show me how you’d do [unlikely problem] in [unfamiliar language]”
“We’re gonna need you guys to work on some in-house software.”
“Can’t you use Java?”
Q: Can anyone help me with this problem?
A: nvm, I figured it out.
I know, right?
When I was a freshman in compsci in Algorithms class, my professor was awful. The guy in the Stanford U videos taught me everything I needed to know. I also linked his videos in the tutorial section on this site, but maybe I should link the playlist. :D
Glad to know it helps!
1. Wake up with an idea. Mull over it during breakfast brunch.
2. By 1 P.M., you’ve decided it’ll be a great way to get into that new language you’ve been wanting to try.
3. Hack out a few basic components. Get excited when they work beautifully.
5. Time for actual lunch. Come up with an extension to your idea that’s even more exciting than the original idea.
6. Get started on the extension, which spawns three more amazing ideas.
7. It’s 2 P.M., and the extension has become its own project.
8. It’s 4 P.M. and the components you hacked out before won’t play nice together. Ask Stack Overflow.
9. Incorrectly copy/paste your code into SO such that you’re missing a brace and the community thinks that’s your problem. It’s 6 o’clock. Tumblr break.
10. Read all the articles linked from the #programming tags. Read the articles they link to.
11. It’s 8:30 P.M., and you’ve got 11 tabs open. Not including Reddit and Tumblr.
12. Finish arguing over IRC about how Scala is the next big thing and oh maybe I should get back to that project.
13. 10 P.M., dinner ramen should be sufficient.
14. Open up vim and get back to that project.
15. *multiple “what the fuck” moments while reacquainting yourself with your 4-hour-old code*
16. “This is idea isn’t really that great anyway. I’m sure tons of people have tried and failed.”
17. Read xkcd/Cracked articles/TV Tropes.
18. “I’ll just get back to that project in the morning.”
19. It’s 3 A.M. and maybe sleep or something I guess but ycombinator and
20. goto 1

lol, thanks!
I thought so too at first! Glad I can unite all of us~ XD
I love how all of our sleeping patterns (or lack thereof) are alike.
I usually get submissions between 2:00AM - 4:00AM EST. :D
Sleep? WTF is that?
SLEEP IS FOR THE WEAK. >:D
I love how all of our sleeping patterns (or lack thereof) are alike.
I usually get submissions between 2:00AM - 4:00AM EST. :D