Re: [Gambas-user] OO design problem?

2016-08-31 Thread Fabien Bodard
The three way are :


Implemented in the base Class :

hChild.Function()


Implemented since a least the second inheritance level :
'hChild must be typed as Object
if hChild is SubTypeClass then hChld.Function


Totaly random :
'hChild must be typed as Object

Try hChild.Function
if Error then Error Subst("Warning: the function  \"Function\" is not
implemented in class &2",, Object.Type(hChild))

--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] OO design problem?

2016-08-30 Thread adamn...@gmail.com
On Mon, 29 Aug 2016 01:13:01 +0300
Jussi Lahtinen  wrote:

> > It's not unnecessary in fact. Imagine if a children not implement the
> > property... then it's the property in the parent that is readed.
> >
> 
> Yes I know, but in my case it is unnecessary.
> 
But if I understand you correctly then you should be implementing an 
Error.Raise in those empty methods to trap where a child class has not 
re-implemented the property!
> 
> 
> > Another way is to not declare the property in the parent and use an
> > object type to walk the children.
> >
> >
> > Dosometing(hChild as Myclass)
> >
> > dim hObj as Object = hChild
> >
> > try hObj.DoSomethingElse()
> >
> > end
> >
> 
> Thanks for the suggestion. Though, I hope something more elegant...
> 
> 
> 
> Jussi
> --
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user


And another use we have here for those "empty" methods is to implement a 
(hackish) trap to enforce a sort of protection i.e. the implementing child must 
be a particular object type. in other words to prevent say a client program 
calling the root method class directly.

-- 
B Bruen 

--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] OO design problem?

2016-08-30 Thread Christof Thalhofer
Am 30.08.2016 um 18:20 schrieb Fabien Bodard:

>> Yes, but in my case I also need corresponding private Variables,
>> which hold the data.

> I think this can be added but the problem is to manage anybody 
> variable calling.

Yes, I think this should not be done by default. Often a property value
is the result of a function. There it would be counterproductive.

> As Benoit does and years before i use to add type
> and range of a variable in it's name.
>
> But maybe others dev don't want that way...

To see the range via "$..." ist useful, but it should not be ruled by
the IDE.


Alles Gute

Christof Thalhofer

-- 
Dies ist keine Signatur

--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] OO design problem?

2016-08-30 Thread Fabien Bodard
2016-08-30 12:18 GMT+02:00 Christof Thalhofer :
> Am 29.08.2016 um 09:20 schrieb Fabien Bodard:
>
>> In the IDE if you write :
>>
>> Property MyProp As Integerand validate
>>
>>
>> The all the stuff (_Read, _Write) is automagiquely added at the end of the 
>> file
>>
>> You just have to validate at the end of the property declaration  line
>
> Yes, but in my case I also need corresponding private Variables, which
> hold the data.

I think this can be added but the problem is to manage anybody
variable calling.
As Benoit does and years before i use to add type and range of a
variable in it's name.

But maybe others dev don't want that way...

>
> Therefore I wrote the GS-creator for me as a simple tool because I have
> to create a lot of classes which represent rows of database tables as
> models for my own Gambas ORM.
>
> Even with the help of the Gambas IDE that job would cause a lot of pain
> in my hands ... ;-)
>
>
> Alles Gute
>
> Christof Thalhofer
>
> --
> Dies ist keine Signatur
>
> --
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user



-- 
Fabien Bodard

--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] OO design problem?

2016-08-30 Thread Christof Thalhofer
Am 29.08.2016 um 09:20 schrieb Fabien Bodard:

> In the IDE if you write :
> 
> Property MyProp As Integerand validate
> 
> 
> The all the stuff (_Read, _Write) is automagiquely added at the end of the 
> file
> 
> You just have to validate at the end of the property declaration  line

Yes, but in my case I also need corresponding private Variables, which
hold the data.

Therefore I wrote the GS-creator for me as a simple tool because I have
to create a lot of classes which represent rows of database tables as
models for my own Gambas ORM.

Even with the help of the Gambas IDE that job would cause a lot of pain
in my hands ... ;-)


Alles Gute

Christof Thalhofer

-- 
Dies ist keine Signatur

--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] OO design problem?

2016-08-29 Thread Jussi Lahtinen
On Mon, Aug 29, 2016 at 10:20 AM, Fabien Bodard  wrote:

> In the IDE if you write :
>
> Property MyProp As Integerand validate
>
>
> The all the stuff (_Read, _Write) is automagiquely added at the end of the
> file
>
> You just have to validate at the end of the property declaration  line
>


Yes, the trouble is not to get the empty properties, but the resulting mess
of a lot of code, which doesn't do anything.



Jussi
--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] OO design problem?

2016-08-29 Thread Fabien Bodard
2016-08-29 8:19 GMT+02:00 Christof Thalhofer :
> Am 28.08.2016 um 20:37 schrieb Jussi Lahtinen:
>
>> It's very likely that I have missed something and I have some crucial
>> design problem. So all suggestions are welcome!
>> Thanks!
>
> Hm, if I declare properties in a parent class I do this only for the
> correct work of methods, that depend on the existence of these
> properties in childs.
>
> If a child does not overwrite the property, it has to be fulfilled by
> the parent, so the property in the parent has to bedeclared with
>
> property_read() ...
>
> property_write() ...
>
> so that methods later work in a correct way. That is a logical
> consequence of the inheritance of properties.
>
> For the mess of writing such a thingy by hand all the time I wrote for
> me a little tool, the getter-setter-creator, it could be much better as
> it is (id does only string, integer, float and date), but it works for
> me. I attach it.


