Skip navigation.

exploreopera

| Help

Sign up | Help

Software Development

Correcting The Future

Where Do I Put This?

In traditional programming, there always comes a time when you need to add a significant amount of functionality that wasn't there before. Maybe it's because the focus has shifted. Maybe it's the clients. Maybe it's budget. Who knows. One thing is for sure though. You have a really nice and tightly coded application that will be decimated. Adding this new functionality can be done in one of two ways. The first way is to modify the existing code and redirect some of the functionality to the new code and vice versa. The second way is to add the new functionality via existing extensibility frameworks. Most applications aren't created with extensible frameworks unless the need arises. And that need is now.

So option #2 is simply NEVER available unless it's the second or third time you're adding similar kind of functionality. The first time around, you have no choice. You have to modify the code you have. Even then, you won't add in custom frameworks. You'll just insert the new functionality. The next time, you may think about adding extensions facilities. No matter what you do, your original code WILL be messed up. At least temporarily.

The key to writing large software is really to write everything as a library. Applications are meant to be used. Its internals should be the same. That way, there is a clear hierarchy all the way from library calls to the main visual interface. The problem is how do you go from tight code to having an extensible framework? It's not easy.

First off, programming languages have shoddy facilities for communication. They really do. Messages in OO are most definitely NOT messages. Real messages are what you get over TCP/IP or over serial cable. OO messages are some weird concoction of looped back execution path, data and objects. This is not the best way to create software. To visualise this problem, imagine that you drove all over town to do all sorts of errands zigzagging to and fro. While you're driving about, also imagine that you are extending a rope from your car that will trace out exactly where you've driven. When you are done your errands, you must then retrace your path in the opposite direction until you've reclaimed all the rope left behind. The scenario I described at the beginning of this article, where we want to add extra functionality, is akin to splicing the rope at a certain point and making more stops until you return to the point where the splice took place. You'd have to do this in multiple locations. And some of the original destinations may also need to move around. That's essentially what programming is about when it comes to adding functionality. The only problem is that we don't consider the rope even though we often get hung by it. In programming, the rope (or execution path) is not visible and not considered at all in many cases.

The reason you want a custom framework is so that you can keep adding onto your code as you would a road network or a city. Over time, it gets larger, but the original functionality doesn't get destroyed. Ok, that analogy doesn't hold up in certain respects, but the point is still valid. We need something to build on rather than something we keep modifying. This notion of modifying existing code is really bad for the soul. I've done it that way for many years and it simply doesn't pay off.

Once you realise that you need a framework, you need to decide how it is to be built. I've talked at length about this before. But it's the challenge that will make you a good programmer into an exceptional one. Data is your friend. So I'll just point out a few tips.

1. Don't be afraid of helper classes. These are classes that operate on a certain kind of data. So you pass data around and NOT the class that operates on it. Well, you can pass that around too just as long as you keep track of who owns the helper class. Each helper class operates one ONE specific kind of data. So if the data format changes, you create a NEW helper class and leave the old one there. If the old data format isn't used anymore, then you can remove the old helper class.

2. Continuing on point #1, pass data around when it comes to interacting with external software. Even internally, use ONLY data when connecting major systems together. Data would be put into the other system's queue to be processed at a later time.

3. When your software gets large, split them up into systems where they each get a turn or where each one runs on its own core. Not only will it make your code easier to maintain and extensible, but it'll make it distributed if the need arises.

4. Use custom resource managers. Make these into a system if necessary. That way all your data and resources are taken care of when multiple events from different systems take place. You need one more thing to make this work which lead to point #5.

5. Allow for the use pluggable interfaces. So if you need a resource to be reset if a context is lost, then allow for an interface to be implemented for that use that can be plugged in.

6. Make sure you have a clear hierarchy for your objects. Objects at a higher level can only call objects at a lower level. They cannot call objects at the same or higher level. This will not only eliminate recursion problems that so often happen with event driven software, but will make your software extremely easy to maintain. If a lower level object needs to affect a change higher up, then you insert a command in the local system's queue. This will keep things always flowing from the top down and never bottom up. Bottom up execution flow is a nightmare to deal with. The problem arises when something is done while returning from other functions. You get into serious causality problems that are difficult to trace. Unfortunately, distinguishing from bottom up execution and returns is not so easy unless you have a clear object hierarchy.

Once you have a proper framework set up, it's really fun to work with. It does take a LOT of work to get there though. And that's the real shame of many programming languages. There are no serious tools for passing data around or for setting up these kinds of extensible facilities. Truly building on top of something without worrying that you'll break something is a breath of fresh air. Having it work the first time, every time, is a dream come true. I know people will disagree with what I have said here, but having set up these kinds of frameworks many times now and seeing how well they work, even in distributed environments, there is simply no comparison. I believe that at some point, we're going to have to move towards being able to BUILD instead of modifying all the time. Where if you need something changed, you swap parts, not change code. And finally, where the people who start projects aren't cursed at by the people who maintain them.

If Programming Languages Were Famous Movie KillersA Few Links May 4th, 2008

Comments

avatar
Anonymous writes:

Could a programming language enforce some of these rules (sort of like how Ada enforces structured programming)? Perhaps a static analysis sort of program for an existing language, that checks a code repository for adherence to a clear object hierarchy... or something. Perhaps add an option on to your programming language to check for adherence to these rules (if you haven't already.) Just passing some hot air around.

By anonymous user, # 4. May 2008, 21:26:20

avatar
Could a programming language enforce some of these rules


Absolutely. Espectially for building modules. Erlang is a step in the right direction. But so much more should be done (and a lot in Erlang should be done differently). Communication via data could be added (via TCP/IP or other transfer mechanisms) and nesting hierarchies could be strictly enforced. So yeah, all these rules could be added in.

I wrote these "rules" specifically so that conventional programming languages could be better used and your software be easier to maintain. There's no reason why a compiler company could not add these rules in as an option.

By Vorlath, # 5. May 2008, 13:12:55

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

Please type this security code : cee5d9

Smilies

July 2008
SMTWTFS
June 2008August 2008
12345
6789101112
13141516171819
20212223242526
2728293031