Posts authored by Jan Dudulski
Do you remember the beauty march in Wrocław last year? The amazing event happened and we’re proudly announcing that its sequel is coming in less than a month: the “fresh Ruby-oriented conference in Wrocław, Poland” will take place on March 1–3rd, 2013.
Just check the list of the speakers, and be sure that the last year was just a warm-up. New conventions, talks fully loaded with meat, and long run of before and after parties. A lot of important mind-changes that will result in hot discussions will strike again, with fresh additions and surprises.
Find, talk and grab a beer with us during the conference! If you’re reading this blog, then you definitely should.
It seems like it happened yesterday. I arrived at the flat in a crumbling tenement located in the Old Town of Wrocław and my journey into the Ruby world began. The community was already large and very active, so I wouldn’t call myself Columb, but—at least—I can tell you about my first year experience and share both bright and dark sides of the story.
I don’t like making New Year’s resolutions, therefore I haven’t been making them at all. But I realized that setting goals to achieve—especially when they are split into smaller pieces—is a good idea. Like in the agile methodology, you can extract what is important for you and move forward step by step to the next
epic year as a better person.
It’s time for New Year’s edition of our summary of the content found in couple of the last weeks. While you are getting back into ordinary flow you can read about Vim, objects in Rails and improve your hacker’s toolbox. Enjoy!
As you could notice I’m big fan of Vim and I promote it intensively among colleagues. Even if you think that it is not for newbies or you feel uncomfortable using it, you should be aware that you’re probably using an editor which is not designed for programmers. So, if you are interested in topic, just know that you can build an IDE around Vim, arm it in powerful search feature or configure for writing… prose.
At last but not least, if you’re still not convinced, check this amazing tip how Vim can save your time.
Object Oriented Rails
There are a lot of interesting ideas how to improve OO approach in Rails. Xavier Shay shared with his solution for form objects and completely redesigned idea of controllers. Chris Flipse shows how you can isolate validations from AR objects which plays well with the idea of form objects and splitting AR into Domain Objects and persistence layer.
DHH encourages us for more intensive usage of Concerns, which he compares to DCI idea. Actually, it’s not the same, so keep in mind Victor Savkin’s page about Ruby and DCI. If we are talking about DCI—there are some interesting voices in the discussion. Gregory Brown raised some common issues about this paradigm, and Rebo responsed with nice article about DCI’s ‘C’ part.
We are looking forward for another possible cure of AR-madness, which could be DataMapper 2. Solnic just wrote some notes about plans and roadmap of this well looking project. You also try some already available patterns to decompose fat AR models.
During last month we found some cool stuff and tips which could improve your hackers toolbox. Vidir is a vim-like tool for mass-edit of file names—open directory, edit names with power of Vim, save and quit and voilà! If you like functional programming you will probably add this simple map alias into your shell. For impatient devs we’ve got another tip, that would automatically reload your irb session.
That’s all for today. Thanks for reading and I wish you a Happy New Year!
When you know one or two languages like C or Java, learning another is a piece of cake. Browse documentation about syntax, get to know some basic quirks and that is everything you need to start writing much more complicated programs than hello world.
Problems start when you try to learn a fundamentally different language than the ones you already know. For example, if you work only with OO languages then switching to functional paradigm can be painful. If you know just the class-based object paradigm then picking-up prototype-based may be hard. Learning another solution is sometimes even harder than the first choice. This is because while you are learning your brain confine its perspective to a single path for specific problems. When you try to meet another path you struggle not only with new things but also with the things which you used to know – you have to beat the temptation to follow the easy way, the one you already know with all its traps, problems and strengths.
Finally, when you overcome such problems, you realize that you are better programmer, with broadened view, and even if you are still programming in the “old way” your code is much better.
Wasn’t it about Vim?
The same problem concerns your editor. Unless you are vim or emacs user, when you hear “editor” you think about textarea with a bunch of tools around. Like Visual Studio, Eclipse, RubyMine or Sublime. So, when you try to use Vim, you struggle not just with learning a new tool, but most of all with a new way of thinking. And that’s hard.
The Vim way of thinking
The key to understand vim is what we call a vim grok. When using it you are actually talking to your editor what to do. Use u for Undo, r for Replace, ctrl-r for Redo, c for Change, i for Insert, a for Append, d for Delete etc. But that is still not sexy. Use vit for Visualize In Tag. Or, with some help, use dar for Delete Around Ruby block. Isn’t that beautiful? To have a pleasure experience with Vim you have to speak the same language. Otherwise it’s like communicating with a foreign using an ad-hoc sign language.
Of course, not every vim command can be expressed in that way. For example, to yank into global, system register, you have to use “+y (or “+p to paste from it), which you cannot easily translate into human language. But you don’t have to understand everything from the first sight, right? There are others really powerful forces in Vim grok, like dot command, macros, regexes, registers… And I have not mentioned tons of plugins yet.
The final question, why?
Ask yourself if you can find anything new for you in your current editor, something that would improve your performance. I bet that is false if you are using it longer than couple of months. It was probably false after couple of weeks… if not days.
In vim it is always true – and I treat that as a biggest advantage of this editor. Vim has so many features and it could be extended in so many ways, that even after years you will still be exploring new things and asking yourself “why I didn’t know that earlier?” But do not be afraid – you can successfully run with Vim after much shorter time. Just give it a try and resist the urge to turn back to the easy path, the one you already know well.
Extend your view, improve your skills. You have nothing to loose, you can only gain.
A couple of months ago Bartosz described how we use Facebook to improve communication in our team. Actually most of the content on our wall are more or less interesting links from the internet. We quickly noticed a troubling pattern though—they are easy to forget. And if you forget them, you can’t use them.
So we decided that we’ll be regularly preparing a brief summary of the best content so it’s easy to find and convenient to browse. Our goal is not to provide The Hot News™—you can find them anywhere—but the top of the top stuff which we believe will remain valuable for a long time. So… let’s start!
Roy Tomeij, one of the speakers on the last wroc_love.rb conference, suggested that
classes should be replaced with
classes are for designers and
Improve your tests
How to (and why) test factories—short and easy, but very useful protip from Thoughtbot.
If yours tests take too long, check if you can replace doubles with OpenStruct. Xavier Shay did some benchmarks on the subject.
There is new shiny tool on the horizon, Testacular, and I think it can soon replace Selenium. It allows to run tests in multiple browsers with your favorite testing engine under the hood. Read more in DailyJS article.
If you don’t feel comfortable writing tests, there is a new site for you: betterspecs.org, the collection of bad examples turned to good. It’s open-sourced so you can always add a new example or fix another if you disagree with proposed solution.
DCI is a hot topic these days, but there is still lack of good examples, especially in Rails context. Victor Savkin fills this gap with an article Data Context Interaction: The Evolution of the Object Oriented Paradigm. If you like the solution proposed by Victor also check his gist collection and DCI-Sample repo.
Another interesting approach to DCI in Rails is shown on already mentioned Xavier Shay’s blog in article titled Dependecy Injection for Rails Controllers.
At last, an article about patterns themselves: The First Step to Applying Design Patterns: Don’t. Very good explanation why design patterns are awesome, when you should use them and when not.
See you next time!
From time to time you need to turn off your app to make some more complicated changes, fix the mess when something goes wrong etc. In short – you want to turn maintenance mode on. In this brief article I will show you the simplest solution for apps running on awesome nginx.
What do we need?
- An app with nice looking 503.html in public folder
- User with access to the server (we recommend to create one user per app)
- Nginx configured for serving your app
When Drew mentioned that he’s planning to write a book I already knew that I will buy it. Now, after almost two years, book is close to be released, but for impatient guys like me there is beta release available for some time.