[Gambas-user] Request for advice

T Lee Davidson t.lee.davidson at gmail.com
Tue Jul 13 18:24:03 CEST 2021

On 7/13/21 11:29 AM, John Dovey wrote:
> What I’m not sure about is the right way to do it.

The "right" way to do it is whatever way works for you [and/or your user(s)] without causing undue issues for you, them, or the 
API server.

I admit that Bruce's conceptualization is a bit confusing at first glance and may actually be more complex than necessary for 
your project. However, I do understand his reasoning for the separate classes, ie. mainly future maintenance.

What I see in your project is you have separated the bot itself into two separate classes when it appears they should be one 
since they maintain properties, upon instantiation, for the same object. Also, if you are trying to follow Bruce's concept, the 
HTTP request functionality would be moved to its own module.

The tb_APIdef class is merely to encapsulate the various API methods and the API endpoint (URL) in a separate file for ease of 
maintenance should they change.

This is how I see the process working. The Main form (or module) is the manager. It creates, destroys, and manages any number of 
bots. When a bot is created, it should use the botMe method to establish its identity.

To do this, it would query the tb_APIdef class and receive a properly formatted request URL, for that specific method, which it 
would then pass to the tb_interface module for processing. The tb_interface module would then return the data retrieved from the 
API endpoint, and tb_BOT would then populate its properties accordingly. (That same process would be used for other 
queries/methods as well.)

I don't know what a chatphoto would be. But, if it is unique to a particular bot and does not have a multitude of required meta 
datum attached, then perhaps you could simply store it in a tb_BOT property and not bother with yet another class.


More information about the User mailing list