Loading... Cancel

builder pattern with fluent interface just an example while i was doing by routine work :) R

January 26th, 2008

today while i was working with one of my projects, i was wondering how this came up with a bit more fluent with my credential object.
just i can’t resists myself to share this code with every one.

assertNotNull(mProfileManager.authenticate(
Credential.Builder
.aNew().userName(userName).password(password).build()));

rails plugin symlinked broken on 1.2.5, fixed from 2.0 R

November 29th, 2007

i was trying to build a rails plugin. my project was in different directory so i symlinked the directory under “vendor/plugins/..”. but i couldn’t find it working.

so after passing few times, i could successfully run my plugin under rails 2.0-RC2. so later i compared lookup.rb file from the 1.5 and 2.0-RC2 release.

the defecting code was the following lines - (1.5)

def use_component_sources!
# ….
sources < < PathSource.new(:lib, "#{::RAILS_ROOT}/lib/generators")
sources << PathSource.new(:vendor, "#{::RAILS_ROOT}/vendor/generators")
sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/**/generators")
# ....
end

the fixed version - (2.0-RC2)

def use_component_sources!
# …

sources < < PathSource.new(:lib, "#{::RAILS_ROOT}/lib/generators")
sources << PathSource.new(:vendor, "#{::RAILS_ROOT}/vendor/generators")
sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/*/**/generators")
sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/*/**/rails_generators")
end
# ...
end

i also checked out rails bug tracker i found a bug was pointed to this issue and apparently which was fixed on the following change set.
http://dev.rubyonrails.org/changeset/6101

on your active record model define has_many with dependent models. R

October 27th, 2007

i was refactoring our Item model, where we have 3 has_many with 3 mapping models.
as we are not using InnoDB based foreign key constraint, we were searching some sort of reliable solution,
which will take pressure in application layer instead of leaving it to the database.

so later we introduced “:dependent” with has_may relation. here is our top of Item model.
has_many :category_mappings, :dependent => :destroy
has_many :categories, :through => :category_mappings

has_many :property_values, :dependent => :destroy
has_many :properties, :through => :property_value

has_many :item_location_mappings, :dependent => :destroy
has_many :locations, :through => :item_location_mappings

our “dependent” flagship is destroying all related items in the item destroy process which has introduced
our flexibility and reduced a lot of code to manage such stuff in a DRY(ied) manner.

so the following unit test worked fine for us.

rails_dependent_unit_test.gif

some bad side,
dependent delete each and every item one by one, which is big issue when you have a big chunk of dependent data.
but that is not suppose to be common in every context. we have no problem with this issue.

best of luck!

“work for fun”

attributes: rails reserved variable :( R

October 20th, 2007

yesterday, i had a pretty rough working day, i was stucked (along with my team) with some simple joining. we had the following models -

Attribute
———–
class Attribute < AR:B
belongs_to :category
end

class AttributeValue < AR:B
belongs_to :item
belongs_to :attribute
end

class Item < AR:B
has_many :attribute_values
has_many :attributes, :through => :attribute_values
end

rails wasn’t giving much better error message, instead it was saying, “invalid type, String to Integer..”, so far i understood ActiveRecord stuff was trying to cast a string to integer.

we even didn’t know which field was doing this stupidity and so on…
so later we dug down to the rails scripts, we added few debug messages. we found “[]” was invoked to set “id” string value.

anyway, after digging more into to this issue, today i gave another try after 7 hours of nice sleep. it was about rails reserve words.

though i heard something from the rails community, but i was expecting some message or  errors which explain this issue.

anyway, i always like fail first approach. if something is not possible it should fail first. at least it should return a meaningful exception.

i believe Active Record should be patched with more clear warning or exception, if any reserved word is used for model or controller or others it should let us inform :) .

JETTY RUNNER version 0.2 R

October 15th, 2007

those who doesn’t know about JETTY RUNNER:
JETTY RUNNER is a standalone swing based application which is used to bundle java ee based application along with jetty container. it comes with simple web app configuration xml file and global properties manager through a simple properties file.

actually i have been using this project for my own development solution, so i belief this project will become a great strengthen feature gradually.

JETTY RUNNER is now running on max OSX, i have removed system try support in new tag v-0.2, soon i will release *.dmg package for mac osx. here are few screen snaps -

