How to you plan "large" programs?

Discuss all aspects of programming here. From 8-bit through to modern architectures.
jregel
Posts: 65
Joined: Fri Dec 20, 2013 6:39 pm
Location: Gloucestershire

How to you plan "large" programs?

Postby jregel » Mon Oct 09, 2017 1:31 pm

I'm looking for some guidance in writing "large" BASIC programs. I've broken the design down into a number of modules (screen drawing, input handling, processing specific events etc.) and I want to work on each module independently.

But what's the best way to actually approach writing this? For example, do you space each module definition out across a wide number of line numbers (e.g., display starts at line 2000, input handling starts at line 6000 etc.)?

For those of you who write large programs, how do you approach it?

Thanks
BBC Master Turbo
Retroclinic External Datacentre
VideoNuLA

User avatar
Lardo Boffin
Posts: 670
Joined: Thu Aug 06, 2015 6:47 am

Re: How to you plan "large" programs?

Postby Lardo Boffin » Mon Oct 09, 2017 1:41 pm

Are you writing the program on the Beeb itself? If you are then you will definitely need a copy of the Acornsoft BASIC Editor. Being able to scroll up and down through a large program without having to rely on LIST all the time is well worth it. Plus there are some refactoring tools as well.
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Retroclinic Datacentre + HDD, matchbox co-proc, Viglen twin 40/80 5.25" discs, acorn cassette
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc, Acorn 6502 coproc

User avatar
1024MAK
Posts: 6791
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: How to you plan "large" programs?

Postby 1024MAK » Mon Oct 09, 2017 2:46 pm

It's been a a long time since I wrote a large BASIC program on a Beeb.

I method I use when writing anything other than a simple program is indeed to break it down into sub-routines / procedures.
I often draw up an outline plan on paper. And yes, on the paper plan you can put down the expected line number range. Then I try to code each sub-routine / procedure to run on it's own with just a test program calling it. The test program being in lines 1 to 200. My first sub-routine / procedure is normally at line 1000 onwards.

Then I do the next sub-routine / procedure. Often at 2000.

The beauty with languages that have a renumber (or better yet, no line numbers) is that you can move things around if you get tight on space :wink:. This was a lot harder on the ZX Spectrum where despite a merge command, you had to use a third party renumber utility.

Often the program develops differently to the paper outline. Again, renumber helps.

If I know I will have some short sub-routines / procedures, I slot them in after a long sub-routine / procedure, so for example, in the finished program you may find that there are a load of short sub-routines / procedures after the routine that starts at 1000 , but before 2000. And then a long one from 2000 onwards.

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
flaxcottage
Posts: 2798
Joined: Thu Dec 13, 2012 8:46 pm
Location: Derbyshire

Re: How to you plan "large" programs?

Postby flaxcottage » Mon Oct 09, 2017 3:18 pm

Basically I did what others have said.

BITD I used to write a lot of large BASIC programs on the beeb. To make things easier I used to keep a library of common routines saved as text files and *EXEC them in as needed. I even had a boot disk containing them and chose the utilities I wanted from a menu for each program I started.

Each utility procedure/function began at a known line number and these were known by me so that trouble-shooting was easy. Essentially, writing the program as a series of modules made the task very much easier.

Nowadays I use BBC BASIC for Windows to develop the idea as it has a much better programming IDE than the BBC. Once the main logic is programmed and working I port the text file to the BBC and *EXEC it. Then all is needed is to tweak the code to add the BBC-specific components. This also works for RISCOS machines too.

The only exception to this is if the program uses assembler routines or BBC micro hardware. Then I have to use the BBC to develop the code.
- John

Currently running Level 4 Econet with BBC B, BBC B+ 128K, Master 128K, 4Mb A3000, 4Mb A3020, 4Mb A4000, 4Mb A5000 dual FDD; UK101; HP41CX setup; Psion 3a, 3mx and 5mx; Z88; TI-58c, TI-59 and printer, HP-16C programmer's calculator

User avatar
yellowpig
Posts: 12
Joined: Sat Apr 08, 2006 6:28 pm
Location: Nottingham, UK
Contact:

Re: How to you plan "large" programs?

Postby yellowpig » Mon Oct 09, 2017 6:51 pm

It does depend on what you mean by "large". My largest ones were always in several different files, using an overlay system to actually run them. How they were split up would often depend on which parts needed to be run together.

I avoided line numbers as far as possible. I developed a simple SWR system which would swap programs between Basic and the Master's Edit, stripping off line numbers in Edit and putting them back in Basic (and working with much bigger programs than the native ("EDIT" and "BASIC @") commands.) They could then be edited in Edit, which seemed quite flexible at the time. This ruled out using GOTOs and GOSUBs altogether, of course, but you always can avoid them in BBC Basic, and I never felt the lack.

David

jregel
Posts: 65
Joined: Fri Dec 20, 2013 6:39 pm
Location: Gloucestershire

Re: How to you plan "large" programs?

Postby jregel » Mon Oct 09, 2017 7:49 pm

Useful comments, thanks for the feedback!
BBC Master Turbo
Retroclinic External Datacentre
VideoNuLA

User avatar
sweh
Posts: 1847
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: How to you plan "large" programs?

Postby sweh » Thu Oct 12, 2017 12:53 am

BITD I would put my PROCs and FNs at line 10000. "Toolkit Plus" had a partial renumber facility so I could renumber the main code without it changing the numbering of the procedures, or I could renumber the procedures without losing the 10000 separation.
Rgds
Stephen


Return to “programming”

Who is online

Users browsing this forum: No registered users and 2 guests