State methods #62

Closed
opened 2020-07-22 01:11:06 +03:00 by jamesmyatt · 2 comments
jamesmyatt commented 2020-07-22 01:11:06 +03:00 (Migrated from github.com)

Why are the following methods all private:

  private:
    inline void changeState();
    inline void setStateFlag(const uint8_t flag)    {state |= flag;}
    inline void unsetStateFlag(const uint8_t flag)  {state &= ~flag;}
    inline void toggleStateFlag(const uint8_t flag) {state ^= flag;}
    inline bool getStateFlag(const uint8_t flag)    {return((state & flag) != 0);}

when the attribute that they concern is protected?

 protected:
    uint8_t state;

I'm not sure it makes sense to be more restrictive of the methods than the underlying attribute.

Why are the following methods all private: ``` private: inline void changeState(); inline void setStateFlag(const uint8_t flag) {state |= flag;} inline void unsetStateFlag(const uint8_t flag) {state &= ~flag;} inline void toggleStateFlag(const uint8_t flag) {state ^= flag;} inline bool getStateFlag(const uint8_t flag) {return((state & flag) != 0);} ``` when the attribute that they concern is protected? ``` protected: uint8_t state; ``` I'm not sure it makes sense to be more restrictive of the methods than the underlying attribute.
thomasfredericks commented 2020-07-24 17:04:05 +03:00 (Migrated from github.com)

This is just an oversight. I will look into this when I come back from vacation. I want to split the debouncing code from the hardware layer at the same time.

This is just an oversight. I will look into this when I come back from vacation. I want to split the debouncing code from the hardware layer at the same time.
thomasfredericks commented 2020-08-08 00:55:52 +03:00 (Migrated from github.com)

@jamesmyatt Those methods are private because they might change in the future. They are linked to space saving and not to the functioning of the algorithm. Anyways, I merged a lot of changes.

@jamesmyatt Those methods are private because they might change in the future. They are linked to space saving and not to the functioning of the algorithm. Anyways, I merged a lot of changes.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Max/thomasfredericks_Bounce2#62