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.
forward drive – Short and approachable, illustrating how intentional force creates momentum.
press bros catalog – Clean interface, product details are thorough and the site feels dependable.
InspirePath – Clear structure keeps creative content easy to understand.
team tadros updates – Organized and polished, highlighting values and focus areas effectively.
GrowthCompass – Clean design and clear direction make the site feel purposeful and well-planned.
progress key – Thoughtful point, growth is the key element that ensures smooth, ongoing progress.
energized thinking – Helpful message, unlocking ideas energizes movement and maintains steady advancement.
TractionFocus – Motivating site with clear explanations and a smooth browsing experience.
Idea Compass – Direct, well-presented advice allows readers to take actionable steps quickly.
Action Driven Success Online – Dynamic layout, reading and applying strategies is straightforward.
forwardgrowthhub – Smart idea, growth moves forward smoothly when effort and focus are aligned today.
smartsolutionhub – Helpful portal, easily navigate and locate solutions for everyday challenges.
Action Flow – Structured content and simple navigation make learning straightforward.
Clarity Hub – Layout and content presentation simplify understanding of key concepts.
movement clarity – Clear guidance, makes progress feel smooth and effortless in daily tasks.
Fur Kids Picks – Well structured, product selection is clear and shopping feels easy.
action leads the way – Concise and natural, emphasizing forward steps.
GrowthDirection – Simple layout paired with helpful insights for steady progress.
guidance drives energy – Clear, motivating phrasing showing how structured direction improves outcomes.
CleverPath – Well-organized pages provide actionable insights without clutter.
moes food hub – Easy-to-navigate and vibrant, had me wanting to try everything right away.
clear path – Encouraging idea, clarity clears the path for progress to flow naturally.
GrowthMomentum – Thoughtful layout supports focused and inspiring content.
guided alignment – Thoughtful phrasing, guided direction brings alignment that improves efficiency.
Forward Hub – Content is presented clearly with navigation that feels natural.
growthblueprint – Nice approach, careful planning ensures growth unfolds smoothly and predictably.
Forward Path – Clean structure with helpful content encourages visitors to implement concepts effectively.
BestPickDaily – Helps you locate smarter selections without unnecessary hassle.
IdeaPaths – Clean layout and concise content make discovering ideas fast.
Motion Insights – Well-organized presentation helps users absorb concepts quickly.
focused power feed – Motivating concept, feeding energy deliberately enhances output naturally.
LearnBetter – Encourages practical steps to improve skills and understanding.
W4 Election Portal – Clean and organized, content is clear and site is simple to use.
calmly guide progress – Gentle phrasing that inspires deliberate and confident movement.
GrowthSteps – Clear sections and concise ideas keep the experience user-friendly.
PathToFocus – Structured guidance and clear messaging help users plan and succeed.
flow with purpose – Gentle, motivating tone linking focus with continuous forward movement.
uncommittednj portal – Short and engaging content, ideas are presented clearly for readers.
leverage builder – Motivating concept, clarity builds leverage that strengthens work output over time.
VisionaryPath – Clear design enhances understanding of useful, everyday strategies.
Progress Hub – Structured design and thoughtful content encourage practical action.
motion propelled – Insightful concept, proper direction propels motion smoothly and predictably.
Step Forward – Structured pages with concise advice guide readers toward immediate action.
NextPick – Modern layout ensures smooth navigation and quick selection of items.
plannedgrowthdesign – Clear strategy, growth through thoughtful design feels structured and achievable each day.
growth momentum – Strong phrasing, gradual progress keeps momentum moving in the right direction.
Momentum Hub – Practical guidance is presented in a clean and readable format.
a href=”https://createimpactplanningframework.click/” />PlanSmart – Professional layout allows users to plan tasks with clarity and ease.
action builds momentum – Short, energetic wording emphasizing steady progress.
IdeaExplorer – Easy-to-use site that inspires curiosity and innovation.