Encapsulation and Automatic properties in C# 3.0(lowendahl.net)

submitted by lowendahllowendahl(750) 4 years, 5 months ago

With C# 3.0 MS realeases Automatic Properties as a simplified encapsulation that generates getters and setters for a similary automated backing field. But is this really the way to go? Should you have dumb getters/setters or are you violating YAGNI when doing so? What are the rational behind MS decision to do so. This post address all thoose questions.

1 comment |category: |Views: 38

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by jessejesse(100) 4 years, 5 months ago 0

Author can't see the forest through the trees; so caught up in trying to show a "YAGNI violation" that he misses the simple convenience that automatic properties offer. FYI: a "YAGNI violation" is when your customers spec something simple and you create something monstrous which they end up not using anyway...thus, YAGNI. Also, a C# MVP who doesn't understand the binary difference between a field and property--what's up with that? If you even *think* you're going to use the setter and getter eventually, it's a hell of a lot easier to start with a property than to refactor a field into a property later on. Deploy some DLLs to customers and you'll understand what I mean.

Reply

information Login or create an account to comment on this story