Friday, June 01, 2007

BS programming

Boy, what a grueling week at work. I'm so tired. But instead of ranting about the Dilbertian moments, the nazi-style leadership apparently in favour in some unnamed consulting companies and the absurd meetings I've been in this week, I thought I'd write about something else tonight. You know, I'd like to maintain a cheery mood in this blog. Bitter complaining can be entertaining to read, but there's a time and a place for everything, and that's next week, this blog.

So, I'll write about a programming exercise I came up with today. It might even become a new trend, or paradigm, if you will, in programming. Why not, other senseless trends have emerged before. It's called Backwards Sprogramming, or BS for short.

Basically the idea is as follows: the program code should be executed from the end to the beginning, instead of vice versa, as usually. This can be achieved by using GOTO statements. Using GOTO statements also has the advantage of eliminating loop structures. The same functionality can be achieved by simply using GOTO's, and this makes the code possibly faster. I'll add an example procedure here as soon possible (I already wrote it, but left it at work and now can't be bothered to do it again).

Edit: Finally, here's the example you've eagerly been waiting for. Sorry about the lack of indentation, but this edit window really likes to mangle any attempts to format this properly. I don't even know if this is the original piece of code anymore. Oh no! Now the b*****d f*****g did it again! F**k! S**t! #!&€!!

CREATE OR REPLACE PROCEDURE backward_proc IS
n_index PLS_INTEGER := 0;
BEGIN
GOTO start_proc;

<<end_proc>>
dbms_output.put_line('backward_proc end');
RETURN;

<<step_3>>
IF n_index < 10 THEN
n_index := n_index + 1;
dbms_output.put_line('Looping, iteration '||TO_CHAR(n_index));
GOTO step_3;
ELSE
GOTO end_proc;
END IF;

<<step_2>>
dbms_output.put_line('Doing the second thing');
GOTO step_3;

<<step_1>>
dbms_output.put_line('Doing the first thing');
GOTO step_2;

<<start_proc>>
dbms_output.put_line('backward_proc start');
GOTO step_1;
END backward_proc;
/


Without doing any research, but with a straight face, and who are you to criticize me anyway, I claim that GOTO statements are present in most programming languages even today, so BS can be followed regardless of the choice of programming language. And the benefits are virtually the same in any language.

So, why should BS be used? It's totally senseless, and makes the program code hard to understand and maintain. Well, that's exactly why, because that makes it the perfect equivalent for the managerial BS practices often used, with undeniable success, in the IT field today. Also, any fatal failings of any given system developed using BS can easily and undeniably be explained by the unmaintainability and complexity of the code. This also ensures that there are plenty of work opportunities for BS experts, because they will be the only ones capable (and willing) to touch systems developed with BS.

The benefits of this paradigm are clear, so I encourage all developers in any organization to embrace them and start using BS today (or the next one banking day after this one). I know I will.

No comments: