Skip to content

UtilBase member functions do not need (some) parameters passed #9

@bjwyman

Description

@bjwyman

From a code review: https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-power/+/52148/2..4/phosphor-power-supply/power_supply.cpp#b178

@smccarney said:

There are a few issues with passing data members as parameters, such as:

  • Makes the code confusing. What is the value of parameter shortName vs. data member shortName? Why do both exist?
  • The parameter hides the data member in the method.

There are a few cases where it can make sense, but in general I think it is something to be avoided.

https://github.com/openbmc/phosphor-power/blob/master/phosphor-power-supply/util_base.hpp

https://github.com/openbmc/phosphor-power/blob/master/phosphor-power-supply/util.hpp

https://github.com/openbmc/phosphor-power/blob/master/phosphor-power-supply/test/mock.hpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions