Search the web
Sign In
New User? Sign Up
rails_artist · Only Ruby on Rails Artist here
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 1 - 23 of 23   Newest  |  < Newer  |  Older >  |  Oldest
Messages: Show Message Summaries   (Group by Topic) Sort by Date v  
#23 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Tue Dec 2, 2008 4:35 pm
Subject: Re: Code71's RoR projects
hasan83bd
Offline Offline
Send Email Send Email
 
On Tue, Dec 2, 2008 at 10:28 PM, nhm tanveer hossain khan <
hasan@...> wrote:

> nice conversation from all of you guys, just explaining test driven
> development for those who get into this term recently.
> as you guys know whenever you are writing code you expect some way to get
> it working.
>
> if this application is web based application you try to hit your browser
> until you feel your fix and verify cycle is finished.
> as you know there is no way to get this browser based verify and fix cycle
> out of your box.
>
> thus test first approach came out. you write whatever behavior you expect
> from your code and then write your code to make it working. as soon as you
> get your expectation fixed by the code you have written you stop running
> your unit test.
>
> as you can guess this unit test process can be executed continuously to
> look after your source code, whether any of your team members wrote
> something unfinished which broke the previously written good code by other
> team members.
>
> *so the TDD is the cycle of -*
> write expectation - > write code -> verify -> again write expectation or
> fix code -> verify -> again .....
>
> i try to keep coverage for all critical services. our QA team try to keep
> coverage on UI related functionality through selenium and we keep coverage
> through unit testing.
>
> gradually we are adopting this approach for every type of projects we have,
> lately we even started test driven development for one of our PHP based
> applications.
>
> *when you start practicing TDD, you might feel, WHY should i care?*
> the reason is very simple, this TDD can help you to prove you had clear
> understanding about the function you have been coding for.
>
> since i had pretty long practice with JUnit, i still prefer JUnit, RUnit
> and simpletest for php. but i tried RSpec and loved their syntax and even i
> have experimented RSpec story runner. i would say i loved the story runner
> concept.
> perhaps my next project would start with story runner code.
>
> more interesting i have got to know about easyB which is groovy based
> RSpect type BDD framework for java.
> you will find my blog
here<http://hasan.we4tech.com/bddbehavior-driven-development-with-easyb/>
>
> here is one of my open source
projects<https://github.com/we4tech/semantic-repository/tree>which was developed
based on test first approach. though lately i got most
> the cases are broken since i became lazy to updating the test cases.
>
> thanks for nice initiative,
> best wishes,
>
>
> On Tue, Dec 2, 2008 at 9:50 PM, S. M. Sohan <sohan39@...> wrote:
>
>> Yeameen,
>> Good to know that you are covering your models and controllers. Regarding,
>> RSpec, its cool! The idea stems from BDD, the so called Behavior Driven
>> Development. The inventors of BDD advocates for TDD but they take TDD to be
>> a rather misnomer.
>>
>> We are using *scenario* to get a work around to complexities resulting
>> from fixture. Using this method, you can actually specify the fixture in
>> context of a particular controller, instead of a global fixture for a model.
>> So, you may have multiple fixtures for a single model in different
>> scenarios. Still, its not that easy to get way with the incremental
>> complexities.
>>
>> Another approach that I am yet to try is called Factory method driven
>> approach. In this approach the fixture is removed by using a Factory method.
>> More on this later, once I get some time to take a look at it. However, if
>> you are already familiar with it, an introduction would be handy.
>>
>>
>>
>> On Tue, Dec 2, 2008 at 9:21 PM, ashabul yeameen
<yeameen@...>wrote:
>>
>>> I personally started to write full coverage of unit testing, and try to
>>> cover functional testing as much as possible. most of the business logic
>>> resides in models, so I think its worth. But we never write functional test
>>> script for checking output format (i.e. html). But I rarely write
>>> integration test. Our QA team check different scenarios against the use
>>> cases by some automated tools.
>>>
>>> Complexity of maintaining fixture grows exponentially with size of code.
>>> We try to use mock whenever possible. Another useful method, if you can't
>>> avoid relations anyway, is to write the the data insertion at the beginning
>>> of the unit test script. At least you know you are not causing test failure
>>> to others when you modify data.
>>>
>>> Did anyone try rspec? It isn't much different than rails build-in test
>>> functionality. But the reason I like this is its similarity with natural
>>> language expression, and it is fun to write in this way. I haven't tried
>>> their 'story runner' feature yet.
>>>
>>> Btw, we created a yahoo group when we fast started working with rails.
>>> join and see previous postings.
>>>
>>> http://tech.groups.yahoo.com/group/rails_artist/
>>>
>>> thanks,
>>> -Yeameen
>>>
>>>
>>> On Mon, Dec 1, 2008 at 2:40 PM, Sohan <sohan39@...> wrote:
>>>
>>>>
>>>> Dear group,
>>>> Its good to see a RoR group created.
>>>>
>>>> Just to get started, I would like to present you a few projects that
>>>> we worked/working on using RoR.
>>>>
>>>> 1. http://www.ScrumPad.com - completely developed at Code71 lab.
>>>> 2. http://www.Xerpi.com - developed in conjunction with the Xerpi
>>>> team.
>>>> 3. http://www.MonkeySee.com - developed jointly by Code71 and
>>>> CodeSherpas (US based)
>>>>
>>>> Please, let us know your project experience. We are having a lot of
>>>> fun with RoR. Said that, we are also finding some pains related to it
>>>> and it would be great to share the learning. My questions are as
>>>> follows-
>>>>
>>>> 1. Are you doing TDD?
>>>> 2. If yes, are you writing Unit/functional/integration tests?
>>>>
>>>> What I found is, the fixture driven unit tests are getting difficult
>>>> to manage as the code is growing in size. Please let us know how you
>>>> are managing this testing. I would also like to know about the % test
>>>> coverage that you have and target to achieve.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>> --
>> Best Wishes,
>> Sohan
>> http://www.smsohan.com
>> http://smsohan.blogspot.com
>> http://www.code71.com
>>
>>
>> --~--~---------~--~----~------------~-------~--~----~
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails Bangladesh" group.
>> To post to this group, send email to
>> rubyonrails_bangladesh@googlegroups.com
>> To unsubscribe from this group, send email to
>>
rubyonrails_bangladesh+unsubscribe@googlegroups.com<rubyonrails_bangladesh%2Buns\
ubscribe@googlegroups.com>
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails_bangladesh?hl=en
>> -~----------~----~----~----~------~----~------~--~---
>>
>>
>
>
> --
> ----------------------------------------------------
> nhm tanveer hossain khan (hasan)
> http://hasan.we4tech.com
> ----------------------------------------------------
> mobile: +880 1713 090 511
> aawaj: hasan15422
> ----------------------------------------------------
> "work for fun"
> "you think you are silly because you are not in right circle"
> "all human beings are entrepreneurs" - m. yunus
>



