Bad Architecture ...

I've taken on a project where I'm fixing up a project that has been through 10 different developers.  The base project is a publically available shopping cart system, that has been heavily modified for the project.  I managed to pick up the project after the other developers "took the money and ran", leaving an absolute mess.

The code is not pretty.  But, that's not the worst part.  The Database is an even bigger mess.  From a pure design standpoint, it makes sense.  The problem is, every column allows nulls.  As a standard practice, I never allow nulls in Databases.  Ever.  So, at least half of the problems that the customer is having with the system can be traced back to this problem of allowing nulls into the DB.

So, I've gone in and changed most of the null columns to not null, but there are even more issues.  Instead of just dealing with empty strings, the original developers did the whole field=null thing. 

Frustrating to try and dig out. 

Print | posted on Wednesday, January 11, 2006 10:48 PM

Feedback

# re: Bad Architecture ...

left by Brian at 1/17/2006 10:03 AM Gravatar
What's wrong with nulls?

You need the null value to descibe an object with "no value". E.g. lets say you have an amount column in which 0 is a valid amount. How would you tell the difference between a valid zero value and no value?

Anyway, I often code around the null problem by designing my table entity classes to use a default in case of null, but this is only because value types in c# can't be null (at least v1.1).

# re: Bad Architecture ...

left by Kyle at 1/18/2006 5:55 AM Gravatar
Nothing wrong with nulls. I'm sure they're useful. I just haven't found any use for them. I've been doing DB for 8 years now, and never once have *needed* a null value.

Yeah, I realize that there's a difference between a zero-length string and a null, but seriously, what's the point? One more level of checks?

# re: Bad Architecture ...

left by Brian at 1/19/2006 6:19 AM Gravatar
You don't need nulls, you can use default values instead. Look at it as just a different way to design.

e.g. "select * from someTable where someFKID > 0"

versus "select * from someTable where someFKID is not null"

BTW, I ran across this in the SQL Help for nulls:

"Important! To minimize maintenance and possible effects on existing queries or reports, it is recommended that you minimize the use of null values. Plan your queries and data-modification statements so that null values have minimal effect."

So it looks like you are justified not to use them, but I'm not sure I would go as far as to say a database design is poor ONLY because it allows null values.

In your case, since the null values are hosing the app the real question is, "who was the poorer designer, the database developer or the coder?". Is the app suffering because of poorly designed use of nulls in the database or poor handling of null values in the application?



# re: Bad Architecture ...

left by Kyle at 1/19/2006 7:23 AM Gravatar
Point well taken.

I'm starting to realize that the app (in its original state) was *fairly* solid. Flexible, yes. Nicely done from an implementation perspective. It's when the mods started to happen that all went haywire.

I also do typically use default values. (especially for dates).

Thanks for your feedback on all this!
Title  
Name
Email (never displayed)
Url
Comments   
Please add 3 and 1 and type the answer here: