> Instead of an unneeded abstract method, I'd rather get the same effect using > an internal constructor. > > public class BaseClass > { > internal BaseClass() > { > } > }
Or, in managed C++, the "private public" access specifier. The original post touches one interesting issue: providing an interface for an assembly's client (where "interface" means either real interface or a class) that assures that its implementation will be of a given type (often, coming from the assembly). For example, when someone needs to develop a package that uses interfaces but internally casts them to an assembly's private type (to allow for operations or access state that should not be seen by the client). This is often not elegant but greatly simplifies the package's overall interface. With classes, with the internal constructor, or the foo() approach, it is possible. Using interfaces is often a better choice, but the problem is that anyone could implement it. So I personally sometimes feel it would be cool to have "public internally implementable" interfaces. E.g., through adding a "constructor" notion to interface (just to mark the inheritance access): public interface IMySmartInterface { internal IMySmartInterface(); // must be always parameterless and cannot have implementation in implementing classes void DoSomething(); // common methods: always public } Of course, I am speculating only. Marek > Jim Gunkel > Nevrona Designs > > ----- Original Message ----- > From: "Ilya Ryzhenkov" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Saturday, April 10, 2004 2:27 AM > Subject: [ADVANCED-DOTNET] Public abstract classes with internal abstract > methods > > > > This was recently discovered locally, that it is allowed (without a > warning) > > to create class like this: > > > > public abstract class AbstractBase > > { > > internal abstract void foo(); > > } > > > > First, I thought it's a sort of bug. But after some thinking about the > > fact... This could be used to ensure all derived classes are in the same > > assembly, but base class is still usable from outside. Moreover, unlike > with > > interfaces, you ensure protocol and still don't allow anyone to implement > it > > outside of your package. Details here: > > http://www.silicontaiga.com/orangy/000032.html > > > > Any comments from the group? > > > > Sincerely yours, Ilya Ryzhenkov > > > > =================================== > > This list is hosted by DevelopMentorŪ http://www.develop.com > > Some .NET courses you may be interested in: > > > > NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles > > http://www.develop.com/courses/gaspdotnetls > > > > View archives and manage your subscription(s) at > http://discuss.develop.com > > > > =================================== > This list is hosted by DevelopMentorŪ http://www.develop.com > Some .NET courses you may be interested in: > > NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles > http://www.develop.com/courses/gaspdotnetls > > View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorŪ http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com