The hardest thing about programming – Naming in programming. advice from a developer over 25 years old – P2

The hardest thing about programming – Naming in programming. advice from a developer over 25 years old – P2

HomeSTARTUP HAKKThe hardest thing about programming – Naming in programming. advice from a developer over 25 years old – P2
The hardest thing about programming – Naming in programming. advice from a developer over 25 years old – P2
ChannelPublish DateThumbnail & View CountDownload Video
Channel AvatarPublish Date not found Thumbnail
0 Views
https://StartupHakk.com?v=1CPoeoKJvLo

Welcome to StartupHakk! At StartupHakk, we turn beginners into full-stack developers in just 3 months! Today we're looking at a fundamental but often overlooked aspect of coding: the importance of naming in programming. Let’s unveil this intriguing concept together!

Have you ever thought about the meaning of names in your code? Just like in stories where knowing the true name of a demon can give you control over it, in programming, a well-chosen name for a function, variable, or other construct can illuminate the essence of the problem you're solving. Today we explore how effective naming can lead to clearer, cleaner code and improved architecture.

Let's talk about the essence of Clean Code:
It's said that almost 90% of writing clean code comes down to choosing the right names. It may seem simple, but it is more of an art than a science! I've said for a long time that the hardest thing in programming is naming! Let's look at some examples to illustrate this point.

Example #1: the misleading function
We start with a function named `demo` with parameters `a` and `b` and a variable `c`. This function returns population statistics but is hampered by vague naming. The ambiguous function name, non-descriptive parameter names, and confusing use of "a" inside a lambda make the code difficult to follow and error-prone.

The transformation:
By renaming the function to "fetchDemographicStatsForFirstAndLastName" and using more informative parameter names like "firstName" and "lastName", we immediately gain clarity. This transformation highlights the purpose of the function and the data it manages, making the code more readable and maintainable.

Example #2: the overloaded function
Our second example is a function called "getJobId" which does much more than its name suggests. It gets a machine, sets up a Docker worker, and starts running a task. The deceptive simplicity of the name hides the complexity of the function's actions.

The solution:
Breaking down this overloaded function into smaller, more focused functions like 'procureFreeMachine', 'setUpDockerWorker' and 'startExecutingJob' clarifies the code. Each function now has a specific and understandable purpose, making it easier to work with the overall code.

So why is it important to define good naming practices?
A good programming name should be clear, concise and contextual. It should tell a story that fits the surrounding code, reflecting its goal without being too creative or assuming too much prior knowledge. The key is to find the essence of what you name and let it guide your choice.

Bad names = reflection of bad code:
Interestingly, a poorly chosen name often indicates underlying problems in the code itself. This is a sign that the code may be trying to do too much or lacking clear direction. Recognizing and fixing these problems can lead to both better names and better code.

Here are some practical tips for naming:
When you have trouble naming, start by writing a descriptive comment. Then sculpt that description into a concise name. Remember, if the name is too complex, it might be time to refactor the code. The goal is to arrive at a name that captures the essence of what it represents in the simplest form.

The role of naming in code reviews:
As you focus on naming, you'll notice a change in your code review process. A clear, well-thought-out name can often lead you to the heart of the code, making it easier to identify and fix problems.

This exploration of the power of naming in programming highlights a fundamental truth: good naming is not just a cosmetic choice, but a reflection of clear thinking and effective code structure. During your coding career, remember the impact a simple name can have on your entire project. Until next time, keep coding, keep learning and see you soon at StartupHakk!

What are your thoughts? Leave a comment below: At StartupHakk, we love training software developers. We accept people with no experience and train them to be ready to start as a Fullstack Software Developer in just 3 months. So make sure to check out the link below or go to StartupHakk.com.

#coding #codingbootcamp #softwaredeveloper #CodeYourFuture

Please take the opportunity to connect and share this video with your friends and family if you find it useful.