New access modifier: channeled<T> #9261
Unanswered
juanclopgar97
asked this question in
Language Ideas
Replies: 3 comments 13 replies
-
Looks like friend #2073 |
Beta Was this translation helpful? Give feedback.
2 replies
-
Any model to restrict accessibility should likely be implemented by custom analyzer. It will provide much more flexibility than the language itself. |
Beta Was this translation helpful? Give feedback.
11 replies
-
I just edit my entry to add an Event example (to have Property,Method and Event example) and how can be channeled<T> be used with a type (in that example is a class) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
OOP (Object Oriented Programming) tries to model data into objects..
C# enables to specify:
and every single one of this members can define its accesibility (Who can use that specific class member) with next access modifiers:
public
private
protected
internal
protected internal
private protected
However there are an special cases that are not being cover in any of the previous access modifiers, to ilustrate these cases I will provide an example:
Let's imagine a person, this person have a Name and everybody is able to ask for the name, however, change its name (set the name) should not be public or open to everybody, only a local courthouse should be able to do so, another example is the capacity of a person to tell its problems, but it is only going to do it with a psychologist.
On previous example there are valid properties and methods applicable to a person but they are only accesible to a PRIVILEGE GROUP.
channeled<T> access modifier would help to solve this issue:
Class member example
In the code block above is shown how channeled access modifier would work.
channeled<T> access modifier could declare multiple "T" types to enable multiple access authorizations:
And last but not less important as protected internal and private protected access modifiers are a "mix" of previous modifiers to enable an especial access case, channeled<T> could be combined with "private" or "protected" as follows:
Class (Type) example
Lets imagine a class with the *channeled<T> * modifier
This is not "atractive" or "new" behavior because can be accomplish with a nested private class, However now lets imagine a Recipient class
Now two classes are allowed to use Message type creating a way to communicate between them with a type they only can use, and this behavior is not possible with a nested private class
SUMMARY
channeled<T> access modifier will allow have more control and access over "who" can access specific Types/class members, increasing security in a way no other access modifier currently do.
Beta Was this translation helpful? Give feedback.
All reactions