Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Refactorings again: idea for library

Reply
Thread Tools

Refactorings again: idea for library

 
 
Victor \Zverok\ Shepelev
Guest
Posts: n/a
 
      09-26-2007
Hi all.

Here's an idea stolen from [1] and [2].

Suppose we have a library. Suppose we've done some refactorings in it
(method or class renamed, class splitted into several, or joined, or...)

The task: change all client code in correspondence to library change.

The trick:

library/changelog.rb
---
module MyLibrary::Changelog
version(0.2.5) do
method_renamed [SomeClass, :method_a] => :method_b
method_removed [SomeClass, ld_method], "he was too old"
module_method_moved [SomeModule, :method_c] => OtherModule
class_renamed ClassA => ClassB
end
end
---

in code, which uses our library:

---
require 'library'
require 'library/changelog' #can omit this if you're not interested in
changes

s = SomeClass.new

s.method_a
#prints "Warning: method #method_a is renamed to #method_b. Called from
app.rb:10
#then calls s.method_b

s.old_method
#throws "Error: #old_method was removed because he was too old"
#? or prints warning and DOESN'T calls any method

SomeModule::method_c
#prints "Warning: method #method_c moved to OtherModule. Called from
app.rb:12
#then calls OtherModule::method_c

ClassA.new
#prints "Warning: ClassA renamed to ClassB. blah"
#then calls ClassB.new
---

the version(0.0.2) in example above can allow user to say
MyLibrary::ChangeLog.from_version = 0.2.1 #migrating from 0.2.1 to 0.2.5

and see only appropriate warnings.

Wha?

V.


1:
http://www.dogbiscuit.org/mdub/weblo...byMethodRename
d
2: http://blade.nagaokaut.ac.jp/cgi-bin...uby-talk/49730


 
Reply With Quote
 
 
 
 
Trans
Guest
Posts: n/a
 
      09-26-2007


On Sep 26, 6:42 am, "Victor \"Zverok\" Shepelev"
<(E-Mail Removed)> wrote:
> Hi all.
>
> Here's an idea stolen from [1] and [2].
>
> Suppose we have a library. Suppose we've done some refactorings in it
> (method or class renamed, class splitted into several, or joined, or...)
>
> The task: change all client code in correspondence to library change.
>
> The trick:
>
> library/changelog.rb
> ---
> module MyLibrary::Changelog
> version(0.2.5) do
> method_renamed [SomeClass, :method_a] => :method_b
> method_removed [SomeClass, ld_method], "he was too old"
> module_method_moved [SomeModule, :method_c] => OtherModule
> class_renamed ClassA => ClassB
> end
> end
> ---
>
> in code, which uses our library:
>
> ---
> require 'library'
> require 'library/changelog' #can omit this if you're not interested in
> changes
>
> s = SomeClass.new
>
> s.method_a
> #prints "Warning: method #method_a is renamed to #method_b. Called from
> app.rb:10
> #then calls s.method_b
>
> s.old_method
> #throws "Error: #old_method was removed because he was too old"
> #? or prints warning and DOESN'T calls any method
>
> SomeModule::method_c
> #prints "Warning: method #method_c moved to OtherModule. Called from
> app.rb:12
> #then calls OtherModule::method_c
>
> ClassA.new
> #prints "Warning: ClassA renamed to ClassB. blah"
> #then calls ClassB.new
> ---
>
> the version(0.0.2) in example above can allow user to say
> MyLibrary::ChangeLog.from_version = 0.2.1 #migrating from 0.2.1 to 0.2.5
>
> and see only appropriate warnings.
>
> Wha?


It a very interesting idea. But I fear it would too hard to maintain
for anything but the smallest lib/app. I think it's better to just to
have intermediary versions that add warnings to methods that are going
away soon (if possible).

T.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: App idea, Any idea on implementation? Matthew_WARREN@bnpparibas.com Python 0 02-05-2008 05:50 PM
App idea, Any idea on implementation? Dr Mephesto Python 3 02-05-2008 06:55 AM
Unique message thought about the idea of throwing out Google for financial corruption (not counting their Napstering Library project), if anything, an experiment pr Computer Support 6 10-15-2005 09:32 PM
Re: Unique message thought about the idea of throwing out Google for financial corruption (not counting their Napstering Library project), if anything, an experiment oj Computer Support 0 10-12-2005 09:51 PM
Nested conditional expressions ---- good idea/bad idea? nimmi_srivastav@yahoo.com C Programming 10 02-02-2005 10:51 PM



Advertisments