So from being a java/c++ developer for years I've been taught the importance of exposing well-defined save apis. You expose parts of your api that you think is safe for black-box users to incorporate and abstract/protect the rest. This is usually done by the visibility, security, and overriding features of the language.
For instance, if I have a method that I think its unsafe for any class, including sub-classes to call, I'll define it as private.
Ruby seems to think this isn't important. I can do this:
class Base
def aMethod
puts "A private method";
end
private :aMethod
end
class Derived
public :aMethod
end
In one line the sub class "Derived" was able to change the visibility of the method "aMethod". A little scary when trying to define things like data structure libraries and application frameworks that depend on the validity of certain methods.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment