dirtydozen – One-trick-pony variables

dirtydozen

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;
nurse.RecordPatientTemperature(patientMorningTemperature);

Read more on dirtydozen

Browse to https://qbituniverse.github.io/dirtydozen/one-trick-pony-variables/ to carry on reading about One-trick-pony variables…

Marcin Narloch

Marcin Narloch

Creative and pragmatic technology architect and game developer with decades of experience across enterprise cloud architecture, software engineering, innovation and digital transformation.
dirtydozen Previous post dirtydozen – Magic strings
dirtydozen Next post dirtydozen – Sensitive config