[REBOL] Re: REBOL : Pure OOP project ?
From: greggirwin:mindspring at: 9-Apr-2002 0:03
I've been doing OOP stuff heavily for the past 7 years (though SmallTalkers
and Eiffel folks could argue about the OOP-ness of it :) and I'm constantly
amazed at the code I find myself writing in REBOL compared to what I would
have written before.
IMO, of the "big 3", Encapsulation provides 49.5% of the value, Polymorphism
is 49.5%, and Inheritance the rest. :) These, of course, are my opinions
based on my experience. YMMV. For large projects, the value of Encapsulation
goes up. The judicious use of Polymorphism can help to keep projects from
<< I can understand the power of refinements, and have even used it for some
small scripts... but at the same time I don't like it... I have found that
most of the time, refinements are simply booleans with further arguements.
Furthermore, they are usually used in functions that does too much ! I
prefer small functions that do less... >>
I've always liked the ability to provide optional arguments. Like other
features, it can be abused, but, done right, they can help to reduce the
number of routines you have to deal with and actually provide quite a bit of
value. For example, I have a ROUND function that has *6* possible
refinements (with one of them probably going away as it's semi-redundant
with another). Normally I would run screaming from something like that but I
looked at the alternative and like this solution better. Here's the help for
ROUND value /up /floor /ceiling /truncate /places pl /to-interval
Rounds numeric value with refinements for what kind of rounding
you want performed, how many decimal places to round to, etc.
ROUND is a function value.
value -- The value to round (Type: number money time)
/up -- Round away from 0
/floor -- Round towards the next more negative digit
/ceiling -- Round towards the next more positive digit
/truncate -- Remaining digits are unchanged. (a.k.a. down)
/places -- The number of decimal places to keep
pl -- (Type: integer)
/to-interval -- Round to the nearest multiple of interval
interval -- (Type: number money time)
The body of the routine is about 20 lines or so, which includes the handling
for all the refinements. Breaking it into separate FLOOR, CEILING, TRUNCATE,
and ROUND-UP (statistical rounding is the default) I would have 5 functions,
each with about 15 lines of code in their bodies, all *nearly* identical,
and nothing to tell you they're similar (except experience of course).
That said, this is currently the best example I have as an argument *for*
refinements. I haven't deployed a system that used them heavily and then
needed to be updated, and there are certainly valid arguments *against* them