I’m getting rather hacked off seeing boolean properties typed as strings. Stringly typed is a phrase I learnt off a post from the excellent Coding Horror blog and it describes a phenomena whereby properties that are of a specific type, e.g. Boolean, Date, int, are stored needlessly as strings.
I’m working on a website that communicates with a money laundering service to check whether an individual is “bad” or not. Individuals can pass the test, but importantly it is possible to pass the test with some warning flags raised. If any of the warning flags are raised then an email should be sent off to compliance for them to do…whatever it is they do. Fair enough right?
The warning flags are obviously booleans. There was either a warning raised or there wasn’t – there are no two ways about it (no pun intended). In the serialized response, the warning flags are encoded as “Yes” or “No”…which is understandable. Now, upon receiving the response, it is parsed and turned into an internal representation. This is where things get really weird. The programmer that coded the object that stores the response from the service has decided to encode the warnings as strings, initialised to “”. Which is totally fucking bonkers.
Why?
Well, now our boolean warnings aren’t really booleans – they have WAY more than two possible values and the meaning of these values is subjective. One may consider “”, null, “No” as false, but could conceivably also consider “false” or “0″. We get the same sort of problem with true – “Yes”, “1″, “true” and then we get a whole load of unknown values which is every other possible string in the world. Which might be considered to be true.
So how the hell can any number of programmers work on this piece of code without introducing errors because of differing definitions of truthy and falsey values? Well, they can’t. To illustrate the problem further, even loosely typed languages differ in their boolean coercion, for example JavaScript and PHP:
<script>
if("0") alert('Opposite day!');
</script>
<?php
if("0") echo 'Opposite day!';
?>
JavaScript considers “0″ true but PHP considers it false. Personally I think JavaScript is “right” here, but as I said before, it is totally subjective.
The icing on the cake is of course the extra code you have to write to check the truthy or falsey string values. Something along the lines of “if x is not null and not empty and not the word No then it is probably true…probably”, which would otherwise have been coded as “if x then true” if x was a boolean – which is orders of magnitude shorter.
Of course, there are some bat shit crazy strongly typed languages that allow you to assign null to a Boolean, but that is a different story altogether.
morvex hub – Layout feels clean, navigation is smooth and information is easy to locate.
brixelbond online – Everything appears well-arranged, giving a trustworthy feel.
glintgarden.shop – Perfect for garden enthusiasts, I always find the best items here!
yavex review – Simple interface, content is well organized and browsing is fast.
Blanket Bay selection – Comfortable, stylish items with a smooth and effortless shopping experience.
Browse Auroriv – The site looks modern and offers something for everyone.
Bright Bento Finds – Stunning bento boxes, these are the best I’ve found for daily use.
Arc Loom picks – Always fun to browse, there’s usually something unexpected.
coppercitrine.shop – A wonderful selection of copper decor with a contemporary edge, highly recommend this store.
charmcartel.shop – The accessories are chic and the site is super intuitive to use.
crystalcorner2.shop – Love this place! A fantastic variety of beautiful crystals and gems.
florafreight.shop – If you’re a fan of beautiful gardens, you’ll love shopping here for flowers and plants.
xylix portal – Clear design, moving through pages is simple and enjoyable.
chicchisel.shop – A solid selection of premium tools, always great to shop here!
this trust site – The design stays minimal and the content comes across clearly.
check nevrix online – Easy-to-use site, information is well presented and browsing feels natural.
Flower favorites – Elegant and thoughtfully designed items with a floral touch.
learn more here – Pages are clear, and the design feels contemporary and user-friendly.
Car essentials hub – Products are easy to find and the experience is smooth.
Floral Wonders – Stunning floral items, and the website design makes shopping effortless.
xorya portal – Pleasant design, pages load quickly and details are easy to locate.
glintvogue.shop – Perfect for discovering chic and trendy pieces, highly recommended!
coralcrate.shop – Awesome items with great design, and the site is so straightforward to use!
Elegant home finds – Great options for making a space feel more elevated.
visit vixarobonding – Well-organized site, pages respond quickly and content is readable.
charmcartel.shop – Amazing accessories for every occasion, the site is so easy to use.
curtaincraft.shop – Love the range of curtains here, so many stylish options to choose from.
freshfinder.shop – Always something new and cool to discover here, I keep coming back for more!
explore plixo – Clean interface, finding details is quick and the site works well overall.
Charming selections – Stylish gifts and decor with a smooth online shopping experience.
Briovanta Selection – Amazing unique pieces, with an effortlessly smooth shopping experience.
Bag hub – Always discovering stylish products I can’t wait to try.
this qulavoholdings site – Pleasant experience, content is clear, and structure makes browsing smooth.
browse trustco – Clear, organized layout that helps the site feel trustworthy and competent.
zexarotrustco online – Professional feel with content arranged logically and no distractions.
covecrimson.shop – Great selection of bold, premium goods. Shopping here is always fun and easy.
gardengalleon.shop – Highly recommend for gardeners, it’s full of great products to elevate any garden.
cypresschic.shop – A perfect place for chic and high-quality products, user-friendly interface too.
Value picks – Smooth experience with prices that actually make sense.
goldenget.shop – An easy and convenient shopping experience with so many quality options!
zarvo info – Clean structure, information is accessible and navigation works well.
cinnamoncorner.shop – The variety here is fantastic, and the items are always so unique!
References:
Paradise casino
References:
dubizzle.ca
Blue Quill online – Amazing designs and a variety of high-quality products.
Briovista World – Love the elegant design and variety of products, makes shopping here so enjoyable.
Beauty picks – Quality items and easy navigation make shopping enjoyable.
cozycarton.shop – A wonderful selection of cozy gifts, perfect for pampering yourself or loved ones.
gemgalleria.shop – Beautiful gems and jewelry for all occasions, I love the variety!
dalvanta.shop – A must-visit for unique style lovers! Always a smooth shopping experience.
charmcartel.shop – The accessories here are stunning, and the website is so user-friendly.