Integrating Ruby Rails, PHP, MATLAB and The Google Docs API for KpozSports.
The Renaissance Programmer is productive in multiple programming languages and platforms. Like the Renaissance Architect, He understands what's important when building software; the symmetry and simplicity of the end product.
The initial challenge when first working for
KPozSports was that the existing site was written in
PHP . I've been working mostly with
Ruby and
Rails for the past few years. And
Jim on our team is a talented PHP developer.
So how can Ruby and PHP developers work together on the same site?1) Have a Clear Division of Responsibilities.On any project, each developer needs to work toward specific functional goals. The language or tools they use to meet these goals is ancillary. Although KPoz is a small company, we don't mind working with multiple languages to get our jobs done.
Rob is an expert with the
MATLAB programming language. All of our computationally intensive work is done in MATLAB. The PHP code is primarily there for the Web interface.
Jim's been building web sites for years, and it's his tool of choice. Adding some Ruby code to the project didn't bother anyone because they were more interested in the resulting functionality. My primarily responsibility was to gather data from several sources, organize it, and integrate the PHP site with the MATLAB background processes.
Ruby, known as
The Enterprise Glue, was a natural choice.
2) Group Similar Goals and Tasks together.Software developers call this
cohesion. KPoz gets it's game data from
Rake tasks I've written that do screen scrapes from public data sources on the web. When the task came along to screen scrape current point spread estimates for those same games, it was assigned to me. My mind had recently been absorbed in the problem, and I was able to reuse some existing code.
3) Keep Components Independent.We built a complete internal site in
Rails to manage data flow for KPoz. The site runs independent of the External PHP site, and the MATLAB components. Conversely, The PHP and MATLAB components don't require the existence of the other components. They barely know about each other. Software developers call this
Low Coupling. This makes it easy to work on and run a component without worrying about breaking the other components.
4) Design Together.Building a single usable software application requires constant design. Everyone at KPoz participates in the design process. We keep important concepts defined in an online
Domain Dictionary that continuously gets revised. This ensures that developers talking about the same concepts are using the same terms. Keeping a harmonious Domain Dictionary will ultimately resonate into the code, and out to the end user.
5) Don't Repeat Yourself!
The full DRY rule, from
The Pragmatic Programmer is
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When data is shared across databases, it needs to flow correctly, from the authoritative representation to the replica. In our system, the authoritative representation of our object model is the Rails database. Updates to that database automatically replicate throughout our system. This unambiguous flow of data keeps things from getting complicated. In addition to keeping our own code DRY, it's important to make sure that the system as a whole is DRY, particularly when integrating multiple sub systems.
6) Constant Communication.Developers working on disparate platforms from different physical locations need to proactively engage each other. At KPoz we have two weekly calls. At the beginning of the week we thoroughly discuss plans, strategy (or is it tactics?) , tasks, and issues. The end of the week call is a quick stand-up meeting. By having two weekly calls, even if someone is travelling or busy , we all speak at least once a week. We also frequently contact each other informally , for anything from discussing a fascinating programming problem, getting a remedial lesson in Statistics, or celebrating a favorite Football Teams victory.
7) Expand Your Mind.
In
Pragmatic Thinking and Learning,
Andy Hunt discusses the concept of
Neurogenesis . Contrary to popular belief, we continue to create brain cells throughout adulthood. By forcing ourselves to work on unfamiliar platforms at KPoz, we were opening our minds. When Rob wanted several
football statistics downloads available on the Web site, we wrote a rake task to load the relevant data into the
Google Spreadsheets API. An additional Rake task then updates a PHP page on the main sites with links to the new Spreadsheets. Since our system already contains multiple integrated platforms, adding another platform was simple. And notice how I say "we wrote". By including multiple development platforms on our site, we all learned more than we would have if it was a single platform solution.
At times while working on the site, I wondered if things would have been easier or more ideal if it was all written in Rails, or all PHP for that matter. However I've concluded that integrating multiple solutions is in many ways more ideal. This lead me to the concept of a Renaissance Programmer, a programmer that is versed in multiple platforms. I've also experienced yet another personal Programming Renaissance, in which I'm reminded that it's only the resulting product that matters.