
Ruby Access Control - Are Private And Protected Methods Only A Guideline? - skorks
http://www.skorks.com/2010/04/ruby-access-control-are-private-and-protected-methods-only-a-guideline/
======
dan_sim
I was just writing a bit of code in javascript
([http://github.com/dsimard/jskataUndo/blob/master/jskataUndo....](http://github.com/dsimard/jskataUndo/blob/master/jskataUndo.js))
when I saw this post on HN. I was wondering "should I make some functions
private?" and the answer is "NO". Why would I do this? Is this because I don't
trust programmers? Why should I care if someone messes up with my "private"
things? It's his problem after all. If you look at the source, you'll see that
I have a private section at the end but it means "you don't need to use this
to make it work".

(note : there are some ways to make things private in javascript as I wrote
there : [http://www.javascriptkata.com/2009/09/23/how-to-create-an-
ob...](http://www.javascriptkata.com/2009/09/23/how-to-create-an-object-with-
private-variables-and-methods/))

------
epochwolf
tl;dr -> Ruby allows you to bypass private/protected by using Object#send

    
    
        class Object
          private 
          def name
            puts "Name called"
          end
        end
    
        o = Object.new
        o = o.send :name # outputs "Name called"
    

And therefore you can easily test private methods.

