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.
of course like your website but you need to check the spelling on several of your posts. Several of them are rife with spelling problems and I in finding it very troublesome to tell the truth on the other hand I?ll surely come again again.
very good publish, i definitely love this web site, keep on it
of course like your web-site but you need to check the spelling on quite a few of your posts. A number of them are rife with spelling issues and I find it very bothersome to tell the truth nevertheless I?ll definitely come back again.
I think other website proprietors should take this web site as an model, very clean and great user genial style and design, as well as the content. You’re an expert in this topic!
I like the valuable information you provide in your articles. I will bookmark your blog and check again here frequently. I am quite certain I will learn plenty of new stuff right here! Best of luck for the next!
Автор статьи предоставляет важные сведения и контекст, что помогает читателям более глубоко понять обсуждаемую тему.
Накрутка подписчиков в Инстаграм – ТОП-25 способов в 2026 году https://vc.ru/1437934
Деньги в долг в Казахстане можно получить без сложных процедур. Онлайн кредитование экономит время и силы. Заявка заполняется в удобное время. Решение приходит в короткие сроки. Кредит наличными может быть выдан без залога: официальный сайт
Нужен проектор? projector24.ru большой выбор моделей для дома офиса и бизнеса. Проекторы для кино презентаций и обучения официальная гарантия консультации специалистов гарантия качества и удобные условия покупки.
Cheap electric vehicles are affordable EVs designed for budget-conscious buyers. Many offers have good reliability basic features and low maintenance costs for daily commuting: https://ev.motorwatt.com/ev-manufacturers/
Frederick County Conservation – Clear focus on nature and wildlife, content feels local and engaging.
Enterprise solutions site – Well thought out, the content comes across as clear and useful.
Find Solutions Daily – Clear and engaging, content provides practical answers quickly.
Купить активных живых подписчиков в Телеграм – Мои проверенные 20 сервисов в 2026 году https://vc.ru/2333695
fastshoppinghub – Dependable site, checkout process was very easy and smooth.
corporatepartnerhub – Very user-friendly, makes commercial connections easy and fast.
enterprisetrustsolutions – Excellent resource, strengthened our strategy for enterprise bonds effectively.
networkingcentral – Really simple way to meet new people and expand your social circle.
businessally – Helpful guidance, connected me with the right contacts efficiently.
bizscanner – Useful insights, made market evaluation straightforward.
Meaningful Projects Daily – Clear and practical, ideas help guide creative work regularly.
taskstrategist – Very insightful, made planning and workflow more efficient.
productivitycenter – Simple, actionable tips, really improved how I work.
OBDNet auto resource – Dependable and practical, resources make vehicle maintenance easier.
smartcommerceplatform – Site is user-friendly, navigating products was quick and simple.
easybuyzone – Hub is user-friendly, locating items online is very easy and efficient.
alliancesuccesspath – Advice feels well thought out and helped strengthen future-focused collaborations.
trustworthy shopping page – Secure and seamless process made buying products easy and fast.
strategic workflow resource – Practical insights that improved team efficiency and project management.
fastconsumerclick – Online shopping is easy here, payment process went seamlessly.
Learning journey starts here – Pleasant idea, the site gives off a supportive and positive learning atmosphere.
partnergrowthclick – Actionable advice for alliances, really accelerated building key business relationships.
actionablegrowthtools – Insights are practical and easy to apply for real business results.
smartexperiencehub – Very flexible interface, purchasing online was smooth and simple.
Easy Ways to Smile – Simple and engaging, advice inspires daily positive actions.
buyingtipscenter – Reliable shopping advice, made the buying process smooth and hassle-free.
fastonlineshop – Platform runs smoothly, digital shopping experience was convenient.
business alliance roadmap – Practical guidance that streamlined partnership planning and execution.
actionideas – Useful recommendations, helped me optimize work processes quickly.
dailyactionableinsights – Advice given is useful, enhanced efficiency in our workflow processes.
Gardens AL Neighborhood Info – Relaxed presentation, all local updates are simple to understand.
enterprise collaboration guide – Solid guidance that improved alliance-building outcomes.
business collaboration page – Actionable ideas that helped teams align and grow together efficiently.
fastbuyonline – User-friendly site, checkout was seamless and fast.
smartpowerhub – Practical strategies that helped reduce energy waste significantly.
learnbusinesshub – Lessons are simple, practical, and very easy to understand.
planningstrategyclick – Guidance is concise and helpful, made planning meetings more productive.
trustedbizhub – Very effective networking tools, helped me expand my professional circle.
futuregrowthacademy – Content is concise and helpful, allowed me to build important future-ready skills.
businessstrategyhub – Planning guidance is practical, made developing my next strategy simple and fast.