jetty runner v0.2
figure - 1: server console main window

jetty_runner_02_settings.gif

figure - 2: global properties editor

change logs -
1. removed system tray support
2. removed default jmx configuration
3. added “start.sh” to launch JETTY RUNNER on *nix based platform where ruby script is installed.
here are few screen snaps, which i have taken from the newly added ruby script! -
jetty_runner_02_ruby_script.gif
figure - 3: newly added jetty runner on ruby

jetty_runner_02_ruby_class.gif
figure - 4: newly added jetty runner implementation in ruby

this script really great ;) , at least i like it :)

Just bang, a new group, Rails artist, Only Ruby on Rails Artist here R

September 5th, 2007

these message convey the basic purpose of the rails_artist group-

Those who belief on themselves, those who believes they are passionate about the rails stuff in ruby way on rails, i belief this gonna create a new open space for them to share their nut and bolts.

from now on let’s change your title from developer, software engineer or architect to an ARTIST :)

welcome, dear artist.

here is the group url -

http://tech.groups.yahoo.com/group/rails_artist/ 

IntelliJ IDEA and ruby plugin R

September 1st, 2007

i belief, i should share this story, once i heard about apatana (eclipse based) ruby IDE i gave it a try without being late, later i heard Net beans got ruby supported, again i wasn’t late and gave it a try.

as you know, i am java developer, always like java stuff everywhere (if possible). anyway, later i returned to my favorite IDE IntelliJ idea.

my personal judgement in terms of usable and flexibility i must say, intelliJ idea with ruby plugin just rocks!!
currently i am developing a active record kind of things where i am using java based repository model in back end and my restful web service clients are developed on ruby.

i am pleased with intelliJ idea, as because the ruby plugin is too friendly, though i faced lot of internal code hints related problem, but i could see those problems were fixed on new release.

here is the ruby plugin details page

It seems LinkedIn moved on tomcat ! R

August 21st, 2007

after a long while i got myself on linked in site, as i got “Server spy” installed on my firefox browser, so i was getting the server name from the browser status menu.

anyway, today i found something different, actually “Server spy” said, linked in is using “Apache-Coyote/1.1″, as far i can remind, linked in was using sun application server previously.

i think it is really interesting, what led linked in to move over tomcat backed or tomcat based servlet container instead of sun application server?

anyway, if i find any info i would love to feed my blog :)

“শ্রম মিটার”, রিক্সা আর ঠেলা গাড়ির জন্য R

August 19th, 2007

আজ রিক্সায় করে আসার সময় ভাবলাম, কেমন হয় আমরা যদি রিক্সা ওয়ালাদের তার প্রাপ্পটা একটা যথাযথ নিয়মে দিতে পারি ?

ত ভাবলাম “শ্রম মিটার” এর ব্যপারে, “শ্রম মিটার” একটা সহজ সিস্টেম, যার কাজ হবে, রিক্সাওয়লার “কেলরি” আর “দুরত্ব” হিসাব করবে ।

এই ২টা হিসাবের মাধ্যমে বের হবে রিক্সার ভাড়া ।

একটা রাফ আইডিয়া, জানিনা কেমন হেব ।

AsyncServlet (JSR-315) proposed by Greg R

July 28th, 2007

Ajax based application is growing too fast, many frequent requests have to handle by application servers. this overhead is really one of the big concern to maintain ajax based application.

more over reading the instance reply is one of the biggest challenge. as all requests are asychronizely processed, so ajax based application send request to application server more frequent that it actually needs.

the good example can be a chat application or a system where we have frequent request to sync with our messaging or notification service.

thats what greg pointed to the JSR 315 proposal. if you already have heard about continuation i belief you have find some use case for using on your own ajax application.

the basic process in continuation is to send delay response. for example -

i had a ajax request, which is intended for receiving a bunch of incoming message from my application server. so my request won’t get disconnected unless they really have some data to notify me. in between this time my request thread will be in suspended mode. obviously you can apply certain timeout period.

following diagram show how a request cycle works -

http_contd_1.gif

the following part shows the event model, which is used to wake up suspended request before it becomes dead and time out request.

http_contd_2.gif

best wishes,