473,396 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

What does this mean? (nested abstracts...)

HAM
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...


Jul 21 '05 #1
5 1525
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...


Jul 21 '05 #2
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.

--
--- 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:e3*************@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...

Jul 21 '05 #3
HAM

"Nick Malik [Microsoft]" <ni*******@hotmail.nospam.com> wrote in message
news:Zu********************@comcast.com...
the code below is not legal. It doesn't make much sense either.
Well, any illegal code (except for logical bugs) must be trapped by the
compiler I guess...
Classes inherit interfaces.
By creating an interface that declares a class in it, what intent is the
programmer attempting to describe in the code?
I am not going to say that this is a good coding practice or not. However,
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
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.
you're right....
In this case, the Interface can simply refer to another interface for a
member method.
that's a nice idea, just maybe the nested naming of Interfaces could help to
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
syntax below.


I 'll tell this to my friend.
Thanks for the help anyway


Jul 21 '05 #4
HAM
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...)

"Brian Gideon" <br*********@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.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...


Jul 21 '05 #5
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:
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...)


Jul 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: HAM | last post by:
One of my friends asked if the followings have any meanings? '------------- Public Interface IRenderable Sub Render() MustInherit Class Engine MustOverride Sub TurnOn() Interface IAutomatic...
5
by: HAM | last post by:
One of my friends asked if the followings have any meanings? '------------- Public Interface IRenderable Sub Render() MustInherit Class Engine MustOverride Sub TurnOn() Interface IAutomatic...
52
by: Ben Voigt [C++ MVP] | last post by:
I get C:\Programming\LTM\devtools\UselessJunkForDissassembly\Class1.cs(360,27): error CS0535: 'UselessJunkForDissassembly.InvocableInternals' does not implement interface member...
123
by: plenty900 | last post by:
I was looking over someone's C++ code today and despite having written perfectly readable C++ code myself, the stuff I was looking at was worse than legalese. The people who are guiding the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.