Sunday, July 10, 2011

In Search of Software Simplicity

15 years ago I was making small video-games as a hobbyist.  The games were simple, pushing QBasic to its limits.

Jump forward to today, 2011, and I'm still making video-games as a hobbyist.  The software development landscape has greatly changed.  Things look nicer, and the complexity of software development has jumped.  I try to keep up by abstracting away concepts.

The last concept I tried to abstract away was physics.  Of course there are plenty of physics engines out there, but I believe it is best that I understand how these work.  And more often than not, they are too powerful for what I wish to develop.

Even my simplistic set of objects are often times overkill for what I wish to do...

The last object I created, which I should have created a long time ago, is called "Angle".  It allows me to take and compare angles (even though they only exist between -PI and PI).  Something that makes my software more error prone and has greatly helped in reducing bugs.

Another object that I have is "Particle".  It's a point in space (2D or 3D) that has certain physical properties such as mass, velocity, etc.  A character is in essence a particle (it shares the same properties).  But, it can not go through anything.  So, should I infuse, within particle, all the potential logic to handle the case where it is within a bounding box that can collide with this specific world, or should I implement a custom type of object.

The arguments against the custom object are well known.  Code reuse.

But the arguments for creating a custom object are also strong:  Polluting a clean code-base for a one-time-use object is not worth it.  The particle object need not be that complex - leaving it simple means I can more easily reuse it when the time comes.

What if something else needs this code?  Then I'll worry about abstraction.  No use abstracting away something when I'm prototyping.  The goal isn't a library but something to test the feasibility.  The library is just a nice side-effect that happens when I try to keep track of the big picture.

Maybe code reuse is not the ultimate in software simplicity.

I'll leave this rant on one final note:  there once was an article (I believe the Daily WTF) which talked about the added efficiency of using the built-in functions to delete folders rather than recursively deleting folders.  Then it came to me, wouldn't it be more obvious if the right solution were to combine "fmap" with the "delete function" and a "file list"...

Complexity from combinations of simple elements, what a great thought!

No comments:

Post a Comment