learning and "singing" Ruby with Sinatra
Hello I'm trying to improve my ruby knowledge by reading The Ruby Programming Language book. Reading Coders at work I saw that lot of the interviewees suggest to dive into a project source code
- to learn best practices
- to be aware of bad habits
- and of course to take new inspirations for how to do things.
I decided开发者_如何学运维 to pick a project as more self contained as I could find. My choice was Sinatra since It's 1000 LOC.
Is It a good project to learn? Do you suggest another one more simple (i.e. less LOCs)?
I've tried to see rails machinery before but I came out scared from It.
I'm not that much into Ruby (although I've played a little bit with Sinatra), but I want to say that the Coders at Work advice should rather be read as "read source code not only from one project, but from many". We learn best by comparison. That's also how we're able to spot patterns and abstract them away.
So maybe you can choose some topic from Sinatra, see how it is implemented, then compare it with the way it's done in Rails.
The more sources you consider the better you understand a particular subject.
Reading the Sinatra code is a good start. You might also want to read up on Rack, the HTTP interface Sinatra uses. Not necessarily for coding practices but just to understand how Sinatra fits in the whole stack.
Adding to Ionuț's answer, Rails also uses Rack, so if you decide to look at both Sinatra and Rails, you can compare how they use Rack.
Try typing in gem list
to list all the gems you've installed. Pick one that's relevant to your domain.
精彩评论