Brezplačni e-vodič: Kako postati programer?
Poglej več
BESTSELLER: Web Development 1
Read more

6 most common programming mistakes

Are you a beginner in programming and are plagued by nightmares related to mistakes and bug fixes in mileage codes? We promise you that you are not the only one in the sea of ​​programming difficulties for beginners (as well as senior programmers). Writing and troubleshooting programming takes the most time in your workday, so it would actually be a dream if there was a list of the most common programming mistakes, right? Say no more, this is exactly what awaits you in today’s blog post!

Below you will find a list of the most common programming errors. Where are you?

You don’t follow a consistent writing style

Since we don’t have as much superpower as computers, it’s important to make the most of programming efficiency. With a clear programming style, your work will seem more natural – you won’t have to think about it any time soon, because you’ll know what your system is like.

Example: If a name is written with a capital letter, it is probably the name “class”. If the name is all caps, it is some kind of a constant. Such little things ultimately help you focus more with the superbrain on the problem you’d like to solve, and less on the little things. So make sure you have:
– Clearly defined in what way you will name things
– Selected as objective and meaningful names as possible
– Added as meaningful comments as possible

Writing methods that are too long and too complex

We know this is never an intention at first, but it happens – when you start writing and fall into the code for a few hours, you add a few thingiess in between and … voilá – all of a sudden 500 lines of code (or more) are waiting for you. Here, it’s hard to figure out exactly what all this feature is doing – there are too many paths within the code, too many interactions in it, and it’s hard to point out exactly what we want this code to do. Now imagine someone else reading it … drama!

Try these golden rules of writing code:
– Avoid codes longer than 50 lines
– You have to understand what the code is about – in one sentence without AND and OR.
– It should not contain more than eight branches (ifs), repetitions (loops) or selections (switch).

Writing code without a plan

Beginner programmers quickly get used to programming and start writing code without a plan. The plan should include a whole range of things that every senior programmer takes for granted, but is crucial:
– Keep the requirements clear
– Design how the program will look like
– Design a user interface
– Design the test

Global variables

Beginner programmers typically list all variables globally. “Why does it matter at all, who will be dealing with all this nonsense?” It’s important because this variable can have a value you don’t expect. There’s nothing worse than finding that a problem that’s been hunting you all day comes back to a wrong global variable at the beginning of the code, and changes values ​​unexpectedly.
You are not writing in logs
The production system must record its operation. This is especially common for Internet access systems. How can a bug programmer find out exactly what it’s about? With reference to logs! Production systems are constantly recording performance and who demanded that what should be done. By obtaining the programmer ID and the approximate time when this error occurred, the programmer can return to the log and find or correct the request. Ideally, the log can tell the programmer if it worked and if not, why not. Therefore, hear us out: record log files!

You don’t back up your code

“My disk crashed and I lost two weeks of work!” This really shouldn’t be an excuse, because it’s an old-fashioned disaster … Although it can take a long time to recover after a disk crash. You may need to format the disk, rebuild the operating system, and who knows what else – but restoring the source code you wrote shouldn’t be harder than copying files from one system to another.

There are countless inexpensive systems that automatically backup your entire disk every night. The investment is worth every penny, much more than your sleepless nights, right? Night backups can be stored in the same room as the original disk, but we recommend that the backups be moved to another location at least once a week – to protect yourself from fire and water damage …

So, we got to the bottom of the blog post. If we saved at least one hour of programming with these “preventive” measures, we did quite a lot, didn’t we? You can learn all about programming in our SmartNinja course web Development 1. Choose your country and join us in a fun world of programming!

You might also like