Abstract Interface vs Callbacks

BlitzMax Forums/BlitzMax Programming/Abstract Interface vs Callbacks

beanage(Posted 2010) [#1]
Well, this is really about polling opinions [not just yays and nays] to get a basis on which to make design decisions in future APIs and modules. But it's also always interesting to listen to the the individual experiences on these sort of design philosophy issues..

Thats basically what its all about:
Would you prefer this..
' that would be somewhere on API side

Type TColladaLoaderInterface Abstract

	Method CreateTriangle( object, x1, x2, x3, y1, y2, y3, z1, z2, z3 ) Abstract

	Method CreateObject( name, parent ) Abstract

'	Method ... Abstract

End Type

' that would be in your engine or application

Type TMyEngineColladaLoaderInterface Extends TColladaLoaderInterface
	
	Method CreateTriangle( object, x1, x2, x3, y1, y2, y3, z1, z2, z3 )
		MyEngine.CreateTri ...
	End Method

	Method CreateObject( name, parent )
		MyEngine.CreateObject ...
	End Method

End Type

... or this ...
' that would be somewhere on API side

Function initColladaLoader( tri_callback_:Int(object, x1, x2, x3, y1, y2, y3, z1, z2, z3), object_callback_:Int(name, parent) )
'	...
End Function

' that would be in your engine/application

Function CreateTriangle( object, x1, x2, x3, y1, y2, y3, z1, z2, z3 )
	MyEngine.CreateTri ...
End Function

Function CreateObject( name, parent )
	MyEngine.CreateObject ...
End Function

initColladaLoader CreateTriangle, CreateObject

...?


skn3(Posted 2010) [#2]
First please! I suspect you are going to have quite an indecisive response.


plash(Posted 2010) [#3]
^


beanage(Posted 2010) [#4]
First please!

Why?
I suspect you are going to have quite an indecisive response.

Me pretty much too! I fear that actually! But we are well so far :}


plash(Posted 2010) [#5]
Passing around function pointers is no fun. I also greatly dislike procedural programming.


Htbaa(Posted 2010) [#6]
And to add, callbacks are no fun in BlitzMax as BlitzMax doesn't support closures like Javascript, Perl or C# does.


skn3(Posted 2010) [#7]
Why?

Aside from the points mentioned above...

I find it easier/quicker to learn and remember the first method. It is generally easier to memorise and categorise functionality into their respective groups.


ima747(Posted 2010) [#8]
First for me as well, easy to understand for me that I just have to fill in a few blanks.


TaskMaster(Posted 2010) [#9]
I also like the first...


Jesse(Posted 2010) [#10]
I like the first too. I know that the Function to Method calls greatly deteriorate performance in some cases.


jsp(Posted 2010) [#11]
The first one... much better to maintain.


Kryzon(Posted 2010) [#12]
First one as well.

Isn't Collada not supposed to be used as the final extension? it's purpose is to allow easy communication between content creation applications, but the final format will be engine specific.