[Gambas-user] Another basics

M. Cs. mohareve at ...626...
Fri Jan 6 16:55:03 CET 2012


Hello Fabien,
and I also think it would be nice to hear about how to keep the code
clean. I have to rewrite the things in order to have a program without
unfreed allocations.
What I intend to do is to use more private variables on modules and
well defined functions to access to them across the modules if needed.

2012/1/6, Fabien Bodard <gambas.fr at ...626...>:
> well :)
>
> i'm not a true professionnal of computing so words i use are not good.
> (and my english is really bad)
>
> In a class you have 3 time
>
> _Init
> Called only one time at the first use of the class
>
> _New
>  Called at each NEW instantiation
>
> _Free
>  Called when a classe is freed (when the ref to this class instance
> not stored anywhere)
>
>
>
>
> You can access a public var from anywhere but this var is linked to an
> instance
>
> If you use static public the var is accessible from the class name
> like with a module and not depend of an instance. (it allow for
> example to share a value between each instance of a class
>
> Private var is accessible ony from the sub of the current class
>
> static private can be used only from a static sub.
>
>
>
> I use public var for property that just store a value and can be
> accessed in read write mode
>
> i use property  for value that need controle or that generate an event
>
>
> for example
> dim $iX as private
> property X as integer
>
> Private X_Read() as Integer
> return  $iX
> end
>
> Private X_Write(Value as integer)
>   $iX = min(Value,100)  'max 100
>   RefreshDraw()   'redraw the object when the x is changed
> end
>
>
> You can use Property Read for a read only value
>
>
> this is some basis.....
>
> --
> Fabien Bodard
>
> ------------------------------------------------------------------------------
> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
> infrastructure or vast IT resources to deliver seamless, secure access to
> virtual desktops. With this all-in-one solution, easily deploy virtual
> desktops for less than the cost of PCs and save 60% on VDI infrastructure
> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>




More information about the User mailing list