Bad Languages
Did something last week I'm not particularly proud of (OK, OK, I did lots of things last week I'm not proud of - this happens to be the one that I'm prepared to write about here....) In search of a cheap laugh in the first year programming lecture I cast aspersions on the Visual Basic programming language. I seem to have left the impression that I hate it. This is actually not true. When you get to my advanced years you tend to avoid wasting energy on hating things like programming languages....
The good news is that this has sparked a rather good debate on the departmental forum, with people pitching in and making points for and against the language. If you want my actual position on this one I can quote it if you like:
I've written the odd VB app in the past. It is a very nice place to work. You can make something which looks good very quickly. However, the way that you tend to construct programs (user interface first) does work against good designs. You get tempted to put the actual guts of the program into the actions behind events triggered by the buttons on the screen and this is a very bad idea since your program logic is now spread all over the place.
However, you can write well structured applications in VB in the same way that you can create badly structured ones in Java. In VB I'd advise:
Design the screens, but put nothing behind the buttons. Work out what each screen does and show it to the customer so that he/she is happy with what it is supposed to do.
Back off from the screens and decide what the data structures in your program are and what properties they have. Design the data objects and give them actions which allow them to perform the required tasks.
Create a "method" file which contains all the actions, which are implemented as sequences of method calls in the data objects.
Bind the method calls to the events produced by the buttons.
Keep a very close eye on state, and make sure that events can't occur in a sequence which will upset your program. Turn buttons on and off as required to achieve this and make appropriate use of modal dialogues.
And there you are.
If you don't like me quoting this - then I'm sorry...
0 Comments:
Post a Comment
<< Home