Be True to Yourself

by in CodeSOD on

Ben M recently inherited some code from some Highly Paid Consultants. These consultants needed to be able to set some flags to control the behavior of the application, and for whatever reason, these flags needed to be strings. It probably wasn't a good reason, but there was some reason. The consultants wrote the module which set the flags, and guaranteed that the flags were only ever "true" or "false".

To parse those flags back into boolean values, they did it the true Highly Paid Consultant way: they used a generic "string to boolean" solution they copied from Stack Overflow instead of Boolean.Parse, the built-in C# method for turning "true" into a boolean value.


On Second Thought, I'll Just Go Back to Bed

by in Error'd on

Gordon S. wrote, "In seeing how someone botched the deployment of Windows on the flight boards, I sure hope that's ALL that admin was allowed to work on."


Waaaaaiiiiit for it…

by in CodeSOD on

There are many moments where our multi-threaded code needs to gurantee only one code path is executing at a time. That’s why we have locks, semaphores, mutexes, and so on. But those are all pretty complicated. Vincent H recently was reviewing someone’s code, and they found a far more elegant solution, which simply uses booleans.

For example, you could whip up a wait loop with a simple block like this:


The Ballad of Bart

by in Feature Articles on

Alvin had the fortune of working with an exceptional talent while he was employed at Virtucon. Bart knew how to do everything from desktop support to software development to database administration to IT security. Not only was he proficient in all of them, he also knew them better than those with many years of experience.

Bart had been with Virtucon since the early days, racking up nearly 20 years of tenure. During this time, he 'mastered' everything and asserted himself to the point that no changes could happen without his approval. His changes were auto-approved because of course any idea he had was a good one. This led to myriad problems for fellow IT people like Alvin, who were hired after Bart.


Tern Your View

by in Representative Line on

We all just love ternaries around here. So much. A powerful form of code golf, they can clarify and they can confound, but usually it’s just confounding.

Christopher sends us this example, saying, “This is an accurate indicator of the rest of the code.”


Typing for Types

by in CodeSOD on

Today, any sort of data access layer we build is going to be rooted in some sort of object-oriented design. It might be a full ORM, it might be an object-store database, it might be one of any number of kinds of database mapping tool.

What we usually don't do anymore is get a resultset with no type information, where we have to invoke the proper "GetXXX" method to fetch data out of what behaves more-or-less like a dictionary. Oh, we might have to do this, but we'll almost always bury it under a layer of abstraction to hide the ugly details.


Are You Not Satisfied?

by in Error'd on

"Does this mean that Toyota believes that hybrid owners are fundamentally unhappy with their cars?" writes Thom.


Oooooooooooooo no

by in CodeSOD on

Kids these days have their flexboxes and their ems and their position absolutes. In the olden days of HTML, we arranged everything with table tags and we liked it. Well, some of us did. Mike was recently doing part of a redesign, and when the background color of the page was changed, a bunch of garbage text appeared in various input forms. How could changing the CSS background color cause garbage text to appear?

<b>Billing Address Information</b>
<p class="style3">Billing Address 1:<font color=white>0ooo0.....</font><input type="text" name="BillStreet1"></p>
<p class="style3">Billing Address 2:<font color=white>o00000...</font><input type="text" name="BillStreet2"></p>
<p class="style3">Billing City:<font color=white>00o00..0.o...0..</font><input type="text" name="BillCity"></p>

Archives