Archive for September, 2005

RPG IV Training

I'm off to Cairo for some RGP training. Although, I'm not quite convinced with the language, but it is always nice to see how things perform. Besides… it's kind of a company training policy.

Rails Likes and Dislikes

This is my impressions about Rails after rolling out an Issue Tracking system in 1 week (I might put it on tamersalama.com for a taste of what can be accomplised in 1 week).

    Likes:

  • Ease of use.
  • Help developers focus on business aspects rather than configuration, integration issues.
  • Smooth learning curve.
  • AJAX wowing helpers and js libraries.
  • The power of being agile and getting things done, fast.
  • Simple APIs with powerful methods.
  • No need for an IDE (a text editor is enough), while in Java an IDE is an absolute must.
  • Convention: cars table is mapped by default to car model, placements in directory structure.
  • Everything under the same hood:
    • Persistence framework (ActiveRecords). In Java one have to learn Hibernate, Config, Mapping files and a new API.
    • Simple configuration is done via Ruby with no need for XML (one doesn't bother about XML and “Spring”ing files which is almost like learning a new language).
    • Templates use rails functions (No need to learn JSTL EL syntax or struts tags).
    • Helpers, similar to writing Tag libraries but with no need to extend BodyTagSupport, write tlds, and understand weird-named variables like EVAL_BODY_INCLUDE, etc….
    • ActionMailer is simple and powerful.
    Dislikes

  • Ease of “abuse”. Model 1 anyone?
  • Although touting the DRY principle, yet, validating DB stuff (like NOT NULL fields, uniqueness, etc..) is repeated in the model (I've read somewhere about an intention to leave such simple validation to the DB - but not sure how serious or how feasible). A note on this: it's really not too much work including “validate_presence_of” line in the model but, still, it's not DRY.
  • Tying the validation mechanism to the persistence layer (model) - what if there's a need for simple validation of other input (I've read also about other work arounds but haven't tried them).
  • List of reserved keywords (this is non sense: words like System, Task, Class, Transaction shouldn't be used as entities?!).
  • Docs (again), but “Agile Web Development with Rails” sounds like a good reference (haven't read yet).
  • No powerful tag libs like those for java (display tag, etc…)
  • Still haven't reached the tipping point (as of Mid September 2005)

I will be refining the lists as I continue my journey. At the end, I still like the power that Java provides and I consider Ruby on Rails to be a mind opener and another powerful tool. I intend to keep it in my belt.

Qooxdoo

Came across qooXdoo and I love it.
Hard to choose a favorite widget as they're all quite nice (Tree, Menu, Color Picker, Overlapping Window, Gallery, …).

It also seems that integrating them into apps is easy, so, I might give them a try sooner.

qooxdoo is an advanced open-source javascript based toolkit. qooxdoo continues where simple HTML is not enough anymore. This way qooxdoo can help you to get your rich web application interface done - easier than ever before.

Rails many-to-many associations

The tables:


developer (...)

functional_system (…)

developers_function_systems (developer_id, functional_system_id)

I used “functional_system” instead of simply “system”, because it was giving me errors as it is one of Rails

href="http://wiki.rubyonrails.com/nails/show/ReservedWords" target="_blank">reserved words - something I don't like about

Rails.

The models


class FunctionalSystem < ActiveRecord::Base

has_and_belongs_to_many :developers

end



class Developer < ActiveRecord::Base

has_and_belongs_to_many :functional_systems

end


The View (templates)

I included the checkboxes representing developers working on the same system:


...

<% Developer.find(:all).each do |developer| %>

<li><%= check_box_tag(”functional_system[developer_ids][]“, developer.id, @functional_system.developers.include?

(developer))%> <%= developer.name %></li>

<% end %>

..


The Controller


...

@functional_system = FunctionalSystem.new(params[:functional_system])



Rails has recognized the request parameters and magically filled out the @functional_system.developers collection.

A problem occurred when I wanted to include the join_date in the association information. That is the developers_functional_systems has an additional field of “join_date”. After trying out several scenarios - I finally came
across push_with_attributes.

Adding the following lines to the controller


@functional_system = FunctionalSystem.new(params[:functional_system])



#developers collection need to be cleared. Otherwise a “Duplicate Entry” error will be returned

@functional_system.developers.clear

params[:functional_system][:developer_ids].each do |dev_id|

@functional_system.developers.push_with_attributes(Developer.find(dev_id), {”join_date” => Date.today});

end

This performs what Rails has previously done automagically. It added a new developers_functional_systems's entry
(explicitly), with the additional association info of “join_date”.

As a more friendly approach, and to make use of Rails magic, It was better off adding the “join_date” in the view.

The naming convention is a bit tricky, after several trials, this have worked:


<ul>

<% Developer.find(:all).each do |developer| %>

<li><%= check_box_tag(”functional_system[developer_ids][]“, developer.id,

@functional_system.developers.include?(developer)) %><%= developer.name %></li>

<input type=”hidden” name=”developers[join_dates][]” value=”<%= Date.today %>”>

<% end %>

</ul>

I'm still not sure how the hash represented by name=”developers[join_dates][]” is recognized as belonging to the current
“functional_system”. Does anyone have a clue?

Freemarker / Spring / jBPM / Hibernate / MySQL

I'm on a new gig. Freemarker + Spring + JBoss jBPM + Hibernate + MySQL + ….

Sounds like a dangerous mix (nu-b in the first 4), but I'm up for the challenge. Wish me luck.

Any comments/suggestions? Anything on jBPM in particular? (seems fairly new, least mature, least documented among the mix).

I'll try to keep the blog up with the latest.

Freemarker / Spring / jBPM / Hibernate / MySQL

I'm on a new gig. Freemarker + Spring + JBoss jBPM + Hibernate + MySQL + ….

Sounds like a dangerous mix (nu-b in the first 4), but I'm up for the challenge. Wish me luck.

Any comments/suggestions? Anything on jBPM in particular? (seems fairly new, least mature, least documented among the mix).

I'll try to keep the blog up with the latest.

Recent Visitors

I added Recent Visitor Geographical Info to the list of sidebar links:

  • First registered for a free account with GVisit and added their script to the blog.
  • Got hold of GVisit RSS feed for recent-visitors' geographical locations (couldn't find the RSS link on their website today, seems to have been removed, but replacing the map.php with rss.php in the url solved the problem).
  • Used the Feed2JS by Alan Levine to generate the JS script.
  • Here it is: A List of Visitor Geographical Location with links to Google Maps hack….Nice.