Thursday's lessons
Published: 2014-01-09
Tagged: rails
If you, gentlereader, have had Hacker News in your RSS feed for any period of time than you surely know how close to our hearts the topic of failure is.
Some glorify it, for the lessons learned. Other abhor it, as an obstacle towards the Ultimate Acquisition/Pivoting/Investment/IPO.
Sometimes, it's just inevitable. Like today. I got my ass kicked so hard, it made me rethink my goals and methods. The worst possible thing I could would be to take it in a stride and continue on... committing the same error next week. Next month. Next year.
I received a task that required a decent amount of non-standard-crud-rails-app knowledge ie. design patterns and practices. This was my first project, small as it was, that I could apply all that I learned from Practical Object-Oriented Design in Ruby (no worries - non-affiliate link). I spent an hour and a half drawing up diagrams and even made a few sequence UML diagrams than I dove head-first into TDDing the design. Never had a chance to do that before, as I've always prototyped-cleaned up-spec'd-out.
Here's what went wrong
My design was failure. Oh, the design itself might not have been too shabby, but about 3/4 way in I saw it - the design I created cannot be applied to the current model ecosystem - with the associations and such. It might be good for applications without many associations. Not here though.
I saw some warning signs. I saw the law of demeter but I plowed on. Then I saw even more law of demeter violations. What'd I do? Plow right ahead, yes sir, head first into a wall.
Update 01/10/14 - Observer pattern. Using AR Observers is much preferred to using the before and after hooks for actions interacting with other objects ie. hooks good for checking state of self, observers good for sending out emails after user created. More on this here.
Those two items are big enough to warrant immediate termination of the patient. The code will be excised and made and example of. I can't give concrete examples, but it created a tightly coupled nightmare.
Salvaging the situation
Fortunately for myself, I wasn't terminated on the spot. My boss is a great guy hell bent on providing a learning environment for us and heard me out, saw the code, made some suggestions. One suggestion relates to me reading up more about these principles. I think that's good, but I'll also do a bit more - I've got a few weekend project ideas to build out. A perfect opportunity to get my hands dirty and practice conscious design. The second suggestion - to hit him up more often instead of plowing ahead at all cost - is even better.
I've had moral mentors and discipline mentors. But never a hands-on-dirty-work mentor. I always dove into books and tutorials (written word > youtube) and tried to pull myself up by my bootstraps over the wall of incompetence. And this time I will change it. Totally alien experience for me, but both me and the company I work for can only gain by this.
It's going to be a busy weekend.
Comments
Add new comment