Saturday, December 19, 2015

Code readability: avoid negative statements

Negative statements are more difficult to read and not always the straightforward approach will result in the better code from the first attempt. Let's say the procedure should react on certain condition and ignore all overs. Compare these two snippets:

if (!isGreen) 
if (isGreen) return;
The second one is more readable but more verbose (so as human language). Also the second one is obviously a separate method while the first one could be an inline code. In this case refactoring to the better readability resulted in more cohesive code.
If you're a tough C# programmer and reading both snippets is no brainer for you - consider this SQL nonsense:
DELETE FROM Cross_Reference_Between_Left_And_Right WHERE xId IN 
    (SELECT xId FROM Left_Table WHERE xNamePrefix NOT IN ('pro','contra'))
DELETE FROM Cross_Reference_Between_Left_And_Right WHERE xId NOT IN 
    (SELECT xId FROM Left_Table WHERE xNamePrefix IN ('pro','contra'))
For me personally, the first one is an eyesore.

Wednesday, July 15, 2015

Give it a name: taming a domain vocabulary

While comprehending a business problem it is a good idea for a scrupulous technologist to learn the language of locals (a.k.a. Subject Matter Experts or Those Who Do Business). It could be a ubiquitous Esperanto of "KPI ETA TBD ASAP" or more wordy (but not more descriptive) "partial amendment of the retroactive memo transfers". Surprisingly, a mutual exercise of assigning a short one-words names to operations or processes can shorten a requirement gathering and even make it fun: the business expert will be forced to look at daily activities from a new angle. Side effect: presentations (and meetings!) will shorten.
And the examples of what actually did work:
process of capture and input of the initial client data = client onboarding
partial amendment of the retroactive memo transfers = retro-partials

Tuesday, April 14, 2015

A belated and very theoretical retrospective on raising a child

1. Whatever you feel while raising your child (which at the moment may seem like suffering) you will sorely miss later. Cherish every single moment.
2. You will always be able to catch that opportunity, movie or even that party -  but you will never get back the day when your daughter was 4 years, 2 months and 12 days old.
3. There is never ever enough of video and photo memories of your parenting days. Not even close. So keep taking pictures and shooting videos.
4. Until they are old enough they mean no evil. That priceless vase could as well got shattered on its own. Be patient. You may be still regretting things you've done and said a decades later.

And while you in the trenches:
1. Baby sleeps - you sleep. If and only. So grab every opportunity.
2. You actually can work from home with kids. But only if they are under 1 month or are between 10 and 12 years old. First group is capable of enjoying lengthy sleeps, second - rejects your attention already while still being incapable yet to render a truly major trouble on themselves.

Inspired by LifeHacker's "# 10 Things I Wish I Had Known Before Becoming a Parent"

© 2008-2013 Michael Goldobin. All rights reserved