Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Tight coupling vs. complete abstraction
Trans
10/29/2006 1:47:00 PM
On n' off I've been thinking about something Ruby allows one to do more
so than most other languages --in many usecases it allows one to
construct a program that is tightly coupled to the language interpretor
itself rather than use the langage to create a complete abatraction of
the problem. To give an example of what I mean consider Facets[1]
command line tool:
>cat greet
#!/usr/bin/ruby
require 'facets'
require 'command'
MyCmd < Console::Command
def __who(v)
@who = v
end
def hello
puts "Hello, #{@who}!"
end
end
> greet --who Mom hello
> Hello, Mom!
Notice how the functionality of the command line is strongly tied to
the functionality of Ruby's method calls. ConsoleCommand does a lot of
neat metaprogramming tricks to send the right message to the right
place with the right data depending on arity of the methods defined ,
etc.
Coding like things can make many programming chores dirt simple,
becuase there's no need to learn YAAPI (Yet Another API). But there can
be some unexpected side effects. For instance there is potential for
name clashes with built-in methods. Now most of these problems can be
mitigated but no doubt there's alwys that overlooked case, and ther are
some edge uses that simply have to be avoided.
So I'm wondering, is it worth it? Does the simplicity of tight coupling
outweigh it's potential pitfalls? Or is there a better way to
essentially get the best of both worlds? What do other's think of this
techinque of coding?
T.
[1]
http://facets.ruby...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Tight coupling vs. complete abstraction
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password