Actualize Dreams

We are able

The difference “” vs null vs 0 — February 18, 2018

The difference “” vs null vs 0

Recently as I was conversing with my young friend, he looked at some of my code and wondered why I was using a zero or null or empty string (“” or ‘ ‘ ) instead of using one wherever I wanted.

Programming is an interesting though weird or confusing discipline, especially to the novice things don’t mean a lot because most novices concentrate on the output than the efficiency and effectiveness of the output. For the mature programmers optimization is key, after all at the end of the day a user wants something working but requires less attention than something erroneous and slow.

So let’s get to it. How does null, empty string and zero differ?

Similarities

First of all the similarity is of the three is that they are all values to variables and mostly used as the initial value of a variable.

Second the empty string and null will usually output nothing if printed on the screen.

Differences

Differences might be defined differently per programming language.

For example in Python there is no null but there is None which means the same as null in other programming languages.

To find out the datatype of None and other values in python use the type( ) function e.g type( None ), will return NoneType data type in python. While in JavaScript we use typeof value to find out the Data type of a value stored in a variable. i.e. console.log( typeof null ) will return object as the data type of null.

PHP 4+ we use gettype( ) function to find out the datatype of the value stored in the variable. For example gettype( null ) will return for NULL.

If you are a JavaScript novice it’s good to pay much attention to null values since they are of data type object. For example find out how object data types are treated in JavaScript before you hit a nail in your foot.

 

Almost all programming languages “” or ” is treated as a string and it occupies the space in memory of the size that is occupied by a string or char datatype. In fact in JavaScript if a value starts with ” even if it’s proceeded by a number or decimal it will be type cast to a string so that the resulting value will of data type string.

So be careful initializing variables with ” especially if they will be used in mathematical expressions.

In Java, Python and PHP 0 is treated as an integer whereas it’s treated as a number in JavaScript because in JavaScript integers and floats are number data types. I know most people might be wondering why not a Boolean?

Though 0 or 1 might represent false/true they are not treated boolean data types.

Why care?

It’s always good to code what a programmer and fellow programmers understand to avoid spending time in refactoring than improving functionality and optimization.

It’s also important to ship a software which will give more predictable results than not to avoid the users plucking hair out of their heads, assuming they’re wrong yet it’s the programmer is the calprit.

DataTypes determine how big your program will be and how it nay handle memory, avoid confusing by planing to code rightfully from the beginning.

Note: 

This tutorial assumes you have some programming knowledge and some level of practice with the one or more of the programming languages cited in the tutorial.

The tutorial is dedicated to Were Calvin a Ugandan African motion graphics designer and emerging front-end developer practicing at Gagawala Graphics limited.

Advertisements
You will most certainly love this reading about coding — December 26, 2017

You will most certainly love this reading about coding

If you want to be a relevant developer 5, 10 or 15 years to come, don’t make no mistake and ditch JavaScript.
 
Avoid the hype of emerging frameworks if you don’t trust your JavaScript vanilla knowledge and skills. Of course many smart developers in your network will put up a strong challenge which will most certainly make you feel irrelevant but man up and stick to what’s fundamentally right.
 
Don’t take it for granted, if you have strong vanilla skills you would be able to learn and grasp almost any JavaScript framework or library or plugin in less than 72 hours or so.
 
Have an understanding that competent developers, don’t work solo, they have an ecosystem consisting of teams. You’d rather code a process in vanilla that you understand than copying and pasting some library code in the app but you can’t answer why, what, when and how. Efficient software is developed by patient and efficient coders.
 
On top of that learn C++ or Java which languages have been around for forever on top of having top notch OOP maturity level. Which any JS library is embracing but sometimes it’s harder to grasp in JavaScript if you don’t compare it to how it’s done in another language.
 
Since most processes in JS are asynchronous it’s the not the same in JAVA and C++ perhaps giving you a big opportunity to understand both entirely.
 
Last but not least, relevancy is subjective though the more efficient solutions you put out in production is relative to the large number of human problems you are helping to solve but you can’t achieve that if you don’t learn and practice breaking down complex tasks into simple modules on paper before getting your hands dirty.
How to set up a Hybrid Mobile App development environment! — March 26, 2017

How to set up a Hybrid Mobile App development environment!

Have you ever wanted to develop mobile apps using web technologies i.e HTML, CSS and Javascript? In fact, you might have tried but failed along the way after failing to set up your computer for the task. It has happened to many others simply because coding and setting up developer environments are two different games which require different skills.

In this post I have listing what you require and briefly suggest what you have to do to have each tool installed on your Windows computer. Though guideline is eccentric to Windows Operating Systems, it’s transferable to Mac OS and Linux.

Let’s get started!

  • NODE.JS

Get Node.js

Install Node.js and add it to PATH environment variable ). Confirm installation by running $node –version at command line. I prefer using Windows shell instead of CMD. Because Windows shell executes some linux commands such as $ls.

  • GIT

Install Git with default settings.

  • CORDOVA

Installation

In Git Bash or Windows Shell execute the command below

$npm install -g cordava

Confirm installation by running

$cordova –version

  • JAVA

    • Install Java Development Kit (JDK). From Oracle’s website download the Java Standard Edition (Java SE). Add the JDK’s installation path to the PATH environment variables. Usually the location is c:\Program Files\Java\jdk version\bin. Create a JAVA_HOME if it doesn’t exist, setting it’s value to c:\Program Files\Java\jdk version To confirm if all is well run javac -version.
  • APACHE ANT

    • Install Apache ANT. (This is the build system for Java). I kept on failing until I discovered this was the missing piece in the puzzle. Search for it on google, download the zip file and unzip it whenever you want, noting the location. Proceed by adding the Apache ANT bin directory e.g c:\apache-ant\bin to the PATH environment variable and creating a ANT_HOME variable to which you assign the Apache ANT directory. e.g. c:\apache-ant. Now in Git Bash or command line tool of your choice run $ant -version
  • ANDROID

    • Download and Install Android SDK by downloading Android Studio. Before we could install the Android SDK alone but it seems impossible now a days, maybe you or I should do more research about this. Add the Android SDK tools and the Android Platform tools to the path variable. Usually these are located at the SDK installation directory\tools and SDK installation directory\platform-tools.
    • Launch the SDK manager by running the command $android use may use it for downloading additional sdk, platform tools etc.
  • TEST ENVIRONMENT

    •  In command line of your choice. Run $adb -version.

Navigate to a directory of your choice and issue the cordava app creation command. i.e $cordova create app_directory com.domain.app AppTitle

    • Add android platforms to your app. At command line change directory to app_directory by running.
      • $cd app_directory
      • $cordova platform add android
    • Connect your phone will developer options and usb debugging are turned on.
      • $cordova run android.
    • If phone does work for some reason you can try to install Universal Adb drivers or view your apps in the browser by running $cordova run browser.

Conclusion.

Knowing how to code is a good task, setting up the developer environment is another thing.