Abstract classes and Interfaces

Monkey Forums/Monkey Programming/Abstract classes and Interfaces

Samah(Posted 2012) [#1]
In my opinion, interfaces should not need to be implemented in an abstract class. They should simply be inherited as an abstract method. As it stands, you need to explicitly define the interface method in the abstract class (even if you only define the method as abstract).

Interface Foo
	Method SomeMethod:Void()
End

Class Bar Implements Foo Abstract
End

Class Test Extends Bar
	Method SomeMethod:Void()
		' method contents
	End
End

Function Main:Int()
	Local bar:Bar = New Test
	bar.SomeMethod() ' Error : Identifier 'SomeMethod' not found.
	Return 0
End



marksibly(Posted 2012) [#2]
Hi,

I quite like this idea, but unfortunately it looks like C# might not (see 2nd last post):

http://stackoverflow.com/questions/197893/why-an-abstract-class-implementing-an-interface-can-miss-the-declaration-impleme

Will have a look into it though.


Samah(Posted 2012) [#3]
Surely you could make trans silently add them?


therevills(Posted 2012) [#4]
Surely
Don't call Mark, Shirley! ;)




Samah(Posted 2012) [#5]
I knew that was coming...


marksibly(Posted 2012) [#6]
Hi,

Yes, but it's gone from being a 5 minute job to a semi-major one!

Anyway, moving this to programming for now...will think about it.