December 2017

S M T W T F S
     12
34 5 6789
1011 12 13141516
1718 19 20212223
2425 2627282930
31      

Page Summary

Style Credit

Expand Cut Tags

No cut tags
jarandhel: (Default)
Wednesday, September 6th, 2006 09:01 am
So, I was browsing around on google code, looking over the new open source projects they host. Kind of liking the format, really. Very clean compared to the format of sourceforge. You have a description page, an issues page, and a source page. That's it. Very simple, very orderly. I like that.

I was specifically browsing through the C++ projects, since that's the language I'm most focused on at the moment thanks to the phenominal books I got from microcenter. In about five minutes, I found a little open-source implementation of pong that someone had written. Small enough to browse through the code fairly quickly. Now, I'm a coding beginner really. I'm experienced enough in BASIC and LOGO (which I understand is actually a variant of Lisp?) and I've done a small amount of work with Objective C, but C++ has always been kind of over my head. Doesn't seem to be any more, though... I immediately homed in on a section of the source that is in dire need of reworking. It's nothing major, really... it's just that the original programmer hard-coded in identical initialization sequences for both players. That's kind of painful to me. It would be SO easy to split those off into a seperate function. Heck, with a little extra coding you could even set it up so you could add more players that way, and get crazy three-way or four-way games of Pong going. All from modularizing just a tiny bit more. Not to mention that it would make the code that much easier to maintain, if you ever needed to alter the initialization sequence.

... I'm really tempted to step in and make those chances, and submit them to the project. I've never submitted anything to an open source project before, but I'm really not seeing any reason not to here.

Funny thing is, I have no idea what most of the code in the sequence DOES (it uses an API I'm not familiar with)... I just know that it's not optimized, and I know enough about the language in general to know how to optimize it.

Edit: please, nobody do this before I do. I know there are other programmers on my friends lists who could EASILY do it (and probably add in enough new features at the same time to make the original programmer blush that he dared submit the program), but I really want to make the changes myself. I just can't from work, all I can do is browse the code here.

Re-edit: Or maybe I don't know enough about the language... I overlooked something. The code that I thought was identical actually is not, the hard coding involves keymapping. So while all the variables being defined are identical save for player, what they are being defined as are not. And I can't think (at the moment) of a more elegant way to store those variables so that the init sequence could be made more efficient. It seems like no matter how it's done, you're going to have to have some kind of array defined to hold the specific prefs for each player, keymapping-wise, and at that point you may as well hard code it this way since there's really no way to do that any more efficiently. The only drawback is that there's no easy way to add a new player. But then there's no easy way to do that the other way either, if you'd have to load some sort of preferences file holding the same info, since you'd have to create the pref file by hand too and make sure it contains unique mappings. I can't believe I missed that before. Oh well, back to the drawing board. Maybe I'll find something else that actually needs optimizing.