I am new to B4A, got it on 2.0 and without classes it was going to be hard for me.
it is a good addition. I do understand that the nature of B4A is to be simple as possible, but I see that both simple and advanced could co-exist. For more advances bussines apps classes more elaborated are necessary. Hard to mantain the code without that.
Suggestions:
1 - Get and Set Properties
Class.Value is the member visible
SetValue and GetValue would be the real subs. It could be Automatic Named in the code we could declare one line only
Public Property Value As String Set "SetValue" Get "GetValue"
Sub SetValue(x as string)
end sub
Sub GetValue as string
End sub
2 - Basic Inheritance
That will open a door for expanding even more the classes created. It will be really useful if it permit inherit a class from a library. In this case the comunity created libraries could be expanded with no need to change the original.
example:
a new reserved word could be created at beginning of the class file:
Inherited <class module>
Sub Process_Globals
...
Then simple inheritance could be implemented based on the sub signatures. A new word "inherited" could be used in the sub context as a implicit "callsub" to the parents sub with the same signature
The subs from the parent's class that does not match with any sub will be exposed as part of the new created class. Eventually to make easy to implement at compile time the missing subs from the parents could be created as virtual subs with implicit call to the parent.
3 - an great addition would be sub overriding.
example:
SaveLog(x as string)
SaveLog(x as map)
since the 2 subs have different signature it would be different, the compile will choose according to the parameter passed.
4 - Enumaration:
example:
TDataSetState = (
dsInactive,
dsBrowse,
dsEdit,
dsInsert,
dsSetKey,
dsCalcFields,
dsFilter,
dsNewValue,
dsOldValue,
dsCurValue,
dsBlockRead,
dsInternalCalc,
dsOpening
);
it is a much better way than using variables as constants. That is internally mapped as int and each enumaration has a value starting from 0
These would be really great and valuable additions to me, I am giving it based on my backgroud experience, probably in visual basic way there are more compatible style. I am writing bussines applications that needs to have a lot of reused code. Compile to Library saved my life, but there are some situations that still hard to me.
Polymorphism is something needed, and Inheritance solves this situation. I am using the example of Polymorphism that is explained, but that is too simple, when it is needed that the parent class really introduces behavior and holds data, and the children expand that. For example:
Class DataSet
Class MemoryTable Inherit DataSet
Class SQLTable Inherit DataSet
The DataSet class generally defines the class interface, not implementing all the members (virtual subs) but some Subs are declared with functionality.
Children classes expand it, or commonly implement the virtual subs from the parent.
Then using the DataSet makes transparent who is the real children object.
I am certain that I am explaining the obvious...... sorry, got enthusiastic...
Eduardo
it is a good addition. I do understand that the nature of B4A is to be simple as possible, but I see that both simple and advanced could co-exist. For more advances bussines apps classes more elaborated are necessary. Hard to mantain the code without that.
Suggestions:
1 - Get and Set Properties
Class.Value is the member visible
SetValue and GetValue would be the real subs. It could be Automatic Named in the code we could declare one line only
Public Property Value As String Set "SetValue" Get "GetValue"
Sub SetValue(x as string)
end sub
Sub GetValue as string
End sub
2 - Basic Inheritance
That will open a door for expanding even more the classes created. It will be really useful if it permit inherit a class from a library. In this case the comunity created libraries could be expanded with no need to change the original.
example:
a new reserved word could be created at beginning of the class file:
Inherited <class module>
Sub Process_Globals
...
Then simple inheritance could be implemented based on the sub signatures. A new word "inherited" could be used in the sub context as a implicit "callsub" to the parents sub with the same signature
The subs from the parent's class that does not match with any sub will be exposed as part of the new created class. Eventually to make easy to implement at compile time the missing subs from the parents could be created as virtual subs with implicit call to the parent.
3 - an great addition would be sub overriding.
example:
SaveLog(x as string)
SaveLog(x as map)
since the 2 subs have different signature it would be different, the compile will choose according to the parameter passed.
4 - Enumaration:
example:
TDataSetState = (
dsInactive,
dsBrowse,
dsEdit,
dsInsert,
dsSetKey,
dsCalcFields,
dsFilter,
dsNewValue,
dsOldValue,
dsCurValue,
dsBlockRead,
dsInternalCalc,
dsOpening
);
it is a much better way than using variables as constants. That is internally mapped as int and each enumaration has a value starting from 0
These would be really great and valuable additions to me, I am giving it based on my backgroud experience, probably in visual basic way there are more compatible style. I am writing bussines applications that needs to have a lot of reused code. Compile to Library saved my life, but there are some situations that still hard to me.
Polymorphism is something needed, and Inheritance solves this situation. I am using the example of Polymorphism that is explained, but that is too simple, when it is needed that the parent class really introduces behavior and holds data, and the children expand that. For example:
Class DataSet
Class MemoryTable Inherit DataSet
Class SQLTable Inherit DataSet
The DataSet class generally defines the class interface, not implementing all the members (virtual subs) but some Subs are declared with functionality.
Children classes expand it, or commonly implement the virtual subs from the parent.
Then using the DataSet makes transparent who is the real children object.
I am certain that I am explaining the obvious...... sorry, got enthusiastic...
Eduardo