Relative Content

Tag Archive for encapsulation

How far should I expose this status enum?

I wrote a little app to manage an arbitrary series of tasks (e.g., call a SQL sproc and capture out-vars, run another app, run an SSIS package) with dependencies between tasks. Each task has a status (waiting to start, failed and waiting to retry, failed and abandoned, succeeded, etc.). Internally, each Task object has a field of the TaskStatus enum type. There’s a TaskManager object which starts tasks and monitors their successes and failures, and a Dashboard WinForm which displays progress.

is ‘protected’ ever reasonable outside of virtual methods and destructors?

so, suppose you have some fields and methods marked protected (non-virtual). presumably, you did this because you didn’t mark them public because you don’t want some nincompoop to accidentally call them in the wrong order or pass in invalid parameters, or you don’t want people to rely on behaviour that you’re going to change later.

What should be allowed inside getters and setters?

I got into an interesting internet argument about getter and setter methods and encapsulation. Someone said that all they should do is an assignment (setters) or a variable access (getters) to keep them “pure” and ensure encapsulation.

How important is encapsulation? [duplicate]

This question already has answers here: When are Getters and Setters Justified? (14 answers) Closed 11 years ago. As a student in programming, I learned that encapsulation is one of the most important principles of object-oriented programming. However, I only follow that principle when I feel like it suits my purpose. I sometimes leave internal […]

Immutable vs mutable object as returned parameter for class method [closed]

It’s difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago. There is a class method (static method) in […]