jschlyter / ttls

Twinkly Twinkly Little Star
Other
8 stars 6 forks source link

Question: Should this be a "thicker" client? #28

Open Olen opened 1 year ago

Olen commented 1 year ago

Currently, this is a very thin layer between the application and the API. We are basically not doing any validation of either input or output. We are blindly sending whatever the application give us, and just return whatever the API returns.

E.g. https://github.com/jschlyter/ttls/blob/a0e64e2326e16d35803ad2a0b7391fa5f3176daf/ttls/client.py#L262-L263

https://github.com/jschlyter/ttls/blob/a0e64e2326e16d35803ad2a0b7391fa5f3176daf/ttls/client.py#L300-L301

And

https://github.com/jschlyter/ttls/blob/a0e64e2326e16d35803ad2a0b7391fa5f3176daf/ttls/client.py#L289-L290

https://github.com/jschlyter/ttls/blob/a0e64e2326e16d35803ad2a0b7391fa5f3176daf/ttls/client.py#L271-L272

In some ways, that is fine. This makes ttls very simple and we probably do not need to make many changes even if the API changes somewhat. But in other ways, it makes a bigger burden for the applications to validate input and output, and all applications need to be updated if the API changes, instead of making the change only here in ttls.

So this is more of a design discussion than an issue. But something I wanted to raise.

Olen commented 1 year ago

29 and the later #32 validates all return values from the API.

Currently the user/client itself is responsible for validating what is sent to the device.