dirtydozen.dev – One-trick-pony variables


II. One-trick-pony variables

Don’t ride it just once

Programming often requires you to store data in memory during code execution. This programmatic memory storage vehicle is called variable which also has a type defined. For example, variables can be string, integer, boolean types, plus tons more.

var foo = "foo";
var message = "My message sentence";
var age = 35;
var isActive = true;
var temperature = 36.6;

Using variables the right way is a fine balance, which you as programmer, need to strike between readable code and memory utilisation.

Let’s consider this code below which in isolation doesn’t look too bad, right?

var patient = new Patient();
var nurse = new Nurse();

// some additional code left out for brevity

var patientMorningTemperature = patient.Temperature;

Read more on dirtydozen.dev

Browse to https://dirtydozen.dev/one-trick-pony-variables to carry on reading about One-trick-pony variables

Marcin Narloch

Marcin Narloch

Creative and out-of-the-box thinker with strong interests and knowledge in technology and innovation.
dirtydozen.dev Previous post dirtydozen.dev – Magic strings
dirtydozen.dev Next post dirtydozen.dev – Sensitive config

Leave a Reply

Your email address will not be published. Required fields are marked *