--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
aawaj: hasan15422
----------------------------------------------------
"work for fun"
"you think you are silly because you are not in right circle"
"all human beings are entrepreneurs" - m. yunus


[Non-text portions of this message have been removed]

#22 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Tue Dec 2, 2008 4:28 pm
Subject: Re: Code71's RoR projects
hasan83bd
Offline Offline
Send Email Send Email
 
nice conversation from all of you guys, just explaining test driven
development for those who get into this term recently.
as you guys know whenever you are writing code you expect some way to get it
working.

if this application is web based application you try to hit your browser
until you feel your fix and verify cycle is finished.
as you know there is no way to get this browser based verify and fix cycle
out of your box.

thus test first approach came out. you write whatever behavior you expect
from your code and then write your code to make it working. as soon as you
get your expectation fixed by the code you have written you stop running
your unit test.

as you can guess this unit test process can be executed continuously to look
after your source code, whether any of your team members wrote something
unfinished which broke the previously written good code by other team
members.

*so the TDD is the cycle of -*
write expectation - > write code -> verify -> again write expectation or fix
code -> verify -> again .....

i try to keep coverage for all critical services. our QA team try to keep
coverage on UI related functionality through selenium and we keep coverage
through unit testing.

gradually we are adopting this approach for every type of projects we have,
lately we even started test driven development for one of our PHP based
applications.

*when you start practicing TDD, you might feel, WHY should i care?*
the reason is very simple, this TDD can help you to prove you had clear
understanding about the function you have been coding for.

since i had pretty long practice with JUnit, i still prefer JUnit, RUnit and
simpletest for php. but i tried RSpec and loved their syntax and even i have
experimented RSpec story runner. i would say i loved the story runner
concept.
perhaps my next project would start with story runner code.

more interesting i have got to know about easyB which is groovy based RSpect
type BDD framework for java.
you will find my blog
here<http://hasan.we4tech.com/bddbehavior-driven-development-with-easyb/>

