entries friends calendar user info My Website
A day in the life of me
Add to Memories
Tell a Friend
I finally started a new blog about video games and me making them at IsThatPeanutButter.com. I thought the name was catchy, so I set it up. Right now it just redirects to blog.austinmcgee.com, but I may change that later.

I've been programming a bunch on my own time and I really hope it keeps going. I always feel super productive when I do it and lazy when I don't.

Tags: ,

Add to Memories
Tell a Friend
Dealing with NULL pointers is always a pain, because it could be that the pointer being NULL is completely acceptable or it could mean that it's broken, but it's hard to know which without digging into the code many times.

I came across this while working on some shared code the other day. Another group had created a macro that looked something like this (although much more crazy):

#define mustDeref(p) if(!p) assert(line, file, etc);*p;

So essentially all it does is check to see if the pointer is null and then assert if it is. If it's not, it returns the dereferenced pointer. That turns code into something like this:

void function( int *ptr )
{
    int &ref = mustDeref(ptr);

    // use ref like a reference now instead of a pointer
}

of course some people don't like to do that and get lazy, so you see a lot of stuff like this:

mustDeref(parentclass).membervar;

Aaaand, then of course you get stuff like this (which is an actual line of code):

*(mustDeref(mustDeref(mustDeref(mustDeref(mustDeref(tgt.GetOuter()).GetOuter()).GetOuter()).GetOuter()).GetOuter()).GetName())

And we all know that's just fucking ugly.  I talked to some of the guys who used it and they swear by it saying that it pushes bad null pointers up the stack into the function in which it's actually null.  My god though, it just breeds ugly code.  I would much, much prefer having an assert wherever necessary and then continue using the pointer as-is.  The assert isn't going to catch a bad pointer, only a null one, so it doesn't make sense to use anything other than an assert, especially when it clutters up the code.  This just reeks of someone trying to fix something and causing more problems than it's worth, especially because it clutters up the code to be hard to read and disgusting looking.

So ya, don't write extra code to do something that's already possible and make it look uglier in the process.  BAD.

Tags:

Add to Memories
Tell a Friend
I just started programming at home again for the first time in... well... probably a year or so. I tried to learn C# to make a Sudoku solver, but got bored and annoyed at having to learn how interfaces work. There has GOT to be a more simpler way of doing that, but I probably just didn't do it right. I've moved on to trying to write a configuration file tool. I want it to do all the things I've dreamed of (but never seen) and I think I know how to do it. I'll be learning how to integrate Lua into C++ in the process, which is good because I've always wanted to learn that as well.

Yay for programming on projects you have an interest in :). I hate setting up the solution and all that, but it was interesting to say the least. John and Habib did some magic voodoo to get Bossinabox set up so well. I've copied most of it, but I really need to learn how to make those macros that just do it all for you. In time... in time. I also set up UnitTest++ which is going to be the first time I'll be using it on a personal project. Should be fun, I love unit testing.

Tags:

profile
Look at the website name
Name: Look at the website name
Website: My Website
calendar
Back November 2008
1
2345678
9101112131415
16171819202122
23242526272829
30
links
page summary
tags