Some people just try to make problems much more difficult than they actually are. Granted, this applies to everyday life, but in this case, we’re talking about making software.
While talking to a friend of mine the other day, he started ranting about having to re-write some code where he works. It appears as though one of his co-workers is a fan of making things difficult.
The problem in question was finding a path from point A to point B. The solution his co-worker came up with was a complex process that involved concentric circles and all sorts of other things. It made my head hurt.
It made my friend’s head hurt too. Apparently this guy has some sort of a fetish for solutions with a big O of n^2, n^3, or worse.
The best answer in this case would be to simply determine the angle that you need to travel at by doing a little math with the X and Y co-ordinates of each point. It gives you the shortest path and the big O of the solution is more than acceptable.
Even the brain dead solution which I came up with off the top of my head since it was and I didn’t want to look up the math was better than the one that my friend had to replace. In fact, the computation time in this case is minimal and the path length isn’t horribly bad but the answer I gave above is a lot better.
The brain dead answer? Starting a point A, travel along X until you reach the appropriate value and then traverse Y until you reach point B.
Like I said, that solution is not optimal, but it’s still better than what was there originally.
Why do people have to make these things so bloody hard?
Current Mood: amused
Current Music: Michelle Branch – Paper Pieces