here is one of my open source
projects<https://github.com/we4tech/semantic-repository/tree>which was
developed based on test first approach. though lately i got most
the cases are broken since i became lazy to updating the test cases.

thanks for nice initiative,
best wishes,

On Tue, Dec 2, 2008 at 9:50 PM, S. M. Sohan <sohan39@...> wrote:

> Yeameen,
> Good to know that you are covering your models and controllers. Regarding,
> RSpec, its cool! The idea stems from BDD, the so called Behavior Driven
> Development. The inventors of BDD advocates for TDD but they take TDD to be
> a rather misnomer.
>
> We are using *scenario* to get a work around to complexities resulting
> from fixture. Using this method, you can actually specify the fixture in
> context of a particular controller, instead of a global fixture for a model.
> So, you may have multiple fixtures for a single model in different
> scenarios. Still, its not that easy to get way with the incremental
> complexities.
>
> Another approach that I am yet to try is called Factory method driven
> approach. In this approach the fixture is removed by using a Factory method.
> More on this later, once I get some time to take a look at it. However, if
> you are already familiar with it, an introduction would be handy.
>
>
>
> On Tue, Dec 2, 2008 at 9:21 PM, ashabul yeameen
<yeameen@...>wrote:
>
>> I personally started to write full coverage of unit testing, and try to
>> cover functional testing as much as possible. most of the business logic
>> resides in models, so I think its worth. But we never write functional test
>> script for checking output format (i.e. html). But I rarely write
>> integration test. Our QA team check different scenarios against the use
>> cases by some automated tools.
>>
>> Complexity of maintaining fixture grows exponentially with size of code.
>> We try to use mock whenever possible. Another useful method, if you can't
>> avoid relations anyway, is to write the the data insertion at the beginning
>> of the unit test script. At least you know you are not causing test failure
>> to others when you modify data.
>>
>> Did anyone try rspec? It isn't much different than rails build-in test
>> functionality. But the reason I like this is its similarity with natural
>> language expression, and it is fun to write in this way. I haven't tried
>> their 'story runner' feature yet.
>>
>> Btw, we created a yahoo group when we fast started working with rails.
>> join and see previous postings.
>>
>> http://tech.groups.yahoo.com/group/rails_artist/
>>
>> thanks,
>> -Yeameen
>>
>>
>> On Mon, Dec 1, 2008 at 2:40 PM, Sohan <sohan39@...> wrote:
>>
>>>
>>> Dear group,
>>> Its good to see a RoR group created.
>>>
>>> Just to get started, I would like to present you a few projects that
>>> we worked/working on using RoR.
>>>
>>> 1. http://www.ScrumPad.com - completely developed at Code71 lab.
>>> 2. http://www.Xerpi.com - developed in conjunction with the Xerpi
>>> team.
>>> 3. http://www.MonkeySee.com - developed jointly by Code71 and
>>> CodeSherpas (US based)
>>>
>>> Please, let us know your project experience. We are having a lot of
>>> fun with RoR. Said that, we are also finding some pains related to it
>>> and it would be great to share the learning. My questions are as
>>> follows-
>>>
>>> 1. Are you doing TDD?
>>> 2. If yes, are you writing Unit/functional/integration tests?
>>>
>>> What I found is, the fixture driven unit tests are getting difficult
>>> to manage as the code is growing in size. Please let us know how you
>>> are managing this testing. I would also like to know about the % test
>>> coverage that you have and target to achieve.
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> --
> Best Wishes,
> Sohan
> http://www.smsohan.com
> http://smsohan.blogspot.com
> http://www.code71.com
>
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails Bangladesh" group.
> To post to this group, send email to
> rubyonrails_bangladesh@googlegroups.com
> To unsubscribe from this group, send email to
>
rubyonrails_bangladesh+unsubscribe@googlegroups.com<rubyonrails_bangladesh%2Buns\
ubscribe@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails_bangladesh?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>


--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
aawaj: hasan15422
----------------------------------------------------
"work for fun"
"you think you are silly because you are not in right circle"
"all human beings are entrepreneurs" - m. yunus


[Non-text portions of this message have been removed]

#21 From: "hasan83bd" <hasan83bd@...>
Date: Sat Apr 19, 2008 4:22 pm
Subject: moderate use of dynamic feature
hasan83bd
Offline Offline
Send Email Send Email
 