In the IDE if you write :

Property MyProp As Integerand validate


The all the stuff (_Read, _Write) is automagiquely added at the end of the file

You just have to validate at the end of the property declaration  line


>
>
> Alles Gute
>
> Christof Thalhofer
>
> --
> Dies ist keine Signatur
>
> --
>
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Fabien Bodard

--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] OO design problem?

2016-08-29 Thread Christof Thalhofer
Am 28.08.2016 um 20:37 schrieb Jussi Lahtinen:

> It's very likely that I have missed something and I have some crucial
> design problem. So all suggestions are welcome!
> Thanks!

Hm, if I declare properties in a parent class I do this only for the
correct work of methods, that depend on the existence of these
properties in childs.

If a child does not overwrite the property, it has to be fulfilled by
the parent, so the property in the parent has to bedeclared with

property_read() ...

property_write() ...

so that methods later work in a correct way. That is a logical
consequence of the inheritance of properties.

For the mess of writing such a thingy by hand all the time I wrote for
me a little tool, the getter-setter-creator, it could be much better as
it is (id does only string, integer, float and date), but it works for
me. I attach it.


Alles Gute

Christof Thalhofer

-- 
Dies ist keine Signatur


gshelper-0.0.6.tar.gz
Description: application/gzip
--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] OO design problem?

2016-08-28 Thread Jussi Lahtinen
> It's not unnecessary in fact. Imagine if a children not implement the
> property... then it's the property in the parent that is readed.
>

Yes I know, but in my case it is unnecessary.



> Another way is to not declare the property in the parent and use an
> object type to walk the children.
>
>
> Dosometing(hChild as Myclass)
>
> dim hObj as Object = hChild
>
> try hObj.DoSomethingElse()
>
> end
>

Thanks for the suggestion. Though, I hope something more elegant...



Jussi
--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] OO design problem?

2016-08-28 Thread Fabien Bodard
It's not unnecessary in fact. Imagine if a children not implement the
property... then it's the property in the parent that is readed.


Another way is to not declare the property in the parent and use an
object type to walk the children.


Dosometing(hChild as Myclass)

dim hObj as Object = hChild

try hObj.DoSomethingElse()

end



I use MyClass type in param to ensure to have a MyClass type passed.

Then i use an Object Var that allow a call to unknow symbole and a try
for manage the error if the symbol is not implemented.

By this way the property can be not implemented in the parent without
generating error. I use this to manage ReportControl... For exemple
ReportLabel have a Text property that is not implemented in
ReportControl.



2016-08-28 20:37 GMT+02:00 Jussi Lahtinen :
> I have class which is meant only to function as parent to other classes.
> This class have empty properties and methods, which are there only to be
> over-driven in the children classes. If I remove them I get error that the
> properties are not declared, and if I remove the properties from the parent
> I cannot use them when the object is passed as the parent.
>
> So, is it be possible to do this without declaring empty _read functions
> and _write subs?
>
> I want to be able to pass the objects like this:
>
> Sub DoSomething(hAnyChildrenOfThisClass As ThisClass)
>
>   x = hAnyChildrenOfThisClass.SomethingElse()
>   ...
>
> End
>
>
> Now the "SomethingElse" must be declared in "ThisClass" so that the
> children can have it and over-drive it with actual content.
> So, I'm looking a way to write only this:
>
> In ThisClass:
>
> Property SomethingElse  As Interger
>
>
> Instead of all this, which make a lot of unnecessary mess:
>
> Property SomethingElse  As Interger
>
>
> Private Function SomethingElse_Read() As Integer
>
>   Return 0
>
> End
>
> Private Sub SomethingElse_Write(Value As Integer)
>
> End
>
>
> It's very likely that I have missed something and I have some crucial
> design problem. So all suggestions are welcome!
> Thanks!
>
>
> Jussi
> --
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user



-- 
Fabien Bodard

--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] OO design problem?

2016-08-28 Thread Jussi Lahtinen
I have class which is meant only to function as parent to other classes.
This class have empty properties and methods, which are there only to be
over-driven in the children classes. If I remove them I get error that the
properties are not declared, and if I remove the properties from the parent
I cannot use them when the object is passed as the parent.

So, is it be possible to do this without declaring empty _read functions
and _write subs?

I want to be able to pass the objects like this:

Sub DoSomething(hAnyChildrenOfThisClass As ThisClass)

  x = hAnyChildrenOfThisClass.SomethingElse()
  ...

End


Now the "SomethingElse" must be declared in "ThisClass" so that the
children can have it and over-drive it with actual content.
So, I'm looking a way to write only this:

In ThisClass:

Property SomethingElse  As Interger


Instead of all this, which make a lot of unnecessary mess:

Property SomethingElse  As Interger


Private Function SomethingElse_Read() As Integer

  Return 0

End

Private Sub SomethingElse_Write(Value As Integer)

End


It's very likely that I have missed something and I have some crucial
design problem. So all suggestions are welcome!
Thanks!


Jussi
--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user