The Artima Developer Community
Sponsored Link

C# Answers Forum
c# design: accessiblity modifier

3 replies on 1 page. Most recent reply: Nov 29, 2004 7:04 PM by S. Lee Odegard

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
S. Lee Odegard

Posts: 2
Nickname: leeo
Registered: Mar, 2004

c# design: accessiblity modifier Posted: Mar 1, 2004 11:26 PM
Reply to this message Reply
Advertisement
One of the "accessibility modifiers" (public, private, protected, internal, ...) may prefix an attribute, method, indexer, constructor, etc. in a class definition. This is to provide a means to help to preserving an object's integrity by limiting general accessibility.

Has anyone but myself desired a finer-grained control than this form propagated from objective-C, C++, Java, C# or Delphi? It presumes the designer to know _a priori_ what every client within a particular scope will require.

Modula-3 provides for partial revelations, and with the introduction of __partial__ classes in c# (that is, classes defined from within more than one source file), perhaps a similar construct could be added to c#. What could we call a class that is a partial revelation of elements of a defining class? I proposed the moniker __port__ for "partial object revelation", but that may be a misleading term, though it does suggest a "portion" of the defining class. --S. Lee Odegard


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: c# design: accessiblity modifier Posted: Mar 5, 2004 4:02 PM
Reply to this message Reply
What problem does this solve?

And how is the partial access modifier resolved; that is what's the mechanism by which the acess is partially revealed to the subclass? How is that done in Modula-3?

Chris Dutton

Posts: 15
Nickname: cdutton
Registered: Jul, 2004

Re: c# design: accessiblity modifier Posted: Jul 21, 2004 7:14 PM
Reply to this message Reply
This sounds a bit like what's possible in Eiffel.

class FOO
feature { ANY }
-- roughly equivalent to public
feature { NONE }
-- roughly equivalent to private
feature { FOO }
-- roughly equivalent to protected,
-- depending on how you define "protected"
feature { BAR, BAZ }
-- only available to the BAR and BAZ classes
end[/code]

S. Lee Odegard

Posts: 2
Nickname: leeo
Registered: Mar, 2004

Re: c# design: accessiblity modifier Posted: Nov 29, 2004 7:04 PM
Reply to this message Reply
the "public" to "private" class accessibility modifiers has been my least favorite element of c++, java, and c#, since it forces every client to have the same view of the class. Consider that most "objects" in real live have multiple interaction experiences: for example an automobile has one for the driver, another for the passenger, and a third for the mechanic.

I have been experimenting with class presentations, which are alias types where only a named subset of the "public"ly accessible members of a class are available through the presentation. It is declared as an interface, only restating those elements in the class to be repackaged. This can be useful in determining the usage of a class in a scope for finding alternatives; This can be useful in enforcing access restraints.

One interesting question arised from this: why not just use interfaces? The presentation proposal is linked to exactly one specific class; an interface is a contract that can be fulfilled by any class. A presentation can instiantiate an instance of a class, since it is an alias (with some members hidden by not being named), which an interface cannot do. --Lee Odegard

Flat View: This topic has 3 replies on 1 page
Topic: XP Look-n-Feel for DataGridBoolColumn Previous Topic   Next Topic Topic: How to write an XML-RPC client and server in Java?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use