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

  • Home
  • SEARCH
  • 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 8536171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:36:04+00:00 2026-06-11T10:36:04+00:00

I came across an interface recently that only defined a setter like so: public

  • 0

I came across an interface recently that only defined a setter like so:

public interface IAggregationView
{
   DataTable SetSiteData { set; }
}

I queried this, and it is believed that this is one of the practices advocated by Microsoft for WebPart design (for SharePoint). In fact this example is directly copied from their examples.

I see this as a bad pattern, I don’t see why someone should be able to set a value, and then not be able to read it again, and I believe a setter should always be accompanied with a getter (but not necessarily the other way around).

I’m wondering if anyone can explain the benefit of only having a setter, why Microsoft might be suggesting it in this case, and if it’s really a good pattern to be following?

  • 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-06-11T10:36:05+00:00Added an answer on June 11, 2026 at 10:36 am

    There are two scenarios I can see where this might be reasonable:

    1. it is not possible get the value, for example a password; however, I would replace that with a void SetPassword(string) method, personally
    2. the API it is designed for has no requirement to ever read the value, and it is being restricted purely to expose the minimum required API

    Re my first point, a Set... method may not be ideal if the consuming API is essentially an automated mapper that assigns values to properties; in that scenario properties would indeed be preferable.

    Re your “I don’t see why someone should be able to set a value, and then not be able to read it again” – by the same point, however, it could be argued that someone setting the value already knows the value (they set it), so they have no requirement to do this.

    But yes; it is very unusual to have a set-only property.

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

Sidebar

Related Questions

I came across an interface that was defined as shown below: @interface UITableViewCell (XXXXXXXX)
I came across some code recently that used a custom error handler to turn
I recently came across an article by Matthew Weier O'Phinney (ZF project lead) that
I recently came across the situation where I wanted a set of classes to
I recently came across DUI (Diggs user interface) which implements jquery and gives you
Recently came across the HoverIntent plugin for jQuery. It acts like a regular mouseover
Recently I came across a piece of code wherein I found an interface with
Came across something like this today, and was wondering if there was an equivalent
I came across a piece of code which looks like this: jQuery(function($) { $('#saySomething').click(function()
Recently, I was reading 2 books and I came across with the following statements

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.