hi,
i was wondering why the following line of codes were written -
i found it from action_controller/test_process.rb file.

def self.included(base)
       # execute the request simulating a specific http method and set/
volley the response
       %w( get post put delete head ).each do |method|
         base.class_eval <<-EOV, __FILE__, __LINE__
           def #{method}(action, parameters = nil, session = nil, flash
= nil)
             @request.env['REQUEST_METHOD'] = "#{method.upcase}" if
defined?(@request)
             process(action, parameters, session, flash)
           end
         EOV
       end
     end

i believe, this was trying to make this code more DRY'ed, but this
think might be confusion for other sufferer.
because this "get, post, put, delete, head" methods are not reflected
during RDoc compilation.

unless we get some solution like "monitor loaded class behavior and
render documentation based upon their meta information" for example
-
      %w( get post put delete head ).each do |method|
         base.class_eval <<-EOV, __FILE__, __LINE__
            desc "delegating process method"
            def #{method}(action, parameters = nil, session = nil,
flash = nil)
             @request.env['REQUEST_METHOD'] = "#{method.upcase}" if
defined?(@request)
             process(action, parameters, session, flash)
           end
         EOV
       end

i would really love to see this kind of code is broken into the
following code -
# delegating process method
def post(action, parameters = nil, session = nil, flash = nil)
    @request.env['REQUEST_METHOD'] = "#{method.upcase}" if defined?
(@request)
     process(action, parameters, session, flash)
end

# delegating process method
def get(action, parameters = nil, session = nil, flash = nil)
    @request.env['REQUEST_METHOD'] = "#{method.upcase}" if defined?
(@request)
     process(action, parameters, session, flash)
end
....

best wishes,

#20 From: "hasan83bd" <hasan83bd@...>
Date: Sun Feb 10, 2008 7:57 am
Subject: upcoming project mojar_workflow
hasan83bd
Offline Offline
Send Email Send Email
 
hi,
we just kicking start a new open source ruby project "mojar workflow".
we named it after our deshi word "mojar" reason is very clear to
spread out this word.

mojar workflow, is integral solution to execute a flow of business
rules. for example -

you have an action where you have the following set of rules -
1. start transaction
2. verify user account
3. verify user balance
4. verify user dues
5. reduce dues from balance
6. complete transaction

after few days you got a new requirement, where you suppose to reduce
user dues by the 10% because of company new discount policy.
so you have to implement the following rules -
1. start transaction
2. verify user account
3. verify user balance
4. verify user dues
5. reduce dues by 10% of discount
5. reduce discounted dues from balance
6. complete transaction

to implement such scenario you have to again code in your stable
release. but using mojar workflow, you can add that new concern from
the abstract flow maintenance layer. where you can define this flow in
yaml file or an xml document.

keep your eyes on -
http://rubyforge.org/projects/mojarworkflow/

best wishes,

#19 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Wed Jan 23, 2008 12:46 pm
Subject: how to configure dynamic subdomain
hasan83bd
Offline Offline
Send Email Send Email
 
here is how we have configured dynamic sub domain, where application
determine the resource based on subdomain name.
for example -
test.mydomain.com, here "test" is subdomain

write this to your dns configuration -
*.mydomain.com. 14400 IN A 123.123.123.123

now any host lookups (eg. blah.mydomain.com, foo.mydomain.com) will
resolve to 123.123.123.123

best wishes,
--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
               "work for fun"


[Non-text portions of this message have been removed]

#18 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Mon Dec 24, 2007 5:08 pm
Subject: Immutable class or object in ruby
hasan83bd
Offline Offline
Send Email Send Email
 
hi,
sometimes we want our object or instance variables should be immutable (none
changeable).
for example, if you have the following code -
data = ["a", "b"]
call_some_method(data)

you expect "call_some_method" shouldn't change your argument. there are two
way you can ensure immutability.
1. clone your array while you passing through the method.
call_some_method(data.clone)
2. freeze your array so none can change your array.
data.freeze
call_some_method(data)
in this case, if someone try to change the value of data it will throw an
exception.

similarly we can ensure mutability for classes as well, as you know ruby as
great advantage of being open. anytime anywhere you can replace or change
the class behavior.
for example:

class String
  def print
    puts self
  end
end

so sometimes your exposed api should be more preventive, in that case don't
forget to use freeze.
for example - if String class was freezed you won't be able to modify this
class anymore.

hope this will help to understand where should you use freeze.

best wishes,
--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
               "work for fun"


