2014
Microservices for grumpy old men and women
Microservices? I’m not entirely sure what they are. The term seems to exist on all parts of the hype cycle simultaneously. It’s on the ascent of excitement, the descent of disillusionment, and the plateau of productivity for different people, simultaneously. Some folks know exactly what it means, others know entirely nothing about what it means. Weirdness ensues. People talk past each other.
It’s a mess. Grumpy old man mode is in full force. (FWIW, I am the grumpy old man in this metaphor. I can not speak to the stature of Fowler or Feathers at this time.)
If I’m pessimistic, I nod along with Michael Feathers. He’s on to something when he observes the use of microservices as a blunt weapon against failures of encapsulation. Microservices become SOLID principles using units of deployment and even teams as a barrier between concerns. I feel that’s rather draconian.
If I’m optimistic, I cite Martin Fowler. To his credit, Fowler is doing the best work sifting through the noise and sensibly organizing what microservices might, in fact, be about. They’re probably not distributed objects, if you do it right. But you should understand the details, lest you get swallowed by the novelty and forget to realize the benefits. Make sure you’re tall enough for the ride your operations team is about to endure.
I get the feeling that radical approaches to working with Rails and microservices are tilting at the same windmill. You won’t fix the human tendency to build complicated structures with more software. Employing more buckets, or smaller buckets, in which to put your software doesn’t solve it either. You need a human factor to jump in and say “Hey, this is complicated! It might even be essentially complex. Let’s manage that complexity.” If you’re actively managing complexity, microservices or monoliths, Rails way or your own way, microservices and decoupling are a lot more of a detail than a foundational principle.
Jerry Jones: slightly human, mostly Faustian
The best thing you will read about Jerry Jones this year. Slightly humanizing, even. What Jerry Jones wants, he cannot have:
I’ve never wanted anything as much as I want to win the next Super Bowl.
The owner of the Dallas Cowboys is his own worst enemy. His general manager, Jerry Jones, is able to make decisions good enough to prevent the team from sinking too far. He is not, however, able to make the decisions needed to return the team to legitimate contender status.
If you somehow made it this far without knowing much about football, let me clarify. Jerry Jones is Jerry Jones. Owner and general manager. Everyone who has watched football for more than a few years knows that Jones’ ego is what prevents him from separating the wildly successful owner Jones from the wildly sub-par manager Jones. And yet: it never happens.
That said, it does sound like somewhat Faustian fun to hang out with Jones, as the ESPN reporter who wrote this piece did. On the one hand, it’s obvious that a billionaire is using his considerable resources to come off as a reasonable, alright dude. On the other hand, he stands on the side of not renaming the Washington football team, so you know that Jones is subtly awful in ways he can’t even begin to wrap his brain around.
Thought + Quality
Oliver Reichenstein, Putting Thought Into Things:
Quality — as in “fitness for purpose” — lives in the structure of a product. A lack of quality is a lack of structure, and a lack of structure is, ultimately, a lack of thought. One does not find a solid structure by following some simple method. We deepen the structure by deepening our thought on the product. Our role as designers is to put thought into things.
I've noticed I do the worst, as a developer, when I'm using tools and methodology to avoid thinking. Not entirely sure how to solve this problem, write some tests and commit whatever makes them green. Troubleshoot by tinkering with commenting code out, trying different incantations, pasting snippets found on the internet.
Each advance in how I build software is lead by finding some way I defer or avoid thinking and correcting that shortcoming. In doing so, I find myself a little more opinionated, a little more specific about what really matters in making software and what is dressing.
Put more thought into what I build. Always think about what constitutes The Quality for the kind of software I want to build. Seek to avoid the tech vogue in search of deeper quality and thought. I’m far from mastering any of these disciplines, but the results so far are promising.
When Developers Design
I see lots of “should designers code?” articles and introductions to coding for designers. I see far less interest in the converse. So what’s a designer think? Cap Watkins, a designer; Should Engineers Design?:
If you think design is 100% about creating “design artifacts”, I’d say your scope is too narrow and has the potential to stunt your personal and professional growth.
There’s so much to designing that isn’t about choosing colors, fonts, producing icons, or drawing. Developers can, and should, get involved in how the applications works, how copy guides the user through workflows, when to prompt about invalid data and when to fix it automatically, and how to help users through interactions. That’s design!
To wit:
Throughout my entire career I’ve had engineering partners deep in the design process with me. I show them sketches, bounce ideas off of them, have whiteboarding sessions to figure out what we’re going to do. I trust engineers I work with to let me know when something seems confusing, when there’s an edge case I haven’t thought of and to push on my ideas to find where they break and help me make them even better.
Developers often don’t even realize they’re designing when they’re building libraries and tools for other developers. Writing a good README so developers know why your project is awesome and how to use it? That’s design. Sweating the details of an OO or REST API? That’s design. Opting to remove a feature or solve two problems with one feature? That’s design!
The design was in us the whole time, and we didn’t even know it!
I leave you with this excellent wisdom:
When you look at design as a process and not an artifact, everyone on your team becomes a designer. We have different areas of expertise and skill, no doubt, but the product experience belongs to every member of the team. The more familiar you are with each other’s responsibilities, the more you’re able to participate with and help each other out when needed.
Here’s a fun thing I do that you should try: when you read articles about design, squint a little bit and pretend it’s about designing programs. You might find something you want to try the next time you sit down to work on some code.
How Rails fits into the front-end
Is Rails well positioned for where the web (on all devices) is going? Pal Dave Copeland asked that on Twitter. Turns out I had plenty of opinions!
- I buy into the notion that the majority of applications don’t need much special in the way of browser-side functionality. SJR, a little bit of CoffeeScript, and SCSS will do you fine.
- For the rare team building ambitious applications, an opinionated framework like Rails is probably the last thing you want. Ambitious applications, perhaps by definition, are going to cut against the grain in one or more places. An opinionated framework is only going to get in the way of the opinions that make the application ambitious in the first place.
- The web is in a weird place. I think it’s a somewhat risky environment to build for browsers right now. The combinatorial explosion of devices and browsers means that you’re almost certainly giving some non-trivial class of user a suboptimal or buggy experience. Choosing where to spend your effort seems like a non-fun process.
- There isn’t a high-quality, well supported, well conceived ecosystem that currently exists for browsers. Rails and iOS both succeeded with a combination of smart conception, (mostly) excellent execution, and supportive communities or vendors. Front-end technologies are deeply splintered right now.
- I suspect there’s no opportunity for Rails to crown a winner in this space until the Cambrian explosion of JavaScript and CSS practice coalesce into something coherent that most developers can relate to and execute.
- But, if I had to wager, my money is on Rails choosing Ember as a default choice. This would happen on the trailing edge of fashion though, in the same way that jQuery didn’t become the default for Rails until long after jQuery became the go-to choice for most front-end developers.
- Even if the Rails core team could pick a winner on the leading edge of fashion, I don’t think it would work out. The Rails core team has much less experience with the front-end than the back-end. Historically, the choices have been OK (CoffeeScript turned out well, Prototype+Scriptaculous was an excellent early choice) with a recent trend towards provoking wild disagreement (e.g. CoffeeScript and Turbolinks).
- I think a lot of this comes down to Sprockets’ ability to gracefully grow to support front-end practice. It already does a pretty good job. Adding better support for browser components (e.g. Bower) would be good, as well as keeping up with SVG, web fonts and other somewhat special asset types.
If, tomorrow, I did have to build a Rails app whose web experience was crucial, I’d be as conservative as possible with my library choices. I’d stick with the oldest, boring-est, best-tested JS and CSS tools until it wasn’t feasible anymore.
A Ruby hash, Luxury Touring Edition
map.rb, quality software by Ara T. Howard:
the awesome ruby container you've always wanted: a string/symbol indifferent ordered hash that works in all rubies
m = Map.new
m[:a] = 0 m[:b] = 1 m[:c] = 2
p m.keys #=> [‘a’,‘b’,‘c’] ### always ordered! p m.values #=> [0,1,2] ### always ordered!
m = Map(:foo => {:bar => 42}) s = m.struct # maps can give back clever little struct objects p s.foo.bar #=> 42
I like little tactical improvements to the Ruby standard library that give it a slightly more modern feel.
It's Always Been This Way...Huh?
I’ve been programming, as a full-time job, for more than ten years. I started doing Ruby, and Rails, nearly ten years ago. I’ve been at LivingSocial for a two and a half years now. If you add these numbers up you will find that I am, improbably, an old hand.
As I try to explain and contextualize our organization, technology, and culture inside LivingSocial, I often catch myself delicately dancing around saying “it’s always been this way”. It sucks to hear this. It’s easy for this to sound like a deflection. “Don’t worry yourself, just accept it and let me get back to whatever I was doing before you asked that foolish question.” Crawl back to your desk and grind away.
Beginner’s mind is crucial and fleeting, so every person new to our communities and teams are invaluable. I want to extract as much information about how we’re confusing or mired in our legacy of stupidity. A beginner’s mind can help us improve our organizations, but only when it’s open and the experts aren’t marked as institutional damage to route around instead of engage with.
So I’m explaining organizational history and I find myself hand waving around “it’s always been this way, bask in despair!” At this point I (try to) profusely apologize and restart my explanation or answer. I need to get at that beginner’s mind before it becomes jaded in foregone conclusions.
But sometimes I don’t stop. I forget. I get wrapped up in accurately and concisely explaining how it got this way and why it’s this way. I forget to actually answer the question or suggest how it might be made better.
Allow me apologize to everyone out there on the internet. Sometimes it might seem like I’m saying “it’s always been this way”, but really I got so wrapped up in giving a vigorous history lesson that I lost my train of thought. It might help to restate the question. I’m an old hand, after all, with a frail brain.
Microsoft's Orleans, a good ideas
I came up in the days when Microsoft and Linux were mortal enemies. Back when “Borg Bill Gates” was the icon for stories about MS on Slashdot. Back when Slashdot was the cutting edge.
Thus, I’m always slightly surprised when I come across some really solid work done by Microsoft. The people at Microsoft are capable of really great work, but it often doesn’t escape The System in place between the hands on keyboards and the public face of the company.
Microsoft Research, in particular, produces surprisingly good research papers. The recent paper on Orleans is a great example.
Orleans is an opinionated “virutalized” actor framework MS developed that runs on their .NET and Azure frameworks:
- The design is single-threaded, small timemeslices, no preemption; not unlike Go’s goroutines (when considered on only one host)
- Orleans has its own runtime for activating, deactivating, locating, and dispatching to actors
- Semantics end up looking like a combination of queue-workers, actors, and Promise-based systems
Implementing Orleans instead of a three-tier (web, app, DB) system allowed them to eliminate the need for a caching layer once they reached scale. Actors encapsulate state and caching thereof instead.
- Virtualized actors become analogous to virtual memory, raising the level of abstraction programmers can work at
- Virtualized actors don’t require management by operators or developers; failure and load-balancing behavior is managed by the runtime instead of prior specification
- Currently implements at-least-once message semantics, which works for developers; considering added only-once message delivery
Orleans is currently in use in the Halo 4 presence and statistics services. I bet you’ll see clones and shallow carbon copies of these ideas in a language or conference near you. Read the paper, it’s quite accessible as distributed systems papers go. There are some nice ideas in there.
Ed. Let me know if you like reading notes on papers I’ve read. I’d like to do it more often if folks find it useful.
Unpacking RailsConf 2014
RailsConf 2014 having wrapped up a few weeks ago, now seems like a good time to try and unpack what I saw, heard, and talked to others about. Bear in mind I skipped RailsConf 2013 (but I’ve been to all the others), so I may construe something as new that I simply missed last year.
I’m going to break it down, as is my puzzle-solving wont, by technology and people.
Technology
Lots of people are excited about a few central topics.
JavaScript. They want to build ambitious apps, with Ember, Lineman, and other tools. Developers seem somewhat concerned that building apps this way is swimming upstream. Or that it’s early days and things are changing quickly. Or they think it’s awesome to work in a growing field. It’s all of those things.
Service-oriented Architecture. I went to talks about extracting services, designing services, implementing authentication/authorization across services, and how to write the client side of your various services. The talks felt like they were past the “look at this novel thing!” phase and into the “well here’s the nitty gritty” phase. I didn’t happen upon any sessions of the “here’s how this thing punched me in the face!” sort, which is the kind of thing I, personally, want to learn about right now.
Getting outside of Rails. Beyond SOA, some folks are going off the golden path and finding some success. I attended one good talk on adopting ideas from Domain Driven Design and hexagonal architecture. I found Ernie Miller’s ideas about how he’s worked with Rails' flaws interesting, even though I often didn’t agree.
People
The conference started with David’s keynote throwing barbs at the attitude some people display towards TDD (an ambiguous acryonym to start with). Many speakers opened with, in my opinion vapid, jokes about this. Other people seemed to take personal offense that TDD might not be everything. These reactions were, I found, not particularly interesting. The more interesting ones were those who found it as a challenge to consider how they build applications, either through taste and intuition or through reasoning and engineering.
There’s always, at least in conversations I find myself in, some question of where Rails is now. Relative to other technologies, is it a leader, a follower, a player, a has-been? Every year, it’s more of a safe assumption that Rails is a given, that it’s not going to up and disappear. Still, there’s a desire to keep it fresh, avoid stagnation, and above all avoid becoming the demons (J2EE, .NET, PHP, etc.) that people used before Rails. A lot of this discussion seems to be happening around the size and frameworkness of Rails. There has always been pockets of interest around things that are smaller than Rails (like Sinatra, ROM, etc.) More interesting, there is some defense of largeness now, especially in the context of Ember. This is the most interesting, and at times tedious, debate, for me personally.
The attendance of RailsConf continues to grow more diverse. The inclusiveness efforts of the organizers and community at large seem to be bearing fruit. I saw more ladies and more minorities than I have at any conference of this size. Further, the crowd felt less startup-centric than years past. Plenty of folks from startups, sure, but also people at different kinds of businesses: small, big, hardware, software, commerce, marketing, non-profit, etc. What’s more, it was easier than ever to find myself in a conversation with people not entirely like myself. That’s a quite good thing.
Lots of people are concerned about Rails, its community, and such. There’s a vibe, not unlike 2008 or 2009 when some were seeking other ways to build Ruby web apps, that perhaps the framework, the community, and the leaders thereof don’t have all the answers. That may sound damning, but it’s a pretty healthy attitude. The problems developers face and the way we build our programs are, as ever, changing as we’re building them. The tension is out there, but having been through most of a technology hype cycle with Rails, I’m not worried that the community won’t find the resolution of that tension.
A chunk of paper
So I’m in rehearsals for a comedic musical. I love comedy. I’m very “meh” about musicals; I don’t know much about them. I like combining familiar and strange things, so it’s great so far.
I carry a big chunk of paper around what has the lines written on it. Some of the pages are typed, some of them are photocopies of the script from the original production in 1995. It’s held together with brads. It’s completely archaic.
The director is kind of a “most interesting man in the world” kind of character. Mixed in with a little bit of the least organized person in the world.
We have yet to receive the actual music for this musical. We learned the closing song for act one last night. The whole song has fewer than ten words in it.
Basically, this is the opposite of all the computer things I do and it’s just about perfect.
About version numbers
Conjecture: thinking about releasing software versions to users/partners/the public in dotted version numbers, e.g. “1.0, 2.1, 5.3” is a symptom of misshaped thinking. This line of thinking seems framed by the notion that only a dozen major versions will ever be released. Certainly, some software works that way: shrink-wrap software, video game consoles, etc.. Most notably, dotted release versions are very useful for software used to build software.
However, its increasingly true that software doesn’t really work until it reaches “version” two-hundred something. But maybe that’s another problematic frame of thinking…
English-like programming languages, like, yuck
Glenn Vanderburg on teaching developer how to use Ruby testing APIs:
For example: I hate it when APIs (or languages, or whatever) are presented as "it's just English!" That doesn't give anyone anything useful to work with; it's just trying to allay fears, and it replaces a mythical danger (the thing people are afraid of simply because it's unknown) with a real danger: you're telling them they don't need to learn anything, when in fact the opposite is true.
I’ve never liked English-like APIs either. Consider that AppleScript is, bizarrely, completely unusable by people who know how to program in any other programming language.
If you think unpack “It’s just English” a bit, it’s easy to see why you should run away screaming from anything describing itself as being English-like in a good way. English is a human language riddled with inconsistencies. Many, if not most, English speakers learned it when they were young and the brain is almost useless for anything that isn’t language acquisition. Those who have learned English later in life become literate through lots of work, a healthy dose of necessity, and probably several years where their English was good enough for humans to understand but utterly confusing to a computer.
Just say “false” to “It’s just English”, coders!
Pancake publishing
I’m currently jazzed by the idea of full stack writing:
Hi is what we call a “full stack” writing and publishing platform. Just what is a writing stack? Capture. Write. Publish. is our summary of it, but really it breaks down into five parts:Some platforms provide tools for parts of the stack. Hi gives you tools for the full stack.
- Sudden inspiration!
- Capture
- Draft
- Publish
- Converse
All the pancakes.
Love the breakfast food metaphor! Hi’s tools and community integration seem pretty nifty. That said, the break down of inspire, capture, write, converse is what I can’t get out of my head. I don’t think you need special tools to approach it with that breakdown. WordPress, Jekyll, Medium, whatever. Always be writing, publish small ideas frequently (a thing I need to do more often!), develop the ideas that stick in your head or that lead to great conversations, repeat. Don’t let the layout of your blog template or the name of the tool limit your writing. It’s an easy mental trap to fall for!
Find your principles for editing programs
Some folks from GitHub sprung the Atom text editor on the internet yesterday. Releasing a product into a market defined by saturation, settling for brokenness, and zero-cost alternatives is a bold move. I applaud them for jumping into it. I’m eager to see where they end up, both product-wise and technically.
If you’re wondering whether Atom is the right thing for you, it might help you to know I went through a sort of quest several years ago to decide what was vital to me when editing text:
- Those Who Think With Their Fingers
- A Brief Survey of the History of Editing Programs
- The Cadence and Flow of Editing Programs
- A Personal Journey in Editing Programs
- Breaking My Habits For Editing Programs
Writing these, thinking deeply about the kinds of problems I did and did not want to solve with my text editor and what that meant for my workflow, was exciting. I learned a lot about finding my own principles.
I ended up, to my great surprise, choosing Vim. Most importantly, that decision stuck. I haven’t gazed upon the possibly greener grasses of other text editors since I committed to my principles and workflow. Whether it turns out Atom is your thing or not, thinking about the principles of how you want to work with computer programs is a thing you might benefit from.
Counterpoint: Rails and instance variables
A great thing about writing is that it focuses and sharpens one’s thoughts. The great thing about writing in public is that your thoughts, when passed through the brains of others, sometimes yield even better thoughts. The greatest thing about writing is when you hit publish feeling confident about your position and end up with your opinion flipped once the conversation is over.
So it went with A tale of two Rails view that a few hours after I’d published it, my mind was changed.
On the one hand, you can take a permissive stance on views and ivars. Dave Copeland nicely laid this idea out. If you are responsible about minimizing sharing ivars between actions and views, you have a chance. In this case, that means sharing one or two ivars, no more. Placing a little trust in your fellow developers lets you put off the day when you need to isolate state behind helper methods or other restrictive abstractions.
On the other hand, you can take a contractual stance on views and require all data passing between actions and view to do so through a specific object. Tony Pitale’s SimplestView does just this. It unifies views and partials into one name, “templates”, and then provides backing objects (somewhat confusingly called views). Actions create the backing objects and templates consume them. Nothing can leak through, no hunting down the origin of an ivar needed in this template but not yet defined in that one.
Somewhere in the middle are ideas about building a bridge between the action and the view. One could use responds_with
as said bridge, but, for me, that felt like it played better with APIs than traditional views[1]. A possible middle ground is to use something like decent_exposure, or this interesting spin on it by Nathan Ladd. I like that Nathan’s approach is basically sugar over the pattern of encapsulating action state behind controller helper methods which are shared between views. I’ve been using the helper method approach so far, but it’s a little awkward to test and confusing for those used to sharing ivars.
If you’re sick of the baby and the bath water, you might find a more extreme approach interesting. Focused Controller and poniard do away with Rails conventions entirely. You still write controllers, but how you load data and model actions is entirely different. Personally, these are interesting sources of ideas. I’m not sure I’d jump on them for a production application.
Of all these approaches, I’m most intrigued by SimplestView. It seems like the Minimum Viable Departure from Rails conventions that could possibly solve the problem of sharing state and defining a contract on that state. That said, I’m likely to try Dave Copeland’s approach first. I like that it’s about talking with teammates, reviewing each other’s work, and making smart decisions. I’m finding that no amount of framework is as good at helping people write good code as review, feedback, and iteration.
- I know it works with normal views, but I didn’t like that it nudged me down the path of using conditionals. YMMV. ↩
A tale of two Rails views
Why do I prefer to avoid referencing instance variables in view?
I needed to clarify this personal principle to a teammate recently. It was one of those things I’ve internalized so strongly that it was initially difficult for me to do so; one of those things that have become so true to me that teaching someone else about it requires getting past the “well, obviously it’s the best, that’s why” phase of mental tantrum.
An entirely made-up, possibly oversimplified Rails view fragment:
<p>Hi, my name is <%= @user.name %></p>
This is a by-the-book Rails view. Set an ivar in an action, use it in views (and helpers), you’re done, get back to thinking about building product.
It’s easy to iterate with this. It’s easy to see data “passed”1 into the view by scanning for the @
sigil; your editor probably does this already. It’s easy to move markup around in templates with a simple cut-paste.
If you stick with ivars long enough, you’re going to end up with two kinds of misadventures.
Most commonly, you’ll wonder why @user
is nil for some view or edge case. Maybe you forgot a filter or didn’t set it in an action? Backend developers are sometimes equipped with the curiosity and knowledge to fix this themselves. For front-end developers or those new to the system, this kind of error is basically “womp-womp sad music go interrupt someone who can help you”.
This leads to the second misadventure: where did this @user
thing come from2? Maybe it was set in a helper, or a filter, or an action? Well now you’ve painted yourself into a weak spot of a language like Ruby. Your tools probably can’t point you directly at the line of code where a variable came into being. You can do some clever grep’ing around3, probably. At best, you know the system well enough to get to the right file and find it, or there’s some convention you can use to intuit where it might be set.
Of course this way is better, right?
<p>Hi, my name is <%= current_user.name %></p>
Well, not initially. Already you have to pick a good name for a method because you’re probably going to use it all over the place. Then you have to find a good place to put that method: on a helper method? on a helper object? on a model?, i.e. now you’re making decisions, which is a thing Rails tries to shield you from wherever possible. Personally, I find naming things quite entertaining and hardly one of the hardest problems in computer science4.
A marginal benefit comes from reducing the entry points that the name current_user
came to be a thing in this view: it’s a method name, a local variable, or a view-local variable passed into the template5. Thus the search space for “where did this thing come from” is way smaller for typical Rails templates and manageably smaller for unreasonable Rails templates.
This way pays off once the application gets past the point where new code tidily fits into models, views, controllers, or helpers. At that point, you need objects, messages, and experience at building with objects and messages (successes, stalemates, and abject failures)6. If you’re competent at messages (i.e. method calls) in Ruby, you can at this point experience a “this is Unix, I know this!"7 moment and work with this method call like you would any other method/function invocation in a computer program.
Making this investment into a method call yields another long-term benefit: simplicity in experimentation and testing8. I can poke at helper methods and helper objects in a Rails console without breaking a sweat. If that feedback loop doesn’t get the job done, I can write tests against helpers and (some) controller methods to iterate on figuring out why something doesn’t work the way I think it should.
It’s amazing that blogging about programming is so popular. Programming involves a lot of tradeoffs. Tradeoffs make for wordy articles that don’t leave you thinking “yeah, those other guys are SOOOO WRONG” or “YEAHHHH I’m so right”.
If I’ve written this properly, hopefully you felt both of those feelings. Maybe you reminisced about a day when you thought view ivars were great and then regretted it. Perhaps it’s easier to see why you’d start an app or feature off using ivars and then refactor them to method calls later.
With instance variables in views, as with many other grey areas of Rails, the most useful long view is this: you’re always right, and you’re always wrong, it just depends on which “you” (past you, present you, legacy project you, greenfield project you) is being observed.
- I'm not using "passed" as scare quotes here. Rails' choice to take ivars from actions and teleport them into views is oft villified, but I find it more useful to think of them as something that just is. They are incredibly useful at first, but some developers will long for an explicit contract (i.e. a parameter list) between action and view. ↩
- If you're an object design enthusiast, functional programming aficionado, or Rails contrarian you may be crafting an amazing retort about sharing state in weird ways at this point. Please review the previous footnote. Yes, you're basically right. No, that's not going to change how Rails works. ↩
- Regexes, two problems, etc. ↩
- Actual hard problems in computer science: systems connected by unreliable (i.e. any) network, laws and regulations written by humans, working with money. ↩
-
When it comes to variables in Rails templates, a short guide by Adam Keys; method names: friend, ivars: foe, local variables: foe, view-local variables (passed via
render
explicitly or by the framework): both! ↩ - This is the concise version of a seems-really-important-to-me idea I need to express in more words. Remind me to write this, should I forget about it, internet! ↩
- What up, Ariana Richards? ↩
- You knew the testing thing was coming, didn't you? I mean it's like Chekov said about guns in stories: if method calls are mentioned in the first act, you have to mention TDD in the last act. If you headdesk'd, consider that you might be annoyed by TDD because you keep giving yourself a head injury when it's mentioned. ↩
Rockets and startups
A venture-funded startup is sort of like a space program. Space programs don’t build airplanes that fly in flat, predictable, safe trajectories. They shouldn’t be concerned with doing something pedestrian. Space programs should be concerned with doing something very unusual, perhaps unnatural.
Like a space program, a funded startup is equal parts propaganda and collection of great minds. During the first few rounds of financing, a startup is completely unlike an actual business. It’s all growth: technical growth, metrics growth, mindshare growth, operational growth, staff growth. It’s about gathering smart, driven people and making something new without the confines of traditional market forces. It’s about showing that new thing off to the world, making everyone think that they either really need to have it or that they’re behind in the race to make something like it.
Startups, like space programs, take a bunch of volatile materials and apply them to make an impossible climb. Quite often, those materials explode on the pad or in the first couple minutes of flight. Sometimes all the systems work together, months of effort by teams coordinated by a few masterminds, and the startup or spaceship gets off the ground.
Even if the startup or spaceship survives it’s first minutes, most of it is discarded as it ascends. A Saturn V weighed millions of pounds on the launch pad; what returns to Earth weight thousands of pounds in the end. Systems are built, used, and discarded many times over. Depending on a startup’s exit, what remains is only one of many ideas or systems built over time, sometimes an idea expressed in the heads of a few key people.
Space programs are great. Startups are great. Keep in mind that they are wholly unlike more commonplace human endeavors and you’ll be fine.
Grow and cultivate
Adding new functionality to software is really exciting. I love poking around the edges of a system, figuring out what’s going on, and looking for that “obvious” place where the first change should happen. But sometimes, it’s hard to know if I’m making the right change. How Should This Work?
The temptation when changing an existing system is to implement the desired behavior within the structure of the current abstractions. Repeat this without adjustment, and you’ll quickly end up contorting existing concepts or working around legacy behaviors. Conditionals pile up, and shotgun surgery becomes standard operating procedure.
Even if you code test first, you can make a mess of a system. What you end up with is a system that moves from local maximum to local maximum while the time of the test suite grows unbounded. There are worse things that could happen, but no one’s going to jot this one down as a “best practice” either.
The counterforce to this temptation is the red-green-refactor cycle. Look at how the system works and figure out how the next bit of work might change how the system works. Refactor to simplify the act of making a change, or make the change and refactor afterwards to a better design.
Software can grow by accretion, but it stays malleable when the team culture is one that balances continuous growth with continuous cultivation of good design.