Hi there, in my last post I talked about what programming is all about, how it has evolved and why programming is very essential to computing. Today we will be approaching things from the unique perspective of a evolving programmer.
Code to a non tech savvy person has an impression at times defined as complicated and dull, but it appears so because of its adhesion to functionality and that can not be altered because well "Code is meant to look like code". Most times programmers forget that a major key characteristic of being programmers is to get the computer to understand instructions better and faster but we end up prioritizing aesthetics over functionality. Below we take look at the few practices that can make you a better programmer if adapted.
Pseudocode
Always have your code flow modeled out before you start working on a project. Considering individual uniqueness, I wouldn't say there is a best way to organize your flow as it varies based on what we are most comfortable with. For me I use what call a "Flow to Pseudo System" which enables me to:
- draft out a step by step approach of what my algorithm would do and steps it would take to do that, just like a flow chart
- write a pseudocode(code on paper) on how I would implement the task or project on code This saves me the time of excessive time consumption writing unnecessary code and makes Algorithms have a better structure
note: normalizing writing pseudocode also helps in a better understanding of syntax as you depend less on automated IDE suggestions
Choosing the right programming language, tool or framework
There are several Programming Languages out there, each bearing its own syntax, rules and limitations to which it is able to interpret or compile. Being aware of the fundamental rules guiding a programming language should always come first before we try to develop or build anything as it reduces syntax error. For example some languages are very case sensitive while some aren't and this can be the source of an avoidable bug. also different programming languages and tools have their preferred area of implementation based on its functionality and having knowledge of such saves us time and cost of trial and error. Some have further improved libraries targeted at simplifying various stages of development.
Commenting on your code
Readability of code should be taken as crucial as writing efficient code. Leaving comments in your code improves its comprehension by others and makes it easy to debug and refactor. Leaving comment might help you remember implementations and shortens time taken to figure/remember set up in your code if you were to come back to it after a given time period.
public class Numbers{
//this is a class containing number implementations
}
Using the right variable types and data types
We sometimes tend to loose track of our things especially when we experience developer burn outs and this can result to common mistakes like misplacing our variable types for example we might create variables of type int that ends up holding variable type of double and depending on the language this might result in inaccuracy of values or in some cases lead to annoying bugs that no one likes. In order to avoid this it is good practice to note the required data types which would be used in writing code and also crosscheck the value which it would hold.
//always put the right values into a variable
int number ;
number = 14;
Variable naming
Picking the right variable name plays a very important role in the readability of code, and I must confess to being very terrible at picking variable names at first but so far with regular practice am getting better at it. Case sensitivity might play a role in the variable naming methodology but in most cases, classes , variables , objects and methods are named using the UpperCase and lowerCamelCase method where in a class name the first letter is capitalized e.g. class Numbers{} and the variable names start with small letters and have a capital letter for the first letter of any extra word attached to the variable name, object name or method e.g. var singleDigit; . The example above isn't specific to all languages, try researching on the common naming conventions of your specific language to be sure. It is also good practice to always have naming conventions related to function or relevance, that way its use in a code base is easier to understand; I wouldn't want someone to wonder what a variable named dance is doing in a class of numbers
Managing a proper data flow
Properly organizing and managing the flow in our algorithms helps us develop faster solutions and avoid unnecessary implementations which consumes memory and makes our code extra bulky.
Version control
Version Control is a practice of tracking, managing and enhancing changes in code. Choosing the right version control system is very important. There are three major type of version control which includes;
Local version control
Centralized Version Control
Distributed Version Control
Learning how to work with collaboration tools such as GitHub helps you be able to track, compare, update, manage changes to your code, while also making distribution possible at the same time serving as a back up to your localized codebase. It also helps team collaboration. Other version control tools include; GitLAB, BeanStalk(not Amazon BeanStalk), PerForce, Apache and Aws CodeCommit.
I Hope this article helps reduce the number of variables named i out there and until next time:
System.out.println("Sayonara"); //have a good day