Mar 10, 2012 12:37 PM
I think Murphy’s law is particularly relevant to software engineering, especially if we consider the full statement sometimes attributed to Murphy:
If there's more than one way to do a job, and one of those ways will result in disaster, then somebody will do it that way.
This is true of UI design; if we let the user enter data without validating it, then surely someone will do that. But I’m thinking particularly of database design:
If you design a database such that a programmer can put corrupt data into it, then eventually some programmer will do that.
And it will be mess, when you find out about that bad data later. The obvious rules apply here – use foreign keys to enforce relationships between tables (yes, there are people building databases on MS SQL Server with no foreign keys.)
But there are a lot of more subtle irregularities that can be prevented with a little planning, by applying constraints to columns. What does a NULL mean in that bit field? Nothing? Then make sure it’s NOT NULL. The reverse is true as well – are you using an empty string to indicate that no value has been entered into a field? It might be better to use a NULL for that. The ZipCodeLastFour field shouldn’t allow three digits, or five.
Some might argue that these things are validated in the UI or business layers, and don’t need to be enforced in the database. But Murphy’s law applies – someone is going to write the validation wrong, or the SQL statements that submit the data, or some import process. Figuring out how to fix your data is always a whole lot harder than preventing it from being corrupted in the first place.
Mar 01, 2012 1:34 PM
I was trying to switch to an embedded background image for my Flex application, and this syntax works:
<?xml version="1.0" encoding="utf-8"?>
However, I had fiddler open at the time, and noticed that flash was getting a 404 Not Found, while trying to retrieve an image at http://mydomain/@Embed(source='./images/soselec_bg.jpg'). Fail.
I couldn’t figure out why this was happening, but did find a different way to embed the image, that doesn’t result in the failed request for a file that doesn’t exist. I used the standard embedding format:
protected var BackgroundImage:Class;
Then programmatically assigned the background in my preInitialize handler:
protected function preinitializeHandler(event:FlexEvent):void