SuperPumpup (dot com)
General awesomeness may be found here.

12 August 2014

Mode Analytics Is Helping Me Become A Better Developer

Like most other "software writers" who primarily write Rails code I've met with, I don't have any formal CS training - or any formal training at all, really. I just started learning how to build things, which was hard and horrible in PHP and spectacularly easy in Rails. Love it or hate it, it's SO EASY to build systems in Rails when you have no idea what you're doing. I'll always argue that, and think it's amazing.

That said, I never learned SQL well. I was handcrafting SQL queries with NO CLUE what I was doing in the few weeks I was doing PHP (I guess) and then ActiveRecord has had my back ever since. I've done complicated things with the help of gobs of StackOverflow and complex ActiveRecord and always kind of felt guilty about not knowing how my database worked.

What do I even build?

I've spent a lot of my career writing views over MySQL queries, and trying to "optimize" them with more and more complicated ActiveRecord but it's always been pain. Want to scope a report by date? That will take three days to write some view widgets, tests, some controller code, tests, a new scope, pull review it, merge, and deploy. Ouch.

But it's just the database! And I remember learning and poking around with PhpMyAdmin and thought that "there must be a better way than writing all this app code to do basically that". That solution is just not "production-ready", though, maybe? In the Rails world?

But one time a friend was showing me how his software company worked (he was a business-y founder who had outsourced all the software writing to a third-world country and the company eventually failed, go figure), it was basically exploring the database through something like PhpMyAdmin. I was intrigued (and a bit jealous) of how easily he, from the business side, was able to view and manipulate his data and generate reports. But didn't really think much more of it. I was a real developer. I build a lot of reports. I spend weeks trying to make them consistent and "optimized". And it hurts.

What am I going to build?

As I try to simplify more and more complex systems, I keep finding my ORM's getting in the way. 90% of the DB interactions in my app need about 1% of the power of SQL. My ORM's are great for that. Doing something more complex, though, always makes the abstraction leak all over the place. Want to search for a record by date greater than something? You're probably going to write that as regular SQL. Some ORM's offer more and more query "algebra" and that's... Something, but I kept finding myself thinking that it is weird to write code that gets translated to human language for the database to ingest and turn back into code. Can't we just skip that first code -> human language step?

Enter Mode

I heard about Mode Analytics on a Ruby Rogues podcast and was interested to try it. It's awesome. The thing that was surprising to me was how amazingly ignorant I was about SQL. But I've been going for it. When I get asked a question about how people are using our site, I'll reach for Mode because it's easy to use, it's easy to share my results, and I can iteratively build these reports to answer the questions more and more accurately. I can do it with the super-fast feedback loop that you would want while developing code, (I'm not building UI's, writing tests, or doing code review once I finish a little tweak).

After a couple months now (with most of my use being centered around end-of-month billing cycles), I'm getting confident in my SQL skills. I can write subqueries. I understand the differences between joins and unions. I am not afraid of my database anymore.

Web application development is an incredibly complex task that you need to know a LOT of technology to do well (from configuration management to CSS and spanning at least a hundred sub-skills). But we can learn one at a time. I am using these newfound powers to write better code. I can design better code because I don't NEED my ORM to talk to my database for me. I can drop lots of unnecessary complexity. I can get better performance. I can save time.

It's amazing.

Categories: Ruby on Rails Software