Recent Articles

Jun 2016

The Validation Regex

by in Representative Line on

Regular expressions are a powerful tool for validating inputs, but what if your input is itself a regular expression? Is there a regular expression that can validate regular expressions?

Well, yes, if your regular expression engine supports recursion: /^((?:(?:[^?+*{}()[\]\\|]+|\\.|\[(?:\^?\\.|\^[^\\]|[^\\^])(?:[^\]\\]+|\\.)*\]|\((?:\?[:=!]|\?<[=!]|\?>)?(?1)??\)|\(\?(?:R|[+-]?\d+)\))(?:(?:[?+*]|\{\d+(?:,\d*)?\})[?+]?)?|\|)*)$/.


Analyze This

by in Feature Articles on

When asked to choose among several possible tools to do a job, qualified technical people look at the manual and test to see if the tool actually does what they need it to do. Is it reasonably configurable? Must it have root privilege to launch, or can it be installed as your application login id? Smarter folks will do a load test to see if it will scale beyond a handful of records and work with the expected volumes of data. And all of this will be combined to form an informed opinion as to whether the tool is appropriate for the task at hand.

High Level Managers have a different approach. They are too busy to deal with mere technical details.

Sigmund Freud Anciano

The Bare Minimum

by in CodeSOD on

Let’s say you needed to find the maximum and minimum values for a field in a SQL database. If you’re like most people, you might write a query like SELECT MAX(someval), MIN(someval) FROM table.

That’s the least you could do. That’s the bare minimum. And do you want to be the kind of person who does the bare minimum? Kevin L’s co-worker doesn’t. He’s a Brian.


Logging, Retooled

by in Feature Articles on

OR Route 38 erosion, Jan. 2012 storm

In every company, there is a tendency to value code that was invented in-house over code that was, to put it bluntly, Not Invented Here. There is an eternal struggle to find balance between the convenience of pre-packaged code that is not fully vetted and the trustworthiness of code they themselves have written. As is typical in these tales, Jon's company got it wrong.


It Ain't Over Til It's Over

by in Error'd on

"Countdowns are hard, particularly once they run out!" writes Peter.


Dumb's The Word

by in Feature Articles on

Thank-you-word-cloud

Brent's latest software project contained a story for adding a word-cloud to a PDF report that was already being generated on a production server using Java. Instead of being handled by Brent's in-house team, the requirement was assigned—against Brent's wishes—to overseas developers whom the company had recently contracted to "add more horsepower" to things.


Built Up

by in CodeSOD on

In most languages, strings are immutable. As developers, we often need to manipulate strings- for example, constructing output through concatenation.

Constructs like foo += " and then I appended this"; “solve” this immutability issue by creating a new string instance. If you’re doing a long round of concatenation, especially if it happens inside of a loop, this could get very expensive, which is why most languages also have a StringBuilder type, which allows you to append without all that overhead of new instances. Often, the advice is that you should prefer StringBuilder objects to string.


Putting the "No" in "Novell"

by in Feature Articles on

In the late 90's, Gregg was hired to administer a small Novell network at EduLoans, a student loan processing company. What it amounted to though was a toxic waste cleanup at a Superfund site. To say his predecessor, Loretta, was underqualified was a blunt understatement. The company wanted a network on the cheap, which included elevating a receptionist with slight technical skills to the ranks of Novell administrator. They figured the only training she would ever need was a two week hands-on Novell CNA course. Novell Netware login screen circa 1997

Loretta returned from training with tons of free swag in tow. This included a CD-ROM beta version of Netware 3.12, with bold text printed across its face reading NOT FOR USE IN A PRODUCTION ENVIRONMENT. Ignoring that, she convinced the President of EduLoans that they could get by with this great free version so there would be more money to spend on hardware - and her raise.


Now There's a Switch…

by in CodeSOD on

You know what’s awful? If-then-elseif conditions. You have this long, long chain of them, and then what? If only there were a shorter, clearer way to write a large number of conditions.

Oh, what’s that? There is? It’s called a switch statement? But doesn’t a switch statement only work on equality comparisons? I’d really like something that works on any condition.


Pirates, Your Days are Numbered

by in Error'd on

"If you pirate Windows 10, watch out," Norman D. wrote, "One week and 100 years from now, Microsoft is going to catch you."


Our Next Kickstarter: Lairs Board Game

by in Announcements on

I've been a board/tabletop gamer for as long as I can remember, even before writing my first program (obviously, 10 PRINT "ALEX IS COOL" / 20 GOTO 10). After seeing how much you supported the Release! game, it turned out that a lot of you are into games, too.


Trained Developer

by in CodeSOD on

ASP.NET, like any other web development system, has a “role provider” system to handle authorization. With a small quantity of code, you can hook your custom security settings into this API and get authorization essentially for “free”. Not every organization uses it, because it’s not sufficient for every security situation, but it’s a good starting point, and it’s guaranteed that it’ll be covered in any ASP.NET training course.

