ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Going Over Old Code...

(1/2) > >>

Renegade:
So, I'm back at some code that I wrote quite a long, long while ago... and it all works amazingly well. And, it's just one fast hack after another. Fast, tight, get it done code, that is so utterly not reusable. Well, unless I want to do some copy & paste & refactor...  :-[

And I know darn well that when I wrote it, I just wanted to get it done and working, and knew that it would take me 3x as long (at least) to get things done if I'd have done it "right".

Something like the old phrase:

Good.
Fast.
Cheap.

Now pick 2. :P


Anyways, now I'm debating whether I should just continue on, or bite the bullet and actually do some refactoring to clean things up. Decisions, decisions...  :huh:

Ath:
Simple logic, IMHO:
if (minor_fixes_only || noDevTimeAvailable) {
  keepTheOldStuffJustFixIssues();
} else {
  refactorIntoModernStructures();
}

Renegade:
Simple logic, IMHO:
if (minor_fixes_only || noDevTimeAvailable) {
  keepTheOldStuffJustFixIssues();
} else {
  refactorIntoModernStructures();
}
-Ath (November 22, 2012, 01:37 AM)
--- End quote ---

True enough.

But really, I've committed major sins. Like, it's almost the programming equivalent of worshiping the Devil... I suppose if I were to quote Aleister Crowley:

Black magic is not a myth. It is a totally unscientific and emotional form of magic, but it does get results... To practice black magic you have to violate every principle of science, decency, and intelligence.
--- End quote ---

Looking at one part... cripes... But it all works beautifully. I've just violated so much encapsulation...  :P

vlastimil:
Old code almost always looks bad. Software engineering is too young and evolves rapidly. What used to be a good practice 10 years ago is frowned upon now.

Look at the current disputes about object-vs-functional approach to coding. Would all the nice object code we have written in the past decade be totally out of style in 2020? :o

I usually do not refactor just for code's sake. If there is a concrete goal and the old code stands in the way of progress, it gets re-done. But otherwise, I'd just let it live.

40hz:
Probably presumptuous of me to even comment since what coding I have done in the last 10 years is mostly educational or hobbyist type stuff along with an infrequent fix sent over to some FOSS project. I haven't done any 'real' coding in years.

But I'm somewhat skeptical of many of the claims for code reusability. Certainly some stuff is. Core things like initialization routines, some snazzy error checking or sorting code, a security module or two... But from a lot of what I've seen, most code isn't all that reusable in practice. Especially now that coding conventions and best practices evolve so rapidly. And what was considered "good" a few years ago is often second guessed and replaced as new methodologies and paradigms emerge.

Top-Down, HIPO, structured, natural language, RAD, OOPS, 3-tier, RISC yadda-yadda all had their moment in the sun. Most made wildly exaggerated claims about solving the "programming efficiency problem" once and for all. And none did - although almost all of them contributed something worthwhile to the discipline in the process - even if some did nothing more than show us how not to do it. (APL and Prolog suddenly come to mind for some odd reason. ::))

So I'd agree with vlastimil on across the board refactoring. Unless there's a goal, why bother? You're a much better coder now than you were ten years ago. And your entire approach has probably changed a great deal since then. So why go and do the equivalent of rewriting a book report you did in back grammar school unless there was something in it that you had a use for?

Just my tuppence, but from what I've seen on contract jobs I've been responsible for overseeing, the best success was obtained with 85% code written specifically for the project. Only the balance came from purchased or reused code.

Maybe code reuse works well with something like database type apps where there's significant commonality of rules, objects, and tables used between one business and another. Especially when you consider most of what makes up your basic AP/AR/GL/INV accounting suite is already standardized to comply with legal reporting and auditing requirements. So reuse does make sense there. Just take a pre-written accounting package and add whatever customizations and special business rules you need.

But for what I call 'real' programs, I haven't noticed much actual code getting reused except for snippets or a few special routines.
 8)

Navigation

[0] Message Index

[#] Next page

Go to full version