Learning from Existing Code



Another question from a software developer:

What kind of things can you learn from a guy who only hacks existing code?
At my previous job I was the lead programmer and I worked with this guy who was a self-admitted hacker. We respected each other and had a great relationship. The company was much better off because we blended our talents.

I would tend to look for an elegant, graceful solution that we could add to our code library. He would tend to find, tweak, and fit some strange piece of code into a solution. One of the most valuable lessons I learned from him was you don’t always have to build the solution from scratch, there’s a ton of code out there you can borrow from.

What kind of things have you learned from a hacker?

Definition: By hacker I mean someone who for the most part, cannot create something from scratch. However they are very good at morphing code that others have written.

Well, I learned a lot of programming by hacking, in the old definition, as in someone who takes stuff apart and tries to make it do more stuff. In my case, I reverse-engineered file formats for program code for a programming language that no longer exists–that was Texas Instruments Extended BASIC for the TI/994a Home Computer, back in the 1980’s. Pulling that information apart and understanding the proprietary format allowed me to write programs that modified programs, mostly to make them easier to edit; there are still online copies of that around, if you search online for ‘MICROpendium Magazine’ and the program called ‘SubIndex’. It was great training.

Now, most companies specifically prohibit reverse-engineering of their products, so when it’s done, it doesn’t get published. What’s evolved since then has been more along the lines of code sample collections on the various crowd-sourced programming language how-to sites. There are work-arounds of just about any problem you can think of, and many, many of these cover topics that the official sites for the products involved won’t cover at all because they don’t want to endorse a solution that they haven’t tested in-house.

As a programming approach, I’ve always saved every chunk of code as a function or a subprogram. And then reuse code, over and over. And I pull code out of my web sites to use on my other sites just about every month. It saves time.

Yes, I’ve gone your way, and written elegant recursive code that did the impossible in one page. But that’s too much like work for most quick tasks. A quick assembly of saved parts and my prior projects is the preferred approach for me.

Jerry Stern
Chief Technology Officer, PC410.com

BackBlaze