Paul’s employer recently found a new hiring strategy. Instead of hiring expensive, well qualified people, they hire completely inexperienced people on the cheap, and send them to training classes. That’s likely where this code started its life- cribbed from notes in a training class.


Coming of Age

by in Feature Articles on

When you discover the truth about Santa and the Easter Bunny, you die a little inside as you leave some innocence behind and begin to grow up.

When you get your first pay check at your first real job and discover that the government gets the first bite, you get a little disenchanted as you grow up.

Santa and the Ice Cream Bunny

Simulated Congealing

by in CodeSOD on

Simulated Annealing is a class of algorithms from moving through a search space to find a solution, balancing “good enough” results against a computational budget.

John L has a co-worker that has taken this logic and applied it to writing code. Whenever code needs to change, he “randomly” changes the function in small increments until it works. The result is code that looks like this:


The Shield

by in Feature Articles on

Russell M. knew better than to tempt fate. The last time someone asked him about Big Telco’s network downtime, he bragged about not having any since he began … only for the network to go down within minutes. That time, a construction worker plugged a power drill into a UPS and drained it.

This time, with no construction on-site, he couldn’t use that excuse.

A round shield from the 16th century with a gun port in the center, allowing the user to fire a weapon from behind the shield

All Rights Reversed

by in Error'd on

Tim B. writes, "If you violate Laotel's rights, does this mean that you can sue them instead?"


Lines and Lines and Lines of Order Lines

by in CodeSOD on

Darlene’s company uses Siebel for managing their enterprise. Like most enterprise software packages, it’s complicated, incomprehensible, and any significant maintenance depends on very expensive consultants.

During an upgrade, one of those Highly Paid Consultants caught a new requirement: customers wanted to be able to change an order, replacing one product code with another, all the way up until the order went into fulfillment. Now, the logical thing would have been to cancel the changed order line and create a new one, but our HPC couldn’t quite figure out how to cancel an individual line item, so he just decided to delete it instead.


A Costly Slip

by in Feature Articles on

Computer networks 080916-A-QS269-014

It was a lazy, drowsy Saturday afternoon. The sun was shining, birds were singing. The kind of day when children should be playing outside, perhaps running bases in a sandlot someplace, carefree and smiling. Even indoors, thanks to the cost-saving measures at Big Online Retail Store™ HQ, it was warm enough to send tantalizing daydreams of comfortable naps in soft places to the employees working the weekend shift.


A Dated Inheritance

by in CodeSOD on

Teppo works for a Finnish company that, among other things, develops a few mobile applications. This company is growing, and as growing companies do, it recently purchased another company.

One of the applications that came with this company had a mongrel past. It started as an in-house project, was shipped off to a vague bunch of contractors in Serbia with no known address, then back to an intern, before being left to grow wild with anyone who had a few minutes trying to fix it.


Patchwork

by in Feature Articles on

Most technical folks can recognize a developmestuction environment when they encounter one. The less fortunate among us have had one inflicted upon us. However, the one thing they all seem to have in common is that people simply make changes directly in production. I’ve encountered a place that takes the concept to a Whole New Level O’ WTF™.

The company is a huge international conglomerate with regional offices on 5 continents, spread fairly evenly around the globe. The team for this particular project has several folks (developers, testers, QA, UAT and prod support) in each of the locations. Each region is mostly a self-contained installation of servers, databases and end users, but just to make it interesting, some of the data and messaging is shared across regions. Each region runs the normal business hours in its own time zone. As such, at any given time, one region is always doing intra-day processing, one is always in night time quiet-mode, and the other three are in various stages of ramp up, ramp down, or light traffic.

A 'crazy quilt'- a quilt in a random and chaotic pattern

The Class B Bus

by in Error'd on

"The bus sign in one of Tel Aviv's train station gives out some interesting info on where to catch your next bus," wrote Eran C.


The Oracle Effect

by in Editor's Soapbox on

In 800BC, if you had a difficult, thorny question, you might climb the slopes of Mount Parnassus with a baby goat, find the Castalian Spring, and approach the Pythia- the priestess of Apollo who served as the Oracle at Delphi. On the seventh day of the month, the Pythia would sanctify her body by bathing in the waters of the spring, drinking water from the Cassotis- a portion of the spring where a naiad was said to dwell- while the high priest would sprinkle holy water about the temple. Thus purified, they’d take your baby goat, lay it before the fires of Hestia, and cut it open to read your answer from its entrails. Unless it trembled the wrong way- that was a bad omen; they’d throw an exception and tell you to try again next month.

The Oracle of Delphi, Entranced


Returnary

by in CodeSOD on

There’s a certain class of bad code we’ve all seen before:

boolean someFunction() {
    if (someBooleanExpression) {
        return true;
    } else {
        return false;
    }
}