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.
···
On Sep 26, 6:42 am, "Victor \"Zverok\" Shepelev" <vshepe...@imho.com.ua> 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, :old_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
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, :old_method], "he was too old"
module_method_moved [SomeModule, :method_c] => OtherModule
class_renamed ClassA => ClassB
end
end
---
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).
Hmmm..
1. I think, many library authors already put this information to changelogs
in human-readable form (like "Warning! API changed: blah"). I just propose
to do such messages auto-checkable.
2. I've envisioned (but forget to show) the case you saying about:
module MyLibrary::Changelog
version(0.2.5) do
method_deprecated [SomeClass, :method_a], "Will remove this ASAP"
end
end
just one more usage of the idea
V.
···
From: Trans [mailto:transfire@gmail.com]
Sent: Wednesday, September 26, 2007 5:34 PM
On Sep 26, 6:42 am, "Victor \"Zverok\" Shepelev" ><vshepe...@imho.com.ua> wrote: