Skip to content

API problem #73

@bucefal76

Description

@bucefal76

First of all, thank you for your effort with the library.

But I have found one issue. :)

An unclear and unexpected semantic coupling exists between pinMode() and begin().
The begin() will send no data on the I2C till pinMode is called at once.
I spend much time debugging my hardware for I2C issues because I did not notice that pinMode() must be set first.
Please note that usually people run the firmware from the most basic levers, so I2C check first, then check the IOs on the expander.

If you want to keep this:

// Check if there are pins to set low
if (writeMode > 0 || readMode > 0)
{

in begin()

I strongly advise returning an enum value from the begin(), not a bool.
Then you can differentiate different reasons for the begin() failure (including lack of proper initialization).

Regards!

Ps. You may find more about hidden semantic coupling in the Code Complete book by Steve McConnell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions