« back

Cutting a Gem- Separation of the Delivery Mechanism

30 Aug 2012

Since I needed to untie my Ui from my Tic-Tac-Toe code,Uncle Bob's video on Architecture was the place Doug suggested I start.

After watching Uncle Bob's video, I could see that it was important to have my application code separate from my delivery mechanism. This made sense. I was happy with the new architecture.

I figured I would just turn my code into a gem, ignore the console bits, add on a web interface, and call it a day. As I was creating my gem, I was struggling to figure out how the console bit bit fit in if I was not going to be using it in my code but I thought that was the way the gem was supposed to be. It was causing me problems. I was having a hard time.

After trying several things, I was happy to have some time to chat with Doug. He told me that the console code would not be included at all, but that I would require my gem in to my separate console app as well. I had a little a-hah moment.

After getting my gem built and proving that I could install and require it, I was having a problem accessing the code from the command line in irb. In the rubygems tutorial, one of the steps is that you prove that the gem works in irb by using some of the code in your irb session. This was not working for me so I added the example from the rubygems tutorial into my gem. I was able to prove that it was working. From that point, I was able to made an executive decision that irb prove was not necessarily proof that the gem could work.

I pushed the gem(You can get it here, or just gem install ang_ttt_gem :) ), required it into my console app, and it worked!!! It felt really great to see it all snap into place. I could see my app working. You can see it here and you can see the Ui, ready to be swapped out with another one, hanging off of the side of my application code just like an appendix.

comments powered by Disqus