You think the CSVDB is funny
Introducing the CSVDB – The Daily WTF
I did too. Until someone told me they were working on adding a “metadata table” to our application. Meaning they could hang arbitrary fields and data off of any table in the database. Then I saw this article.
Use the Entity-Attribute-Value (EAV) Model.
The EAV is a generalized form of row modeling, which basically means a single
table with three columns, an entity (such as a patient), an attribute
(such as an allergy, which is actually a pointer into a metadata table),
and a value for the attribute (e.g., penicillin). In EAV models, a single
fact is stored in an “entity attribute” table. By contrast, in a conventional
table that has one column per attribute, a row can store multiple facts. EAV
works well when the number of attributes that potentially apply to an
entity is significantly more than those that actually apply to an
individual entity. For instance, if a single patient can potentially have
hundreds of attributes, but typically each patient only has a dozen attributes,
then EAV may work well. Although EAV models are quite extensible, they are
typically considered much harder to manage by DBAs because applying standard
relational techniques such as normalizing, adding constraints, attaching
triggers, etc., doesn’t work very well. While I have used the EAV model with
great success in the past, I only suggest it for groups with very strong
understanding of relational data models that can understand the drawbacks as
well as the benefits.
He makes it almost sound reasonable. Cost effective even. I’m hardly a standards and practicies nazi, but I think I’d like to have a little bit more control over data that I might have to query.
Grabbing arbitrary elements from the DOM
In the Javascript library I'm working on, I needed to be able to grab all of the elements in the page DOM that had a certain attribute. There isn't any way through the DOM to currently do this. So I came up with this little function. It appears to be working, but I haven't tested it with a very complicated page yet. The library is based on the Dojo toolset, so I'm leveraging some of it's built in methods like forEach. Right now it just returns a standard Javascript array like the other dom get* methods, but that may change to a hashtable at some point.
-
if(document.getElementsByAttribute == undefined) {
-
document.getElementsByAttribute = function(attribute, parentElement) {
-
var _selectedElements = new Array();
-
var _allElements = document.body.getElementsByTagName('*');
-
dojo.lang.forEach(_allElements,
-
function(node) { //have to use getAttributeNode since it's the only one supported by all browsers
-
if (node.getAttributeNode(attribute) != undefined) {
-
_selectedElements.push(node);
-
}
-
}, true);
-
return _selectedElements;
-
}
-
-
}
n.b. There's a bug in the code. It doesn't actually use the parentElement if it's provided. It's pretty trivial to make it work. Eventually I'll update this code with the fixed code.
Polymorphic relationships in Rails
Rails 1.1: RJS, Active Record++, respond_to, integration tests, and 500 other things!
-
class Author <ActiveRecord::Base
-
has_many :authorships
-
has_many :books, :through => :authorships
-
end
That is beautiful.
IE 7 beta 2 = very beta
I just installed IE 7 beta 2 on my backup machine. It lasted about 10 minutes. It was unusable. In the brief flashes I did see, it looked like it worked OK for rendering pages. But it kept shooting the CPU up to 99% and staying there. I did my part and sent the error reports to MS.
The site it seemed to have the most trouble with was out Exchange OWA site. First it blocked a popup when I clicked "Reply". Ok, I'm sure I can allow the popup for that site. Whoops, nope. I've locked up. OK, we'll restart. Browse to the OWA again, whoops locked up loading the message.
On a positive note, this web site finally looked the same in IE 7 and Firefox. Yay! I can use this design, I just have to hang on until IE 7 is stablized.
Visual Studio 2005 and old web projects
Man, I'm having a heck of a time migrating our app projects to Visual Studio 2005. Well, actually to ASP.NET 2.0. I've got the projects converted over to the new format, including our web projects. But the architecture on this app is so horked and the way the web projects worked has changed so much in 2.0 that every fix-and-compile begats another 20 or so compile errors. Can't find this, can't access that.
One example, the folks that originally wrote this app constructed a "Common Fields" user control and it contains an "Error Message" user control (which just consists of a single span using an eval to output a private member var.). Well, since the "Common Fields" user control declares the "Error Message" user control, and user controls aren't apparently aren't included in the namespace by default, the "Common Fields" class won't compile because it can't find the "Error Message" class. So I'll have to refactor that. This could be a lengthy process and it might not make sense to continue it. It might mean either leaving well enough alone or re-writing the majority of the web UI. Which really wouldn't hurt my feelings any. I took over this project kind of against my wishes. The architecture is just so....
Well you know how a well poured black-and-tan has two distinct layers? You know what happens when you shake it? Someone shook the hell out of this app. The "Business objects" just pass DataSets directly to the UI. The UI enforces business logic, sometimes using client script, sometimes using server side script. The app is stovepiped from the UI directly to the tables. It's very frustrating to work with. Adding a new field to any form means having to change at least two stored procedures, two tables (one main table, one audit table), the biz object for the form, and the code behind in at least two places (four if the field is a drop down list). Ugh.
Passionate employees
Businesses want passionate employees because passion = works long hours for no compensation.
Dare Obasanjo aka Carnage4Life - Your Passion Underwhelms Me