[Non-text portions of this message have been removed]

#17 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Tue Dec 11, 2007 1:39 am
Subject: globalizing your rails application
hasan83bd
Offline Offline
Send Email Send Email
 
hi,
here what luca guidi blogged on his blog -
http://www.lucaguidi.com/pages/click-to-globalize

this is pretty similar idea that we had these days. it seems like it
supports javascript
based inplace editor to add localized text.

best wishes,
--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
               "work for fun"


[Non-text portions of this message have been removed]

#16 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Thu Nov 29, 2007 7:41 am
Subject: rails plugin symlinked broken on 1.2.5, fixed from 2.0
hasan83bd
Offline Offline
Send Email Send Email
 
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-RC2release.

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<http://dev.rubyonrails.org/ticket/4245>to this issue and
apparently which was fixed on the following change set.
http://dev.rubyonrails.org/changeset/6101


--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
               "work for fun"


[Non-text portions of this message have been removed]

#15 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Thu Nov 29, 2007 6:45 am
Subject: simple way to know which script is being evaluated by ruby
hasan83bd
Offline Offline
Send Email Send Email
 
hi,
sometimes it is very important to know which files were evaluated by ruby
interpreter.

here is the simplest way to make it possible -
ruby -d "script"

best wishes,

--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
               "work for fun"


[Non-text portions of this message have been removed]

#14 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Fri Nov 16, 2007 9:08 pm
Subject: simple fragment cache implementation on ruby on rails
hasan83bd
Offline Offline
Send Email Send Email
 
i was getting serious performance problem with one of my projects. so i came
up with a simple fragment cache implementation on ruby on rails.

after implementing this stuff, i replaced "render(:partial => ...)" with the
following method -

render_from_cache_or_render(:cache_key =>"cache key",
:cache_expire_after => ConstantHelper::TAG_CLOUD_EXPIRED_IN, # minutes
:partial => "....")

let's have a look on my implementation -

def render_from_cache_or_render(p_args)

return render(p_args) if true == p_args[:cache_off]

# check from cache
cache_key = p_args[:cache_key]
cached_content = CacheService.get_cache(cache_key)

if not cached_content.nil? and not cached_content.empty?
return cached_content
else
content = render(p_args)
# cache expire time if defined
cache_expire_time_in_minutes = p_args[:cache_expire_after] || 60
CacheService.add_cache(cache_key, cache_expire_time_in_minutes, content)
return content
end
end

actually, my implemented "CacheService" class is simply storing all cache in
a hash map.
when some cache was requested for peek, cache expiry was checked before
returning the cached value.

for CacheService implementation look at the bottom of my post.

anyway, after implementing and utilizing this stuff, i gained 70+ requests
capability per second. fyi, before applying cache it was around 10 per
second.

module Cache
class Item
attr_accessor :key, :expire_time, :content, :created_on

def initialize(p_key, p_expire_time, p_content)
@key = p_key
@expire_time = p_expire_time * 60 # in minutes
@content = p_content
@created_on = Time.now
end
end
end

class CacheService
@@CACHES = {}
@@CACHE_EXPIRE_TIMES = {}

def self.add_cache(p_key, p_expire_time, p_content)
cache_item = Cache::Item.new(p_key, p_expire_time, p_content)
@@CACHES[p_key.to_sym] = cache_item
end

def self.get_cache(p_key)
# load content from cache
cached_content = @@CACHES[p_key.to_sym]
return nil if cached_content.nil?

# verify cache validity
return cached_content.content if not expired?(cached_content)
return nil
end

private
def self.expired?(p_cache)
# find time difference
time_difference = Time.now - p_cache.created_on
return true if time_difference > p_cache.expire_time
end
end

best wishes,


--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
               "work for fun"


[Non-text portions of this message have been removed]

#13 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Sat Nov 10, 2007 8:47 am
Subject: simple AOP implementation in ruby
hasan83bd
Offline Offline
Send Email Send Email
 
i was suppose to work on some of my other projects, but i passed my time by
writing a simple aop implementation in ruby.
it is neither powerful like AspectJ nor comparable with AspectR. however, i
was having fun with my day off.

here is how my simple example is running-

def test_aop
# apply pointcuts
apply_advices(:before, /^do_.+/, SimpleService, SimpleServiceAdvice,
:before_do)
apply_advices(:around, /^do_.+/, SimpleService, SimpleServiceAdvice,
:around_do)
apply_advices(:after, /^do_.+/, SimpleService, SimpleServiceAdvice,
:after_do)

