3 ms·
I've noticed the problem in my own coding that the first paragraph outlines. Having to manually discover the most useful libraries, maintain the code gluing eac
by vinceguidry 12y ago
I've noticed the problem in my own coding that the first paragraph outlines. Having to manually discover the most useful libraries, maintain the code gluing each of these libraries to the rest of the code.
It's a pain in the neck, doing it once or twice is fine, but once you start getting to around half a dozen projects or so in various states of development / production, going back to change the code on all of them when something changes gets pretty onerous.
I've started to recognize that I basically need to either be willing to either vendor dependencies or build interface classes to separate responsibilities.
So now I maintain an 'extractions' gem that implements common patterns as modules. For example right now I'm building a Persistence module that I can include to persist data. Point it at the instance variable containing the data, stored as a Set of value class instances, tell it which engine to use, and the name of the value class it's persisting, so it knows which columns to make in the table, and it handles all the dirty work automatically, presenting a clean interface to the calling library.
So now I can change or update the persistence library used in the extractions gem, say, by changing ActiveRecord to Sequel or even just separate DB libraries and templated queries, and all of my projects can use the new code with a simple 'bundle update'. Shared conventions, made easier by other extractions, make everything work together fluidly.
Eventually I'd love to get to the point where I don't even have to 'bundle update', running production code could poll the git server daily to see if the extractions gem has changed, then pull the repo and restart the server, the code for which can be stored, again, within the extractions gem.
This could get a little dangerous, so I'm eventually going to build a testing apparatus to test the effects of updating the extractions gem. Spin up a bunch of VMs, provision them, pull the repos, run the test suites and finally start the servers. Any errors get reported.