Skip to main content
added 125 characters in body
Source Link
Christophe
  • 82.4k
  • 11
  • 138
  • 201

I have some class

MyClass

MyClass which has two methods:

Lock(){}

and

Unlock(){}

So far so good.

Because ofFor some reasons, the two methods are to be unified into one, with an additional parameter for indicating the action.

  What should be the name of the parameter?

SetLockState(bool isLock)

or

SetLockState(bool isLocked)
// or another better name? 

or other?


 

This happens a lot in our code base, and. I favor isLock, because it is the new state, but it seems there is some convention about isLocked which I am unfamiliar with, and.

I would love an explanation as to why isLocked is the standard. And I would like to know if there is any objective argument that can support the choice of the parameter name.

I have some class

MyClass

which has two methods:

Lock(){}

and

Unlock(){}

So far so good.

Because of reasons, the two methods are to be unified into one.

  What should be the name of the parameter?

SetLockState(bool isLock)

or

SetLockState(bool isLocked)

or other?


 

This happens a lot in our code base, and I favor isLock, because it is the new state, but it seems there is some convention about isLocked which I am unfamiliar with, and would love an explanation as to why isLocked is the standard.

I have some class MyClass which has two methods:

Lock(){}
Unlock(){}

For some reasons, the two methods are to be unified into one, with an additional parameter for indicating the action. What should be the name of the parameter?

SetLockState(bool isLock)
SetLockState(bool isLocked)
// or another better name? 

This happens a lot in our code base. I favor isLock, because it is the new state, but it seems there is some convention about isLocked which I am unfamiliar with.

I would love an explanation as to why isLocked is the standard. And I would like to know if there is any objective argument that can support the choice of the parameter name.

edited tags
Link
Christophe
  • 82.4k
  • 11
  • 138
  • 201
Source Link
Gulzar
  • 1.3k
  • 1
  • 9
  • 13

Naming conventions for set/unset method parameter

I have some class

MyClass

which has two methods:

Lock(){}

and

Unlock(){}

So far so good.

Because of reasons, the two methods are to be unified into one.

What should be the name of the parameter?

SetLockState(bool isLock)

or

SetLockState(bool isLocked)

or other?


This happens a lot in our code base, and I favor isLock, because it is the new state, but it seems there is some convention about isLocked which I am unfamiliar with, and would love an explanation as to why isLocked is the standard.