Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On K.I.S.S and paving cowpaths [closed]

I'm currently developing a PHP application that's using an Access database as a backend. Not by choice you understand... the database is what the client used originally and using it is part of the requirements.

One of the problems with this database is that the column names have the most insane naming convention you could possibly imagine. Uppercase, lowercase, underscores, spaces and the plain insane. For example the column "gender" holds a date. And so does column "User2". There's a lot more but you get the idea.

Faced with this I decided to create an array to map the database columns to PHP variables so we can isolate the code from the madness. However my colleague believes that I'm over-complicating things and we should use the database's column names for the corresponding PHP variables so we don't need to go through the mapping array to find what goes where.

So my question is this... am I doing the right thing or am I complicating things?

like image 972
Manos Dilaverakis Avatar asked Nov 27 '08 12:11

Manos Dilaverakis


2 Answers

Absolutely you are on the right track. If you don't abstract away the madness you will eventually succumb to the madness yourself.

Your colleague has a valid point though, so I suggest you also code an easy way to determine the data to column mapping in PHP.

This isn't about keeping it simple, it's about retrofitting a solid foundation to build upon.

The thing that would worry me is that this kind of random design often hides certain business rules, things like "...if the gender is a date then they must have purchased a widget at some point therefore they can't be allowed to fribbish the lubdub... " - crazy I know but more common than it should be.

like image 164
Ed Guiness Avatar answered Oct 24 '22 15:10

Ed Guiness


Names are exceptionally important. If you want your application to be maintainable, fix them before the code base grows further.

like image 32
Nerdfest Avatar answered Oct 24 '22 14:10

Nerdfest