Re: Encapsulation
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Thu, 29 May 2008 10:53:27 -0700
On Thu, 29 May 2008 02:41:57 -0700, Jon Harrop <jon@xxxxxxxxxxxxxxxxx> wrote:
I believe a lack of multiple inheritance means that cannot work in general
but the idiomatic C# workaround is to use interfaces however C# does not
yet support access modifiers in interfaces. Is that correct?
Technically, yes. But it's not clear what you mean. All interface
members are "public", but interfaces themselves need not be. You can use
the access modifier on the interface itself, nesting the interface as
appropriate, to control access to specific parts of a class.
I see. So you might need many separate interfaces for any given class.
I wouldn't think so. I mean, sure...if you have a very complex set of relationships between implementation and clients, with a variety of clients, each of whom have different accessibility to the implementation, that might require more than one interface. But it seems to me that as you enter that area of complexity, it's time to rethink the overall architecture. That's a _very_ unusual situation and IMHO will practically always be a sign of a larger issue that needs fixing.
That said, I already provided a reply to your most recent problem, showing
you how to solve it. At least for the extant example, it doesn't seem as
though having access modifiers within an interface would be needed or
useful in any case.
Perhaps it would be more concise?
More concise? I don't see how. Do you have an example of a C# syntax that uses access modifiers in an interface as an alternative to my proposal (simply adding the getter to the interface) in order to make a more concise declaration of the code?
Pete
.
- References:
- Encapsulation
- From: Jon Harrop
- Re: Encapsulation
- From: harborsparrow
- Re: Encapsulation
- From: Jon Harrop
- Re: Encapsulation
- From: Peter Duniho
- Re: Encapsulation
- From: Jon Harrop
- Encapsulation
- Prev by Date: Default.aspx.cs
- Next by Date: Re: .NET apps not being recognized as being in the Intranet Zone
- Previous by thread: Re: Encapsulation
- Next by thread: Refreshing Linq query to update second DataGridView when position in first DataGridView changes
- Index(es):
Relevant Pages
|