simple_service = SimpleService.new
simple_service.do_1("A")
end


here is the parameter name.

apply_advices(type_of_advice, pointcuts_in_regex, service_class,
advice_class, advice_method)

instead of making aspectJ type pointcuts syntax, i have used regex, which is
fine for the time being.

if you run this code you will find the following output -

Before execution.
Around {
1 performed - A
}
After execution.

now let's have a look on my *SimpleService* class.

class SimpleService

def do_1(p_param)
puts "1 performed - #{p_param}"
end

def do_2
puts "2 performed."
end

def no_do
puts "No do"
end
end

and here is my aspect class,

class SimpleServiceAdvice

def around_do(p_invoke)
puts "Around { "
output = p_invoke.proceede()
puts "}"
return output
end

def before_do(p_invoke)
puts "Before execution."
end

def after_do(p_params, p_output)
puts "After execution."
end
end

my implementation is very straight forward, actually during implementing
this stuff, i really felt the strength of meta programming. it is so
flexible and so easy that sky is the limit.

here is the attached source code.
<http://hasan.we4tech.com/wp-content/uploads/2007/11/aop_test.zip>

much better and complete aop implementation in
ruby<http://aspectr.sourceforge.net/>


--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
               "work for fun"


[Non-text portions of this message have been removed]

#12 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Sat Nov 10, 2007 2:32 am
Subject: Re: rails monitoring products
hasan83bd
Offline Offline
Send Email Send Email
 
hi emon,
nice finding, perhaps i had a look on this tool previously, at that time, i
had no idea what it can do.
now i feel it is time to check this out.

little bit about this product -
this product is about to measure or monitor the rails based web application.
where it will give several reports on controller, active record, database,
cache and other performance, connectivity and integration. these report will
help you to figure out the potential problem from a production environment.

best wishes,

On Nov 9, 2007 3:38 PM, emon <emon@...> wrote:

> hi ruby on rails guys.
> check this out:
>
> http://www.fiveruns.com/products
>
>
>
>
>
> --
> emon(ইমন)
> rails developer & research intern
> team-rnd, somewhere in...
> blog- http://emon.we4tech.com
> ******************************
> "research&develop to pursuit happiness altogether :)"
> ******************************
>
>
>
>
>
>
>
>


--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
               "work for fun"


[Non-text portions of this message have been removed]

#11 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Sat Nov 3, 2007 4:56 am
Subject: Fat Refactoring: use include module to reduce number of lines
hasan83bd
Offline Offline
Send Email Send Email
 
if i didn't mention that before, i should tell it now, here at somewhere
in... <http://www.somewherein.net/> rnd team we are playing a lot with ruby
on rails. these days our rails team is completely focusing on a
product(which is secret for the time being :) ) where we
found a lot of interesting stuffs, for instance.

few days back, we found our application_helper and few controllers are
growing too fast and getting extra fat (lines of code). so we had few
refactoring to reduce the extra fat.

now have a look on the code we had with in application_helper.rb taken from
tag/v-0.3
[image:
fat_refactoring_before.gif]<http://hasan.we4tech.com/wp-content/uploads/2007/11/\
fat_refactoring_before.gif>

  this code is not completely visible over the screen snap, this is 340
number of lines. which was the output of our 3 iteration.

though these number of lines are not that much problematic, but we had a
scenario which was difficult to make it more concern aware and single
concerned.

now have a look on our code which is taken from the current trunk,
[image:
fat_reforing_after.gif]<http://hasan.we4tech.com/wp-content/uploads/2007/11/fat_\
reforing_after.gif>


Wow, now it is 50 lines only including the header copyright information.
the trick was very simple, we followed the following conventions -

1. find out all related and same concerned functions
2. stick team together in a module
3. include the module to statically available all functions

no integration problem, nothing has occurred.
we are happy with this :)
i think our ruby learning process is going smoothly :)

--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
                "work for fun"


[Non-text portions of this message have been removed]

#10 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Sat Oct 27, 2007 10:36 am
Subject: good of active record :dependent
hasan83bd
Offline Offline
Send Email Send Email
 
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.

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!

--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
                "work for fun"


[Non-text portions of this message have been removed]

#9 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Sat Oct 20, 2007 5:58 pm
Subject: seal yourself on "working with rails"
hasan83bd
Offline Offline
Send Email Send Email
 
