Yesterday I spent the day with my good friend and colleague from my group to work on some coding for the project. Let me just say from the outset that I respect this colleague for their technical prowess and their hard work ethic and this blog does not reflect upon this opinion.
The blog starts with my colleague explaining to me how he had facilitated the design and got a very early prototype of our program working. He explained the tribulations with the Gentle framework and the My Generation tool he and the team member from the other team used last week to turn our database design into a living breathing, business class and database persistence code.
Unfortunately, it doesn’t take me long to find that there has been a cost. And lets say that cost makes a kind of high pitched ‘screeching sound’ in my brain whenever I here details about it.
First up, the table names and columns have been renamed. ‘Gentle is sensitive to case’. Okey doke, so we inherit a naming convention for ourselves that gets rid of MS SQL’s stupid mixed-case, spaces-allowed convention, hooray!
Then, the database foreign key columns have been renamed to include the _id suffix. This went against what I thought was great pains last week to explain to them why I intentionally left the _id suffix off. The field names in the class for foreign key references are to be the type of the related object with a descriptive name. They weren’t to be primitive types which just stored the ID.
|DB column||person_id of datatype number||Person of datatype number|
|Class||person_id variable of type int||person var of class Person|
The db column name doesn’t matter too much since you can configure Gentle to use any column name. But the end result what my concern is.
The Good way means, you can just do something like Membership.getPerson().getName(). It’s already loaded in one swoop into memory when you load the membership. You can use a generation tool to make your code and it picks up on this aspect. (Well perhaps any tool except My Generation)
The Bad way means that you have to go, Person.Retrieve(membership.getPersonId()).getName() after you’ve had to already do a Membership.Retrieve(). Two retrieve calls versus one.
Any database framework worth its pinch of salt in my mind should load in the entire object and all the related collections (objects on the many end of a one to many relationship), not just save and persist the key, making it the developers responsibility to not only maintain the references are correct. In my code, I want to work with my objects, in my database I want to work with keys. The guys have missed the whole point of using a framework here.
Apparently, Gentle or My Generation (they use the term interchangeably, you’d think its one program — another minor screech), needs to see the _id otherwise it wont build list methods from it.
This is no biggie, I hold my tongue at this stage. They have missed a golden opportunity, I think. Hey I could be arrogant and wrong…. or just arrogant.
Oh, there is another thing, Gentle/My Generation needs the primary keys to be marked as IDENTITY columns so that they autonumber. (I later learn that MS SQL doesn’t have a CREATE SEQUENCE syntax like some other DB’s do). That’s fair enough, they defined a few sequences.
“We couldn’t figure out how to do it in TOAD, so we just changed the database directly and uploaded the database image backup to SVN… we don’t need the database diagram anymore”
I start fuming inside, given that the version of the database diagram they used do generate the code has been already out of date. It’s lacked columns and renames I’ve done over the last week. These amendments I’ve done were minor, but they were based on the feedback that Dave gave us when Andy took the design for review.
“Why didn’t you upload your file to SVN?” I ask.
“I couldn’t, I kept getting this error”. I look on his laptop, and see that there is a small yellow exclamation mark next to the Database Schema file. He then motioned to commit. The error message, to me anyway, tells me that his checkout is out of date, and he needs to do an update first. He does this. He gets another error message telling him that the file is in conflict with another recent change (mine) and he needs to merge it. He then brushes off the error reiterating that we don’t need Toad anymore since we’ve started developing.
I then proceed to explain that we still need those diagrams. For one, it is the documentation that will appear in our data dictionary, and follow on to the souls that will be doing work for this client next semester. Another point is that I have spent some time adding notes and column descriptions to the Toad model, and again, this documentation will come to help us or the future maintainers of the system later on.
My colleague recognises that those are important points but can’t validate their importance since given the short timeframe we have; ‘the clients indecision has ‘forced’ us into taking these shortcuts’. The changes I’ve made are relatively minor, why don’t we just add them to the un-commited, ‘more up-to-date’ file that my colleague has?
Toad has a useful compare function so we can quickly view these differences. It quickly becomes apparent that not much of the Toad schema has been modified at all but rather the changes to get the My Generation tool to work have all been done at the database level. The case names are still mixed case whereas the database is in lower, and there is the obvious lack of identifier fields. There are now dozens of changes because of this. Also, my colleague has added another table to represent the username and password field that I had added to the person entity in the version of the database schema he couldn’t see because he had a merge conflict he didn’t know how to get rid of.
Sccrrreeeeech. (One for me, I take some responsibility for only showing them the basics. But I did give them links to some really good guides, which told you what that fricken conflict icon meant in a second…. Why are people afraid to read manuals?)
(If only your parents enrolled you in some more team sports as a kid or made you get off that computer as a kid, not that I can talk, so you could express yourself more clearly and realise the importance of keeping everyone on the same page….wait a sec, am I getting mad at him?, or just that he reminds me of a younger version of me???)
The Toad file and the database schema that our only working code runs on are completely different. This leaves us with only one option, reverse engineer that database into Toad, then add the changes I made. The only problem is that now, we not only have the toad file to worry about, we also have to update the column and class names that were autogenerated by My Generation. But since we’ve started modifying these classes, using My Generation again to get the code into sync is out of the question, since it would write over those business classes and custom logic!
Whilst I still keep my comments to myself, my expression has changed considerably. My colleague, noticing my frustration asks what the matter is. It’s hard to express my disappointment, because I wasn’t there when they performed this work. They did what they could, with the tools they had, and they thought they did a reasonable job considering. My colleague offers that the changes they made weren’t the most ideal way of doing things, but that the looming time constraints have made the shortcuts justifiable.
I can appreciate this position, sort of, but from my experience, not that it is much broader than theirs if at all, tells me that this sort of mashing is a great way to lead to errors and bugs in the code. I can’t give this my blessing, yet I can’t find the words, nor the justification to scrap the work they have already done and rewrite the business layer and persistence in a more reusable, TESTABLE!!!!, maintainable way. All I see/hear, is shortcuts to get the code to compile and the program to run. In the long run, I see the client not signing off on UAT because the thing falls over, or worse, they sign off and the thing breaks after its deployed, if were lucky to keep this jalopy afloat for long enough to the deploy stage. This goes against what I’ve seen as a software developer in the workforce, and as what I’ve been taught as a uni student.
Q?: If you were on the Titanic, would you have told the guy that asked to increase the speed of the ship, which ultimately led it to being unavailable to avoid the iceberg, to piss off with his ‘lets get to america faster to show off this new boat’ request…
Thoughts of the risk seminar, the RMIT student admin project disaster and Dave Grants question during that seminar, ring in my mind. If they know better, why do they revert to using crap practises???
SC Ignorance REE is EEC bliss CHH
Its been about 2 hours since we’ve started. We haven’t even started coding like we planned yet. Grudgingly I agree to hold my tongue in order for us to get any work done. I ask to take a look at the code….
NO CLASS INHERITANCE HAS BEEN IMPLEMENTED BECAUSE THE DATABASE PERSISTANCE FRAMEWORK OR PIECE OF CRAP AUTOMATIC CODE GENERATOR CAN’T HANDLE SUBCLASSES. THERE WILL BE NO USE OF ANY POLYMORPHISM IN OUR CODE (and all code reuse benefits that come from it) BECAUSE EACH CLASS MAPS DIRECTLY TO ONE DATABASE TABLE. WHEN WE CODE, WE MUST CODE THE LOGIC THAT LINKS THE RELATED SUB/SUPERCLASSES TOGETHER. (Why don’t we just write the program in C?). OUR METHODS WILL TAKE THE SUPER CLASS + LOWER LEVEL CLASS AS PARAMETERS, THEY WILL HAVE SWITCH, IFS and LOOPS TO HANDLE EACH DIFFERENT TYPE OF SUBCLASS, THEY WILL REQUIRE 3 TIMES THE TEST CASES TO TEST ALL THE EXTRA CODE WE NEED TO WRITE TO DO THINGS THIS WAY. (so we wont bother with unit testing, just write a local application we can use to manually test the control layer functions in a system testing fashion)
All because of the time restrictions that have been placed on us by the client. Its not how we would do it in an ideal world, but lets do it in a completely stupid way that will take longer in the end because we don’t have enough time in the first place. 2 + 2 = 5. We don’t need to write unit tests, we don’t have the time.
Yeah, since you put it that way, that sounds perfectly fine to me. I forgot to add one thing….
(Yes, I’ve been told for using sarcasm, it’s a poor mans humour I know, not funny and I’m sorry)
What I did after that was look for the nearest chalkboard. Perhaps I could get my colleague to understand if I could demonstrate the sound in my ears. The closest thing I could find was an electrical fuse box, I stood on my chair, and started scratching at its panel.
Believe it or not, we did actually get some work done after that. We now have a new database policy that is designed to only work on the source TOAD file and propagate the changes automagically without intervening in the database directly. It is the responsibility of everyone to keep in sync with the changes and to update their own changes as soon as possible.
As I read over this blog, I realise the bitterness has taken over, I have become what I vowed I wouldn’t. Then again, I got the new Nine Inch Nails record last week. This depressing emo attitude, could be somehow linked to this new music I’ve been digesting recently. Ha!