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
Fat Refactoring: use include module to reduce number of lines   Message List  
Reply | Forward Message #11 of 23 |
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]




Sat Nov 3, 2007 4:56 am

hasan83bd
Offline Offline
Send Email Send Email

Forward
Message #11 of 23 |
Expand Messages Author Sort by Date

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....
nhm tanveer hossain k...
hasan83bd
Offline Send Email
Nov 3, 2007
4:57 am
Advanced

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