Chat freely about anything...

User avatar
By kenn
#25654
datltq wrote:We call a method called 'connect' of the instance 'client'.
client.connect(host, httpPort) will return a value, if it is ZERO - indicate that it is failed by the one who programmed it, code in the block will run.

Bad code practice though, IMO


Just curious; why is the above a bad practice? It's common in alot of languages for a function to return true on success, false on failure.
User avatar
By kenn
#25699
eriksl wrote:He probably wants you to use exceptions. In most cases that is preferrable, but not always.


Then we get into the argument: is not connecting actually an exceptional condition (deserving of a try/catch and exception handling) or is not connecting a normal operating condition to be handled by some retries and after that we truly have an exception... :ugeek:

Also, this is a $4 wifi chip, not a multi-core commercial server. I'm just happy we're not writing assembly language. :D
User avatar
By eriksl
#25757 Yep (x2). Although some minimum level of code "maturity" might not be bad thing. At that point Espressif itself can learn a thing or two. Think e.g. of the include files.