Stringly Typed Booleans

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.

13,491 thoughts on “Stringly Typed Booleans

  1. usa usd 200 no deposit bonus 200 free spins 2021, aristocrat lightning link pokies united kingdom versions
    and online gambling poker australia, or usa online casino lists

    my blog post – blackjack lighting mlo (Chase)

  2. Thanks for another informative web site. Where else could I get that type of info written in such a perfect way? I’ve a project that I’m just now working on, and I have been on the look out for such information.

  3. Hello, i think that i noticed you visited my weblog so i
    came to go back the want?.I am attempting to in finding
    issues to improve my web site!I guess its good enough to use a few of your ideas!!

  4. One other thing I would like to express is that in lieu of trying to suit all your online degree classes on days and nights that you end work (since most people are worn out when they get home), try to find most of your classes on the weekends and only one or two courses for weekdays, even if it means taking some time off your saturday and sunday. This is beneficial because on the saturdays and sundays, you will be a lot more rested plus concentrated on school work. Thx for the different recommendations I have learned from your website.

  5. united kingdom online casino real money no deposit bonus, australian online casino deposit bonus and online poker for money usa, or bingo united kingdom on gsn

    Also visit my blog post: blackjack big side bets; Christi,

  6. Viisual heⅼⲣ in OMT’ѕ curriculum mаke abstract concepts concrete,
    promoting ɑ deep recognition for mathematics and inspiration tо conquer exams.

    Dive іnto ѕelf-paced mathematics proficiency ԝith OMT’s 12-month e-learning courses, totaⅼ with
    practice worksheets аnd taped sessions for extensive revision.

    Аѕ mathematics underpins Singapore’ѕ credibility foг excellence in global criteria
    like PISA, math tuition іs key tо unlocking a
    child’ѕ prospective ɑnd protecting academic benefits
    іn tһiѕ core topic.

    primary school school math tuition improves rationsl thinking, crucial f᧐r
    translating PSLE questions including sequences аnd rational deductions.

    Ɗetermining and fixing ρarticular weak points, like іn likelihood оr coordinate geometry, mɑkes
    secondary tuition indispensable fоr O Level quality.

    Junior college math tuition іѕ important for A Degrees аs it groԝѕ understanding ⲟf innovative calculus topics ⅼike
    combination methods аnd differential formulas, ԝhich arе main to
    the exam curriculum.

    OMT’s special technique inclսdes а curriculum that enhances thе MOE framework ѡith joint components, urging peer conversations оn mathematics ideas.

    OMT’s platform іѕ easy to use one, so even beginners саn navigate and start enhancing grades promptⅼy.

    Singapore’s integrated mathematics educational program tаke advantage of tuition tһat attaches topics across levels f᧐r natural examination preparedness.

    Αlso visit my site; math tuition for primary 4

  7. It’s going to be end of mine day, but before finish I am reading this wonderful article to increase my knowledge.

  8. Thanks for your article. My partner and i have constantly observed that almost all people are wanting to lose weight when they wish to look slim plus attractive. Having said that, they do not generally realize that there are other benefits to losing weight in addition. Doctors claim that obese people suffer from a variety of ailments that can be directly attributed to their excess weight. The great news is that people who sadly are overweight in addition to suffering from a variety of diseases can reduce the severity of the illnesses simply by losing weight. You are able to see a steady but noticeable improvement with health if even a moderate amount of weight reduction is attained.

  9. buy poker machine united kingdom, canadian gambling statistics
    2021 and united statesn online pokies sign up bonus, or united statesn russian roulette app
    gun – Demetrius – european difference

  10. What’s up to all, because I am really eager of reading this weblog’s post to be updated daily.
    It includes nice information.

  11. A motivating discussion is worth comment. I believe that you should write more
    about this subject, it may not be a taboo subject but generally people
    do not speak about these issues. To the next!
    Best wishes!!

  12. I have been exploring for a bit for any high-quality articles or
    blog posts on this kind of house . Exploring in Yahoo I ultimately stumbled upon this site.
    Studying this information So i’m happy to express that I have a very good uncanny
    feeling I came upon exactly what I needed. I most no doubt will make certain to don?t put out of your mind this web site and provides it a
    look on a continuing basis.

  13. I like the helpful information you supply for your articles.
    I will bookmark your blog and check once more here frequently.
    I am somewhat sure I will be informed a lot of new stuff proper right here!

    Good luck for the next!

  14. Incredible! This blog looks exactly like my old one! It’s on a completely different topic but it has pretty much the same layout and design. Superb choice of colors!

  15. OMT’ѕ adaptive knowing devices customize tһe journey,
    turning mathematics гight іnto ɑ cherished friend аnd motivating unwavering
    exam dedication.

    Օpen your kid’ѕ full potential іn mathematics with OMT Math Tuition’ѕ expert-led classes,
    customized to Singapore’ѕ MOE syllabus fоr primary
    school, secondary,ɑnd JC trainees.

    Ꮤith students іn Singapore bеginning official math
    education fгom day one and dealing wіth high-stakes assessments, math tuition ⲣrovides tһе
    additional edge needed to achieve leading efficiency іn tһіs important subject.

    With PSLE matgematics concerns typically
    involving real-ᴡorld applications, tuition ρrovides targeted
    practice to develop crucial believing skills neϲessary fοr
    higһ ratings.

    Secondary math tuition overcomes tһe limitations оf huge classroom sizes,
    offering focused focus tһat boosts understanding fⲟr O
    Level prep ԝork.

    Ꮃith A Levels influencing career paths іn STEM areas,
    math tuition strengthens fundamental skills fоr future university rеsearch studies.

    OMT differentiates іtself ѡith а customized syllabus that matches MOE’s
    Ьy including inteгesting, real-life circumstances tо increase pupil passion ɑnd retention.

    Aesthetic aids ⅼike diagrams һelp envision issues lor, boosting understanding ɑnd exam performance.

    Math tuition minimizes examination anxiety ƅy supplying consistent revision apprߋaches customized tο
    Singapore’s requiring educational program.

    Visit mу web blog maths snag tuition centre
    toa payoh, Zelda,

  16. Hi, this weekend is pleasant designed for me, for the reason that
    this time i am reading this fantastic informative article here at my house.

  17. Thanks for the concepts you have contributed here. Moreover, I believe there are numerous factors which keep your automobile insurance premium all the way down. One is, to contemplate buying cars and trucks that are inside good set of car insurance organizations. Cars which are expensive will be more at risk of being lost. Aside from that insurance coverage is also in accordance with the value of your car or truck, so the more expensive it is, then the higher your premium you only pay.

  18. I visited several web pages but the audio feature for audio
    songs existing at this web page is truly wonderful.

  19. Хочу выделить материал про Практичные финансовые советы для начинающих инвесторов.

    Смотрите сами:

    https://rubl-fin.ru

  20. After examine a number of of the weblog posts on your website now, and I truly like your method of blogging. I bookmarked it to my bookmark website checklist and will be checking back soon. Pls check out my web page as properly and let me know what you think.

  21. Hey would you mind sharing which blog platform you’re working with?

    I’m planning to start my own blog soon but I’m having a tough time choosing between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs and I’m looking for something completely unique.
    P.S Apologies for getting off-topic but I
    had to ask!

  22. all new zealandn poker rules, free spin casinos united
    kingdom and online baccarat cheat (Vernon) casino
    uk free 10, or online poker licence australia

  23. OMT’ѕ encouraging responses loopholes urge development frame of mind, helping students love mathematics ɑnd feel inspired foг examinations.

    Discover the convenience οf 24/7 online math tuition at OMT, wһere engaging resources mɑke discovering fun ɑnd reliable foг all levels.

    Ꭺs mathematics underpins Singapore’ѕ credibility for excellence іn worldwide criteria ⅼike PISA, math tuition іs essential tߋ opening a child’s posѕible and securing scholastic advantages іn tһis core topic.

    Math tuition assists primary students master PSLE Ƅy enhancing the Singapore Math curriculum’s bar
    modeling method fⲟr visual prօblem-solving.

    Ᏼу offering comprehensive practice ѡith previouѕ O Level
    documents, tuition furnishes trainees ԝith experience and tһe capability t᧐ anticipate concern patterns.

    Tuition integrates pure аnd used mathematics seamlessly, preparing trainees fߋr tһe
    interdisciplinary nature оf A Level troubles.

    Τhe exclusive OMT curriculum distinctively improves tһe MOE curriculum
    witһ concentrated technique օn heuristic aрproaches, preparing pupils bettyer for exam obstacles.

    OMT’ѕ online quizzes provide instantaneous comments ѕia, so you can repair mistakes fast and sеe yߋur grades improve ⅼike magic.

    Math tuition supplies instant responses оn method attempts, accelerating renovation f᧐r Singapore examination takers.

    Feel free to surf tо mʏ website … tuition classes

  24. ConextSolution adalah konsultan ERP dan transformasi
    digital yang membantu bisnis meningkatkan efisiensi
    operasional melalui odoo ERP, SAP System, Business Intelligence, dan integrasi sistem.

    Sebagai partner teknologi odoo indonesia, kami menawarkan layanan implementasi
    odoo, jasa implementasi odoo, serta konsultasi dari tim odoo consultant indonesia yang berpengalaman.

    Selain itu menyediakan jasa ERP indonesia untuk berbagai industri, termasuk ERP manufacturing
    indonesia dan ERP retail indonesia. Didukung pengalaman implementasi di berbagai sektor, implementasi
    ERP perusahaan dapat berjalan lebih efektif dan sesuai kebutuhan bisnis.

    Tujuan kami adalah membantu perusahaan membangun sistem ERP untuk
    bisnis yang lebih efisien, mendukung pertumbuhan bisnis, dan mampu
    mengoptimalkan operasional di era digital saat ini.

  25. united states online casino real money, do you have to pay taxes on gambling winnings in australia and poker
    tour australia, or new zealandn free chip casino

    Here is my homepage :: simplified craps game – Lachlan,

  26. no deposit casino self exclusion form (Shanon) bonus codes cashable 2021
    usa, casino nsw united states and united kingdom real money casino, or online casinos
    accepting usa

  27. Fantastic website you have here but I was curious if you knew of any discussion boards that cover the same topics talked about here?

    I’d really like to be a part of community where I can get feedback from other experienced individuals that share the
    same interest. If you have any recommendations, please
    let me know. Thanks!

  28. I’m curious to find out what blog platform you are working with?
    I’m experiencing some minor security issues with my latest
    blog and I’d like to find something more safe. Do you have any suggestions?

  29. This is really interesting, You are a very
    skilled blogger. I have joined your feed and look forward to seeking more of your magnificent
    post. Also, I’ve shared your website in my social
    networks!

  30. Hi everyone, it’s my first visit at this site, and article is genuinely fruitful
    designed for me, keep up posting these types
    of posts.

  31. I’ll immediately take hold of your rss as I can’t to find your
    e-mail subscription hyperlink or newsletter service. Do you’ve any?
    Please let me recognize so that I may subscribe. Thanks.

    my site :: Cologne samples

  32. We absolutely love your blog and find a lot of your post’s to be exactly what I’m looking for.
    Would you offer guest writers to write content
    available for you? I wouldn’t mind composing a post or elaborating on many of the subjects you write in relation to here.
    Again, awesome website!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>