Programming the God’s Way — II

Sampada Bhatnagar
3 min readOct 3, 2020

Ever imagined the supernatural energy high up above (Dear Atheists, hang in here for now ) as the master coder who has fixed our destiny by a few million lines of code in his universal compiler? And a big black screen that never bears the brunt of power cuts,wicked viruses and system failures is the deity’s pro weapon ?
Well well, here are some pretty easy ways to understand the basic showdowns of programming via real life occurrences. Let the battle begin!

Credit: The supremely talented, Ricky Wilsons.

ENTER THE GOD’S BATTLEFIELD WITH A CODER’S GEAR!

1. While vs Do while (Entry and Exit Controlled loops)

Situation: The scary boss is in the same grocery store as you.

Do While: You gotta pay your greetings atleast once to him and then you may leave. (run as fast as you can,if it’s plausible!)

While: Applicable to your colleagues outside, who can check at the entrance. itself,whether they ought to enter the now dreaded area or not.

2. Switch Case vs If Else (Decision Making)

Situation: Buying a mobile phone

Switch Case: You choose one based on the features you have pre-decided.
If Else: You compare phones on the spot with each other and then finalize.

(Both do the same work but the former is a far more faster and sophisticated approach)

3. For Loop (Iterative statement) vs Recursion

Situation: Playtime with dolls

Recursion: Russian dolls are figurines with the biggest doll on the top and as you start uncapping it’s head,you find smaller and smaller dolls in each of them ,till the smallest is obtained.

For Loop: All dolls are laid out on a table and starting from the first doll standing,you count each doll till your gaze reaches the last one.

4. Break vs Continue vs Goto (Jump Statements)

Situation: Standing in a queue of your hostel mess

Break: Your stomach growls too loud and you walk out of the mess in embarrassment.(Highly likely if after all the wait,the food is anyway going to be indigestible)

Continue: The lunch lady gives you your share of food and you realise out loud that it has a dead rat in it.As any sane person will do,all others behind scuffle away and the line disassembles. (Not highly implausible anymore ,after one of the reputed institutes’ recent hygiene checks)

Goto: Your friend has saved a space for you to stand,much to the annoyance of others patiently standing behind.So you beeline straight to her.

Do let me know if you can think of any more examples! I would be more than happy to discuss the infinite possibilities. :)

--

--

Sampada Bhatnagar

Writer at The Startup, UX Collective, Geek Culture & Nerd for Tech | Grad Student at IUB | Believer Of Creativity & Curiosity Combo