|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
What does this mean? (nested abstracts...)'------------- Public Interface IRenderable Sub Render() MustInherit Class Engine MustOverride Sub TurnOn() Interface IAutomatic Sub Start() End Interface End Class End Interface Public Class RenderMan Inherits IRenderable.Engine Implements IRenderable, IRenderable.Engine.IAutomatic Public Sub Render() Implements IRenderable.Render 'Code for implementation End Sub Public Sub Start() Implements IRenderable.Engine.IAutomatic.Start 'Code for implementation End Sub Public Overrides Sub TurnOn() 'Code for implementation End Sub End Class '------------- Does this all comply with the specification of OOP? Just curious... It will not compile. Interfaces cannot declare types.
Brian HAM wrote: Show quoteHide quote > One of my friends asked if the followings have any meanings? > > '------------- > Public Interface IRenderable > Sub Render() > MustInherit Class Engine > MustOverride Sub TurnOn() > Interface IAutomatic > Sub Start() > End Interface > End Class > End Interface > > Public Class RenderMan > Inherits IRenderable.Engine > Implements IRenderable, IRenderable.Engine.IAutomatic > > Public Sub Render() Implements IRenderable.Render > 'Code for implementation > End Sub > > Public Sub Start() Implements IRenderable.Engine.IAutomatic.Start > 'Code for implementation > End Sub > > Public Overrides Sub TurnOn() > 'Code for implementation > End Sub > End Class > '------------- > > Does this all comply with the specification of OOP? Just curious... IT WILL! Try it for yourself in VS 2003....
(And probably it is better to look it up in the Object Browser...you'll see that there is no type in "IRenderable") (PS: Intellisense went wrong when i first entered the code into the text editor. Then, when i complied the class , everything went ok...) Show quoteHide quote "Brian Gideon" <briangid***@yahoo.com> wrote in message news:1113572536.042541.273490@g14g2000cwa.googlegroups.com... > It will not compile. Interfaces cannot declare types. > > Brian > > HAM wrote: >> One of my friends asked if the followings have any meanings? >> >> '------------- >> Public Interface IRenderable >> Sub Render() >> MustInherit Class Engine >> MustOverride Sub TurnOn() >> Interface IAutomatic >> Sub Start() >> End Interface >> End Class >> End Interface >> >> Public Class RenderMan >> Inherits IRenderable.Engine >> Implements IRenderable, IRenderable.Engine.IAutomatic >> >> Public Sub Render() Implements IRenderable.Render >> 'Code for implementation >> End Sub >> >> Public Sub Start() Implements IRenderable.Engine.IAutomatic.Start >> 'Code for implementation >> End Sub >> >> Public Overrides Sub TurnOn() >> 'Code for implementation >> End Sub >> End Class >> '------------- >> >> Does this all comply with the specification of OOP? Just curious... > You are correct. It does compile. I should be more careful about
assuming things about VB.NET based on my experiences with C#. Actually, Engine is nested inside the interface. You can verify that with ildasm. It is odd that it is legal in VB.NET, but not C#. It may have been part of an effort to avoid making C# unnecessarily complex. Brian HAM wrote: Show quoteHide quote > IT WILL! Try it for yourself in VS 2003.... > (And probably it is better to look it up in the Object Browser... > you'll see that there is no type in "IRenderable") > > (PS: Intellisense went wrong when i first entered the code into the > text editor. Then, when i complied the class , everything went > ok...) > Your friend is being very colorful and creative.
However, the code below is not legal. It doesn't make much sense either. Classes inherit interfaces. By creating an interface that declares a class in it, what intent is the programmer attempting to describe in the code? Is it the intent that the object which implement the interface must "have a" member class completely declared within them? Why not just define that a child class returns an object of a particular type from a member method? The same structural purpose would be served. In this case, the Interface can simply refer to another interface for a member method. This allows you to have composition without the byzantine declaration syntax below. -- Show quoteHide quote--- Nick Malik [Microsoft] MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik Disclaimer: Opinions expressed in this forum are my own, and not representative of my employer. I do not answer questions on behalf of my employer. I'm just a programmer helping programmers. -- "HAM" <hmdzxx5x@hotmaildotcom> wrote in message news:e3x36faQFHA.924@TK2MSFTNGP14.phx.gbl... > One of my friends asked if the followings have any meanings? > > '------------- > Public Interface IRenderable > Sub Render() > MustInherit Class Engine > MustOverride Sub TurnOn() > Interface IAutomatic > Sub Start() > End Interface > End Class > End Interface > > Public Class RenderMan > Inherits IRenderable.Engine > Implements IRenderable, IRenderable.Engine.IAutomatic > > Public Sub Render() Implements IRenderable.Render > 'Code for implementation > End Sub > > Public Sub Start() Implements IRenderable.Engine.IAutomatic.Start > 'Code for implementation > End Sub > > Public Overrides Sub TurnOn() > 'Code for implementation > End Sub > End Class > '------------- > > Does this all comply with the specification of OOP? Just curious... > > > > "Nick Malik [Microsoft]" <nickmalik@hotmail.nospam.com> wrote in message Well, any illegal code (except for logical bugs) must be trapped by thenews:ZuOdnQ9ymKxJTMLfRVn-gQ@comcast.com... >the code below is not legal. It doesn't make much sense either. compiler I guess... > Classes inherit interfaces. I am not going to say that this is a good coding practice or not. However,> By creating an interface that declares a class in it, what intent is the > programmer attempting to describe in the code? there is probably a way to know that If class "RenderMan" has inherited the "Engine" Class of the IRenerable Interface through "IRenderable.Engine" , it must also implement the IRenderable interface either. And why not declaring the whole methods of "IRenderable" in the "Engine" class in the first place? Probably because the "Render" method will be able to be implemented in classes that "Also" happen to have implemented from other interfaces, just one like "IRenderable.Engine.Automatic" .... > object which implement the interface must "have a" member class completely you're right....> declared within them? Why not just define that a child class returns an > object of a particular type from a member method? The same structural > purpose would be served. > In this case, the Interface can simply refer to another interface for a that's a nice idea, just maybe the nested naming of Interfaces could help to> member method. be more specific of where an interface come or sth.. I don't know!....Wow... I'm messing up... > This allows you to have composition without the byzantine declaration I 'll tell this to my friend.> syntax below. Thanks for the help anyway
sql Server not found
What happens to debugger here? Paging by example - help - still no luck.... Get processes list problem (win 2000) Reading an XML file into a Dataset - problem forecolor of button ??? Collection Type BindingManagerBase Problem Hide members in a derived class Good book about VB.NET ? |
|||||||||||||||||||||||