Abstract Fields

BlitzMax Forums/BlitzMax Programming/Abstract Fields

beanage(Posted 2010) [#1]
Yeah.. "abstract fields". You know, like abstract methods, just for fields. Not that I needed that.. just interested..
- Is there a more professional name for those?
- Would they make sense as a feature?


Azathoth(Posted 2010) [#2]
I don't see a use for them. Abstract methods enforce the subclasses to have their own implementation, but abstract fields? Whats the point?

Edit: Abstract properties might make more sense if BlitzMax supported properties.


Czar Flavius(Posted 2010) [#3]
What would you replace an abstract integer field with? An integer field?


Htbaa(Posted 2010) [#4]
Abstract fields don't really make any sense to me. The only way I could see a use for them is in an ORM mapper library.

A bit like this:

Type TTable Abstract
Field tablename:String Abstract
End Type

Type TUserTable Extends TTable
Field tablename:String = "my_user_table"
End Type


Which is possible in PHP (Zend_Db_Table does this) and is quite handy, but not possible in BlitzMax. Other than that, I really don't know of any other uses. Which is probably why you don't see it in any other language?


Brucey(Posted 2010) [#5]
A bit like this

I still don't see that as at all useful.

Rather you do this :
Type TTable Abstract
    Method getName:String() Abstract
End Type

Type TUserTable Extends TTable
    Method getName:String()
        Return "my_user_table"
    End Method
End Type



Htbaa(Posted 2010) [#6]
That works too, although you still need to write a method for it.


Brucey(Posted 2010) [#7]
Indeed, but it makes more sense than an abstract field....

"I'm going to define an abstract class, which when you implement it, you need to also implement a field called 'blah" which is a String"

It's just not right.


Htbaa(Posted 2010) [#8]
Yes, and I agree :-).


beanage(Posted 2010) [#9]
Good, good, thanks guys! I think, yea, the only use would be some sort of enforcing a property or some kinda sorta abstract constant, which all can be, of yourse, faked with methods, which is propably why all the property stuff has not been implemented into max in the first place :)

Had me a somewhat more deeper look into "properties" at wiki tho, so it wasnt all pointless! Thanks!