tagged [encapsulation]

Cannot provide arguments when creating an instance of generic type

Cannot provide arguments when creating an instance of generic type I have an object that I want to have read only after it is created... namely because the properties in the constructor must be used i...

16 Dec at 21:16

Can There Be Private Extension Methods?

Can There Be Private Extension Methods? Let's say I have a need for a simple private helper method, and intuitively in the code it would make sense as an extension method. Is there any way to encapsul...

20 Mar at 08:43

C# Object reference not set to an instance of an object. Instantiating Class within a List?

C# Object reference not set to an instance of an object. Instantiating Class within a List? ``` public class OrderItem { public string ProductName { get; private set; } public decimal LatestPrice ...

Isn't there a point where encapsulation gets ridiculous?

Isn't there a point where encapsulation gets ridiculous? For my software development programming class we were supposed to make a "Feed Manager" type program for RSS feeds. Here is how I handled the i...

11 Nov at 02:17

Any reason to use auto-implemented properties over manual implemented properties?

Any reason to use auto-implemented properties over manual implemented properties? I understand the advantages of PROPERTIES over FIELDS, but I feel as though using AUTO-implemented properties over MAN...

14 Nov at 03:29

A very common C# pattern that breaks a very fundamental OOP principle

A very common C# pattern that breaks a very fundamental OOP principle Here is a very simple question, which I'm still very uneasy about: Why is it widely accepted now for a class to return a reference...

Pattern for Creating a Simple and Efficient Value type

Pattern for Creating a Simple and Efficient Value type In reading Mark Seemann’s blog on [Code Smell: Automatic Property](http://blog.ploeh.dk/2011/05/26/CodeSmellAutomaticProperty.aspx) he says near ...

Properties vs. Fields: Need help grasping the uses of Properties over Fields

Properties vs. Fields: Need help grasping the uses of Properties over Fields First off, I have read through a list of postings on this topic and I don't feel I have grasped properties because of what ...

18 Jun at 13:20

How abstraction and encapsulation differ?

How abstraction and encapsulation differ? I am preparing for an interview and decided to brush up my OOP concepts. There are hundreds of articles available, but it seems each describes them differentl...

23 May at 12:2

IEnumerable vs IReadonlyCollection vs ReadonlyCollection for exposing a list member

IEnumerable vs IReadonlyCollection vs ReadonlyCollection for exposing a list member I have spent quite a few hours pondering the subject of exposing list members. In a similar question to mine, Jon Sk...

18 Dec at 20:57

Prefer extension methods for encapsulation and reusability?

Prefer extension methods for encapsulation and reusability? In C++ programming, it's generally considered good practice to "prefer non-member non-friend functions" instead of instance methods. This h...

How to implement C# access modifiers in javascript?

How to implement C# access modifiers in javascript? - I tried to achieve inheritance and encapsulation properly in javascript like it was in a class-based language such as c#. The ugly part is the pro...