Rails webapp bundle (idea)

Having created many web application in Ruby, I always feel pain in my ass when I have to deploy a new release. Usually I have problems with the environment, last time for instance I had to reconfigure my appication to use postgresql instead of sqlite just to work on heroku. I’m paranoid and I want to be sure the deployed application works perfectly. I use TDD, write so many unit and functional tests under developing which pass on my computer, but it doesn’t mean my software works on the production environment too. The hosting services provide me only a black box, just for example heroku where the deploying process installs and configures everything after pushing to the master branch and I just hope it will work by end of deployment.

I was thinking on a unique solution for releasing web applications. My goal is a web application would run like a simple application, just start with a client tool and it runs everything it needs. I describe my idea and give you a little proof of concept to show it works!

Continue reading »

Ruby passes parameters by value

I was convinced Ruby passes parameters by reference when you call a method. I knew there are some special cases (bool, symbols, fixnums, floats) when uses pass-by-value, but usually for objects by-reference is the default. Today I had a conversation on Stackoverflow about the topic and now I know the most object oriented languages (like C#, Java, Smalltalk) use pass-by-value, or more precisely pass-by-value-of-pointer.

In Ruby the variables are stored by uintptr_t VALUE. VALUE can have special flags to determine it’s type. Special flags are small integer, symbol, true, false, nil, Qundef. When no special flag is set, it stores a reference to an object. When you pass a parameter to a method, it passes the VALUE by-value, so the reference to the object will be copied. Consider this behaviour it can be pass-by-reference, but it’s not.

Continue reading »

Using Sublime like Vim

As my friends know me, I like playing with new environments, new tools to make my work easier and faster. I learnt dvorak to type fast, changed to Macintosh to have less problem with my environment and tried many editors to make programming faster. Currently I use Textmate and Sublime Editor at home and Eclipse at the company, but I miss splited window and command run from Textmate and I don’t want to use 500mb memory in Eclipse just to edit some files in a project. I really like Sublime editor, however sometimes I need quicker shortcuts for commands, like remove more lines, searching for words under the cursor, so on…

This weekend I decided to learn Vim again, as I did so many times before. Vim is a really powerful editor for programmers and for whom doesn’t like to use mouse during writing code. My goal was to forget the mouse in programming and make my work faster, as fast as the thoughts pop up in my head.

Continue reading »

Spec directory in Rails

Are you curious about what the spec directory contains in your Rails project? I’d like to write briefly about these directories.

RSpec generates /spec directory with many subdirectories when you call rails generate rspec:install in your rails application. You can extend it with special ones, but the defaults are the following:

Continue reading »

Simplecov – Measure coverage in Rails

Today I spent some hours to discover how to measure Rails application’s test coverage, found Rcov and Simplecov gems. Rcov is not supported in Rails 3.2, while Simplecov is not supported using Ruby Enterprise Edition, so after burning some neurons I’ve upgraded ruby to 1.9.3 to use Simplecov rather. It is simple, but I spended many hours to configure it, so I would share with you some issues:

Continue reading »

Clean code – How to clean an obfuscated code?

One of my good friend, Athos wrote a very good article about cleaning an obfuscated code. Many developers don’t take much emphasis on quality of his code, because they believe in over-optimized solutions and they think the code style doesn’t add more value to the software. But the problem is not the software code becomes unreadable, either you won’t be able the change the logic later. Don’t take much time on code optimization in the beginning, check this out to know why:


Test Driven Development – Meetup Presentation

On Veszpremi Technology Meetup I presented my experiences of test driven development. Test driven development nowdays is getting more used technique to occur problems in long-running projects. Now I want to write more about this technique and describe why and for whom it is so good. (on the right picture you can see Mixer on the Veszpremi Technology Meetup, I have no snap about me)

Continue reading »

Meetup in Veszprem

The Meetup project has stepped to its final phase. We have place for the presentations, I talked to the owner of the Gesztenyes pub to she accept coupons for beers, created twitter and facebook accounts. Now I want to show you the poster of the event:

I hope you like it!

Header files

On Friday we had a short debate in the room with the guys about the role of header and cpp files. I didn’t support to separate unit tests to header and implementation part, because I guess in this case it’s not necessary. Why?

Data types (i.e. classes) have abstract and concrete aspects. We store the abstract aspects in header files (using c++ this is the .h file) and the concrete aspects in implementation files (cpp file). In the header we define the data type’s signature, export interface (public part of a class), parameters, methods, properties. Using C this kind of approach is shown better because header files can be separate from the implementation well, while in C++ sometimes you must store implementation specific properties in the header (usually in the private space).

The more information we define in the header file in connection with the implementation, the harder to change the implementation later without changing the header file. It can be a problem in a complex and huge software, where changing something in a deeper layer can result more hours compilation time.

Continue reading »

The new server – part 2

As I’ve mentioned my server provides Ruby On Rails service for companies also, so I’d like to write in short about Rails hosting. Rails is a framework written in Ruby. There’s a ruby application repository called rubygems like apt-get. So when you want to upgrade your Rails, as in apt-get, you can do it by the gem management application. The current rails version is over the 2.0 release and rubygems is over the 1.3. When we were working on the sites (those are being hosted currently), we used Rails 1.2.3 and rubygems 0.7. Today these versions are unsupported, and the upgrade is not so trivial.

Continue reading »