Tuesday, August 02, 2011

Subclassing applications

Subclassing is a great tool for making small changes to a piece of code to fit it to new requirements. It is as easy as copying code - but it still keeps the new constructs synchronized with later changes to the original. There are problems with inheritance hierarchies - but you need to have a 'hierarchy', not just two classes, to get there.

I imagine that it would be perfect for extended configuration of applications - including web applications. Wouldn't it be great if you could run a slightly changed version of you main web app by making it's code available from PERL5LIB and then subclassing it to change the colors used, add some minor new features and remove some pages for and affiliated site? Or if you could install a blog engine from CPAN, and then subclass it to add new and override old features? This could even make distribution of CPANized applications more popular.

This is one of the things I am experimenting with at Nblog (see also the screencast: Experiments with inheritance in WebNano based applications).


harbud said...

Subclassing is better than copy paste, most of the times, just remember it's no silver bullet. It's also limited in many ways.

zby said...

There is no silver bullet - we all know that - but subclassing should be more appropriate for whole applications than for components because there would be less danger of inheritance hierarchy growth.

Anonymous said...

I like the fact that you had a screencast but I was missing the explanations of what and why are you doing. Especially in the first half. In the second half you already typed in some explanations but I think having voice, or at least subtitles, would be better.

Oh and I did not know about WebNano. It would be nice to see an introduction about that too.