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 713717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:59:32+00:00 2026-05-14T04:59:32+00:00

I recently read that getters/setters are evil and I have to say it makes

  • 0

I recently read that getters/setters are evil and I have to say it makes sense, yet when I started learning OOP one of the first things I learned was “Encapsulate your fields” so I learned to create class give it some fields, create getters, setters for them and create constructor where I initialize these fields. And every time some other class needs to manipulate this object (or for instance display it) I pass it the object and it manipulate it using getters/setters. I can see problems with this approach.

But how to do it right? For instance displaying/rendering object that is “data” class – let’s say Person, that has name and date of birth. Should the class have method for displaying the object where some Renderer would be passed as an argument? Wouldn’t that violate principle that class should have only one purpose (in this case store state) so it should not care about presentation of this object.

Can you suggest some good resources where best practices in OOP design are presented? I’m planning to start a project in my spare time and I want it to be my learning project in correct OOP design..

  • 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-14T04:59:32+00:00Added an answer on May 14, 2026 at 4:59 am

    Allen Holub made a big splash with “Why getter and setter methods are evil” back in 2003.

    It’s great that you’ve found and read the article. I admire anybody who’s learning and thinking critically about what they’re doing.

    But take Mr. Holub with a grain of salt.

    This is one view that got a lot of attention for its extreme position and the use of the word “evil”, but it hasn’t set the world on fire or been generally accepted as dogma.

    Look at C#: they actually added syntactic sugar to the language to make get/set operations easier to write. Either this confirms someone’s view of Microsoft as an evil empire or contradicts Mr. Holub’s statement.

    The fact is that people write objects so that clients can manipulate state. It doesn’t mean that every object written that way is wrong, evil, or unworkable.

    The extreme view is not practical.

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

Sidebar

Related Questions

Recently I have read that it makes sense when returning by value from a
I recently read about the fact that there is a possibility of defining getters/setters
I have recently read an article that said, that you should never trust user
I recently read these notes about SEO which say that you loose Google juice
I had recently read in a book that using the break statement in say
I recently read that making a class singleton makes it impossible to mock the
I recently read somewhere that one of ways of tuning SQL query is that
Recently I came to know about graph databases.I read that these databases have limited
I've read recently that iOS is message based. Is that similar to an event-based
I recently read in a presentation on Scribd that Facebook had benchmarked a variety

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.