hi rails artists,
why not count you in the common rails developer community.
create your profile with http://workingwithrails.com/ NOW!!

here is my profile -
http://workingwithrails.com/person/9969-nhm-tanveer-hossain-khan-hasan

best wishes,
--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
                "work for fun"


[Non-text portions of this message have been removed]

#8 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Sat Oct 20, 2007 8:46 am
Subject: attributes: rails reserved variable :(
hasan83bd
Offline Offline
Send Email Send Email
 
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 [image: :)] .


--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
                "work for fun"


[Non-text portions of this message have been removed]

#7 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Sat Oct 6, 2007 1:50 pm
Subject: where to invoke "layout"? AppllicationController or ChildController?
hasan83bd
Offline Offline
Send Email Send Email
 
these days i am having a lot of fun with Ruby on Rails. it seems to be
like an open ground with lot of handful tools, now come up with ideas
and build them up.

handful ruby based tools really helping me to let my smile back.
anyway, while i was writing code on rails i am feeling something can
be better practice something is not good. from now on, i will try to
put them over the my blog.

their is method called "layout" which is used to define the based
layout for the controller. this can be used from ApplicationController
and other domain specific controller for example : "UserController".

my team and me was used to define layout over the domain specific
controller, but i belief, as we are repeating same "layout
'template1'" code over and over, it must be better to keep inside the
ApplicationController, as because all domain specific controllers are
extending application controller, more over it is easy to change.

you may get a question about ajax based response, the better answer
is, use render .., layout => false, that will get rid of base layout.

best wishes,





--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
                "work for fun"

#6 From: "emonm1" <emonm1@...>
Date: Fri Sep 21, 2007 7:33 pm
Subject: got the first rails book- thanks hasan
emonm1
Offline Offline
Send Email Send Email
 
swi-rails team got couple of ruby & rails book for the first time.
as earlier we had only pdf copy...no books still avilable here in the
market on ror. reading a book on what you work on is much pleasure
when the copy is in your hand. so hasan bought few books for us while
he was attending in the recent rails conference at berlin.

i really appreciate your euro :)
thanks again.

#5 From: "nhm tanveer hossain khan" <hasan83bd@...>
Date: Fri Sep 21, 2007 6:27 pm
Subject: Re: Re: configure rails in production environment.
hasan83bd
Offline Offline
Send Email Send Email
 
so far i know, lighthttpd is  only supported on mac os,
though many people suggested to use apache front with reverse proxy load balancer and a list of mongrel instance.

i wish, i will give it a try, this might be a nice option.

best wishes,

On 9/19/07, emonm1 <emonm1@...> wrote:

lighthttpd working best in deploy environment.

--- In rails_artist@yahoogroups.com, "hasan83bd" <hasan83bd@...> wrote:
>
>
> for last couple of days, i was struggle with rails deployment related
> issue, so far i was happy with mongrel backed and apache reverse proxy
> front configuration.
>
> so last night, i found mongrel is surprisingly slow for serving static
> content, like javascripts, images, and styles files. so later i set
> apache for serving static files. now it seems out performing ;)
>
> anyway, i was wondering about mongrel and how does it works in
> production deployment. as we know (who use java backed application
> server in production environment), any java backed application container
> are configurable. where we can define the maximum limit of thread pool
> size.
>
>
> but i didn't find this type of thing over mongrel, later few of the
> following urls, really helped me to understand how mongrel works in
> production environment. the concept is very simple.
>
> every mongrel worker is a standalone instance of mongrel and every
> mongrel instances are listening to a specific port. so i have to setup a
> reverse proxy or a load balancer which will be used to pick up the right
> mongrel instance. for all session affinity shake, there must be some
> solutions, this is what i have to figure out later. (hopefully after
> getting my laptop)
>
>
> here are the resource links -
>
> pound - used as load balancer and reverse proxy service
> <http://www.apsis.ch/pound/index_html> .
>
> jared's guide how to install pound
> <http://www.jaredrichardson.net/blog/2006/11/21/#installing-pound >
>
> Grails vs rails fight, though it doesn't worth rather than few
> configuration learning
> <http://docs.codehaus.org/display/GRAILS/Grails+vs+Rails+Benchmark > .
>
> hope these will be helpful for my future reminding :)
>




--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
               "work for fun"

#4 From: "emonm1" <emonm1@...>
Date: Thu Sep 20, 2007 4:01 am
Subject: Sun surprises at RailsConf Europe 2007
emonm1
Offline Offline
Send Email Send Email
 
