Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 890025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:39:40+00:00 2026-05-15T13:39:40+00:00

I come from more of a C# background yet am learning Ruby in my

  • 0

I come from more of a C# background yet am learning Ruby in my spare time.

Given classes, it is possible to make their methods private, public (default) or protected. While I understand their usage, is it typical for Ruby code to make use of such modifiers, despite being a dynamic language, in which the user can easily override access?

While using something like Send allows the user access to private methods regardless, I was just wondering what the best practice is regarding Ruby and access modifiers? In other words, should I be making use of them in my classes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:39:41+00:00Added an answer on May 15, 2026 at 1:39 pm

    Given classes, it is possible to make their methods private, public (default) or protected. While I understand their usage, is it typical for Ruby code to make use of such modifiers, despite being a dynamic language, in which the user can easily override access?

    It’s still relatively common, because it conveys intent and minimizes the interface you’re exposing. Some conventions to observe:

    • Simply omit the public, since all methods are public unless you say otherwise, and methods are typically grouped by access modification.

    • Even though a user can override access, that doesn’t mean they should (in much the same way, you don’t see C# developers doing crazy things like injecting IL stubs into classes so that they can access private methods). So it’s still useful to have the distinction.

    • Protected methods are somewhat rarer than they would be in C#, because Ruby doesn’t really encourage inheritance as a means of passing on behavior. Common behavior can often be refactored into Modules and then include/extend-ed as necessary.

    • Private methods are about as common as in C#; Ruby often favors lots of tiny methods that do very specific things, which you then compose together to get something useful. But you don’t expose these methods, because they’re not part of your public interface and you want to keep that clutter-free.

    • Because private methods aren’t considered part of the interface, you should be free to change them with impunity. By making them private, you’ve put others on notice that these methods and their implementation or definitions could change at any time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I come from more of a Java background. In the last year or two,
I come from a mainly PHP background and make good use of the Apache
I come from classes object orientation languages and recently I have been learning those
I come from a mostly n-tier background, and I'm trying to move more towards
I come from a Java background, where packages are used, not namespaces. I'm used
I come from a CVS background. I'm currently investigating using SVN for a project.
I come from a background of MoM. I think I understand ESB conceptually. However,
I come from a Java background and with any servlets-based technology, it's trivial to
I come from a web-development background. I've been playing around with a bit of
I come from the Microsoft world (and I come in peace). I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.