Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

July 9, 2012

Projects worth looking at

For a while I've been reading about the term Software Archeology from different media channels and I find it very valuable. Especially if you are trying to do something interesting with your projects, in those cases is a very good idea to checkout some very well written applications.



Rails
If you want to see what Ruby can do, this is the project I recommend. It has several gems in it, including a very complete documentation.

Guava
Google has released several open source projects with high quality code and lots of functionality, this set of libraries are great tools when dealing with real-life applications.

Guice
A great CDI component that simplifies Spring into fine grained components that are extremely extensible. I use it whenever I can and it's really, but really cool.

Fitnesse
This is perhaps the application with more test coverage I've ever seen, a serious attempt to reduce the gap between user acceptance tests and testers.

You might have noticed that most of them are written in Java, I didn't have time to check some other languages, but for sure Scala and Clojure are my next target.

References

June 23, 2012

Ruby disappointment

I have been trying to port some work I've done in Java to Ruby, to see how it looks and how much code it would take. But in the way I found out that Ruby might not be the best option for this kind of situations.

Let me explain it, this is my pseudo code:



As you can see, the OrderSet has a collection of Order classes, but classes!! Not instances, because in the real application I will have hundred of Orders and I don't want to instantiate a new object for each one of them.

So to keep the memory load very low I handle classes, in that way I can control them, instantiate them and destroy them as much as I want.

Now, I tried to write it in Ruby, but I found out that there's no easy way to add metadata at a class level!!
The closest approach to it that I could find is instance-oriented. I would need a new instance of every Order to make it work....sad.

April 3, 2012

Binary tree implementation on Ruby

I was having fun comparing the code I did in my early programming attempts in Java, and thought about how much would it take to rewrite it now, but in Ruby.



As an initial attempt, I took the widely known Binary tree, I started with the test cases and then implemented the code for them, here's the result.


I can say that it took at least ~50% less effort compared to the Java implementation, and it looks good :-)

January 31, 2012

Exercise: Sieve of Eratosthenes

After reading an interesting blog post from Robert Martin I started writing this nice algorithm in Ruby (I'm still learning it).

As I'm a refactoring freak, here's the first version:

Nasty right? Then the cleaned up release:

September 28, 2011

Migrate Oracle backup script to H2 (mode=ORACLE)

Some work I've been doing today.

September 14, 2011

Quick and dirty LOC counter written in Ruby

A few weeks ago I needed urgently to measure some projects I'm interested in, but I didn't have an internet connection to download the latest application that would do the work for me. So, I decided to write my own LOC counter.

I didn't want to write it in Java because of the time consuming for it, and as I am learning Ruby, I just gave it a try.

Result

A very short and dummy implementation that took me nearly 15 minutes, reading some API docs and testing, I don't know how to express it, but it feels right. If I would have done it in Java would work even better, but I like this approach, clean and short.