The biggest surprise at RailsConf Europe 2007 was hearing Craig
McClanahan from Sun speak. Craig is the creator of Struts,the original
blockbuster web framework for Java, and more recently Java Server Faces.

check out what he says next here:

http://www.loudthinking.com/posts/11-sun-surprises-at-railsconf-europe-2007

#3 From: "emonm1" <emonm1@...>
Date: Thu Sep 20, 2007 3:54 am
Subject: Re: configure rails in production environment.
emonm1
Offline Offline
Send Email Send Email
 
lighthttpd working best in deploy environment.

--- In rails_artist@yahoogroups.com, "hasan83bd" <hasan83bd@...> wrote:
>
>
> for last couple of days, i was struggle with rails deployment related
> issue, so far i was happy with mongrel backed and apache reverse proxy
> front configuration.
>
> so last night, i found mongrel is surprisingly slow for serving static
> content, like javascripts, images, and styles files. so later i set
> apache for serving static files. now it seems out performing ;)
>
> anyway, i was wondering about mongrel and how does it works in
> production deployment. as we know (who use java backed application
> server in production environment), any java backed application container
> are configurable. where we can define the maximum limit of thread pool
> size.
>
>
> but i didn't find this type of thing over mongrel, later few of the
> following urls, really helped me to understand how mongrel  works in
> production environment. the concept is very simple.
>
> every mongrel worker is a standalone instance of mongrel and every
> mongrel instances are listening to a specific port. so i have to setup a
> reverse proxy or a load balancer which will be used to pick up the right
> mongrel instance.  for all session affinity shake, there must be some
> solutions, this is what i have to figure out later. (hopefully after
> getting my laptop)
>
>
> here are the resource links -
>
> pound - used as load balancer and reverse proxy service
> <http://www.apsis.ch/pound/index_html> .
>
> jared's guide how to install pound
> <http://www.jaredrichardson.net/blog/2006/11/21/#installing-pound>
>
> Grails vs rails fight, though it doesn't worth rather than few
> configuration learning
> <http://docs.codehaus.org/display/GRAILS/Grails+vs+Rails+Benchmark> .
>
> hope these will be helpful for my future reminding :)
>

#2 From: "emonm1" <emonm1@...>
Date: Thu Sep 20, 2007 3:52 am
Subject: a mind blowing rails conference - railsconfeurope,2007
emonm1
Offline Offline
Send Email Send Email
 
yea,i have to say that when j2ee guys making rails conference
successful."roy fielding" " the author REST concept",
"dave thomas" one of the best known in ror world& the author of "agile
web development with rails" best selling book of rails & many more

check this out & watch,enjoy the presentations rails way...

http://conferences.oreillynet.com/pub/w/61/presentations.html

DHH(david hanson)the creator of rails framework,saying @ his blog about:

www.loudthinking.com

now eagerly waiting for our "hasan" who attended in this conference.
hopefully he is coming back fully charged with rails.

good day,

emon

#1 From: "hasan83bd" <hasan83bd@...>
Date: Sun Sep 9, 2007 3:01 am
Subject: configure rails in production environment.
hasan83bd
Offline Offline
Send Email Send Email
 

for last couple of days, i was struggle with rails deployment related issue, so far i was happy with mongrel backed and apache reverse proxy front configuration.

so last night, i found mongrel is surprisingly slow for serving static content, like javascripts, images, and styles files. so later i set apache for serving static files. now it seems out performing ;)

anyway, i was wondering about mongrel and how does it works in production deployment. as we know (who use java backed application server in production environment), any java backed application container are configurable. where we can define the maximum limit of thread pool size.

but i didn't find this type of thing over mongrel, later few of the following urls, really helped me to understand how mongrel  works in production environment. the concept is very simple.

every mongrel worker is a standalone instance of mongrel and every mongrel instances are listening to a specific port. so i have to setup a reverse proxy or a load balancer which will be used to pick up the right mongrel instance.  for all session affinity shake, there must be some solutions, this is what i have to figure out later. (hopefully after getting my laptop)

here are the resource links -

pound - used as load balancer and reverse proxy service.

jared's guide how to install pound

Grails vs rails fight, though it doesn't worth rather than few configuration learning.

hope these will be helpful for my future reminding :)


Messages 1 - 23 of 23   Newest  |  < Newer  |  Older >  |  Oldest
Advanced
Add to My Yahoo!      XML What's This?

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help