How to Structure Your Programming Code

How to Structure Your Programming Code

I remember my first fumble with basic on my ZX Spectrum computer back in the 1980s, ploughing through pages of basic commands and example code without any real idea of how I could write programs myself

Image for post

Photo by Arian Darvishi on Unsplash

I remember my first fumble with basic on my ZX Spectrum computer back in the 1980s, ploughing through pages of basic commands and example code without any real idea of how I could write programs myself. It was like reading a dictionary where I could learn certain words and their meanings with limited information on how I could construct them into entire sentences to write a document. Every programmer who has dabbled in basic has probably come across the famous “Hello Word” routine which consists of a two-line program that prints this phrase unlimited times on the screen.

Your program code needs to be written as step-by-step instructions using the commands that your choice of programming language understands. It means reading your programming manual to learn which commands you need to use for what you want your program to do. In the “Hello World” example you would first need a command that prints “Hello World” onto the screen, and then you would need a second command to print it again multiple times, without writing multiple print statements.

Check out this example. To make things simple I am using old-school basic with line numbers — probably because I’m a retro-freak.

10 print “Hello World”

20 goto 10

The best structure for writing any program code is to make it clear and easy to follow. Some programmers put multiple commands on one line which can make your code difficult to follow if you are trying to iron out bugs. Spreading your code over multiple lines actually makes the program work better and becomes more readable.

Another recommended practice is to separate each part of your program code using REM Statements. REM (short for Remark) allows you to put comments before each section of code to remind you what each part does. This is especially useful if you wish to edit your code at a later date.

10 rem Set Up Variables

20 let A=1: let B=2

30 rem ***

40 rem Print Variables to Screen

50 rem ***

60 print A,B

Anything after the REM command is ignored by the computer and you can use as many REM statements as you want to make bigger gaps in your code for easy reading. Other programming languages allow you to use blank lines or indent the first line of the routine.

Now I will show you how to structure the entire program code. Remember that the computer needs to follow step-by-step instructions so you need to write each instruction in the order you want it to run.

code coding software-development programming-tips programming

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Offshore Software Development - Best Practices

To make the most out of the benefits of offshore software development, you should understand the crucial factors that affect offshore development.

5 Core Criteria for Selecting Software Development Company -

Check out these five criteria for the selection of your software vendor, and you will never regret having the wrong quality product made for you.

Software Developer vs Software Engineer — Differences: Bogus or Real?

In this article, see if there are any differences between software developers and software engineers. What you’re about to read mostly revolves around my personal thoughts, deductions, and offbeat imagination. If you have different sentiments, add them in the comment section, and let’s dispute! So, today’s topic…

Developer or Engineer? Does It Make a Difference?

To summarise the main differences between the software developer and engineer: A developer executes. ... So the software developer is mainly focused on developing code that is a part of software development cycle. An engineer designs and plans applying the principles of engineering to software development.

Wrestling Betting Software Development | WWE Betting Software Developers

Wrestling betting software development solutions from expert Wrestling betting app and software development company delivers ultimate betting experience. Chat with us.