To be more specific, how to name a method that may or not present a view to the user?
For example:
void maybeShowView() {
if (checkSomething()) {
presentViewToUser();
}
}
So maybeShowView is an awful name, also Im separating the maybe method from the presenting method for unit testing purposes, this way the maybe method can be unit tested properly.
In my team we have come up with names like
But this are really bad names
Any Ideas?
Thanks
note: I could create a boolean method shouldPresentView() but this would require me to check for it everytime I want to present my view, I dont want this.
Your best bet would be to include both the condition and what you will do in the name of the method. so, if your view will be shown when checkSomething() is true, you would call it like so:
void presentViewIfSomething() {
if (checkSomething()) {
presentViewToUser();
}
}
This will leave no doubt what the method actually does. The downside to this approach is, of course, that if you change the condition you'll also have to change the name of the method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With