Timeline for Naming of bool methods: Is vs. Can vs.?
Current License: CC BY-SA 3.0
38 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 14, 2021 at 20:57 | history | protected | gnat | ||
| Nov 13, 2021 at 8:30 | comment | added | Hartmut Braun | Has anybody else noticed how, over the years, this discussion has turned form „naming convention wars“ into a fruitful and respectful exchange of arguments as exemplified by this questions, it’s answers and it’s comments? | |
| Nov 13, 2021 at 6:05 | review | Close votes | |||
| Nov 20, 2021 at 3:06 | |||||
| Nov 13, 2021 at 0:14 | comment | added | davidbak | I prefer a trailing ?, or if that's not available, a trailing -p. (p for "predicate".) For benighted languages I use a prefix p or q. | |
| Nov 12, 2021 at 13:27 | answer | added | Islem | timeline score: 0 | |
| May 11, 2017 at 8:19 | comment | added | Stack Exchange Broke The Law | @megaflop He's gotta be onto something considering they've already cornered the synthetic market through superior engineering. | |
| May 10, 2017 at 20:20 | comment | added | Toby | IsContentTypeSupported? | |
| May 10, 2017 at 14:38 | comment | added | daiscog | @WeylandYutani I'd be far from delighted if you'd renamed a method I'd written to something so horrendous. | |
| May 10, 2017 at 14:37 | comment | added | daiscog | IsContentTypeSupported? | |
| May 10, 2017 at 14:12 | comment | added | leftaroundabout | Best practice for boolean-returning methods/functions is to not write them in the first place. | |
| May 10, 2017 at 13:43 | review | Suggested edits | |||
| May 10, 2017 at 16:37 | |||||
| May 10, 2017 at 13:40 | comment | added | Charles Duffy | Conventions vary by language, and I'm surprised not to see a tag. For instance, in many LISP-family languages, the standard way to specify that a function has a boolean is to have its name end in a ? -- so, (defn support-content-type? ...) | |
| May 10, 2017 at 13:36 | comment | added | R.M. | @WeylandYutani IsCanHasSupportCheezburger? | |
| May 10, 2017 at 12:40 | comment | added | Marco13 | The capital first letters suggest that this is about C#, but it may be worth mentioning that for Java, there is another important point to consider: The is prefix is assumed for Java Beans, and expected by the introspectors. So in Java, you should usually use is as the prefix for "getters for boolean values". | |
| May 10, 2017 at 12:06 | history | edited | Martin Ba | CC BY-SA 3.0 | edited title |
| May 10, 2017 at 12:00 | comment | added | Weyland Yutani | You can always use both. IsCanSupportContentType. I use both so that my code stands out. People know when I've been refactoring their code, they are delighted and I gain recognition. | |
| May 10, 2017 at 11:46 | history | edited | candied_orange | CC BY-SA 3.0 | deleted 1 character in body |
| May 10, 2017 at 10:39 | comment | added | JDługosz | You didn’t specify a language. Standards vary widely. | |
| May 10, 2017 at 10:07 | review | Suggested edits | |||
| May 10, 2017 at 11:44 | |||||
| May 10, 2017 at 9:27 | comment | added | Cody Gray | I agree with Olivier. SupportsContentType is the best choice. It is simpler, shorter, and reads better in a wider variety of statements. In general, when it's a toss-up like this, I look at how I expect the function to be called, and pick the one that ends up being the most readable with the surrounding code. The client of the library will either have to look it up or use IntelliSense anyway, so you might as well shoot for readability of the resulting code for future maintainers. | |
| May 10, 2017 at 9:12 | comment | added | Olivier Grégoire | What about simply supportsContentType? The following is entirely readable: if (abc.supportsContentType("text/html")). "can support" implies that there are further conditions to support the content-type. | |
| May 10, 2017 at 8:40 | comment | added | CodesInChaos | First one would have to be IsSupportedContentType to be grammatically correct. (unless "support content type" acts as a noun, which seems unlikely) | |
| May 10, 2017 at 8:07 | comment | added | Weckar E. | What kind of method are we even talking about? A getter type method or a query type method? Maybe a processing validation? | |
| May 10, 2017 at 5:31 | vote | accept | Mediator | ||
| May 10, 2017 at 4:58 | comment | added | Craig Tullis | @immibis That is a fair point. I find myself compelled to agree with you, without inheritance or polymorphism even needing to necessarily play a part. | |
| May 10, 2017 at 4:56 | comment | added | Craig Tullis | @RomanReiner That's already better grammar than more than one native speaker I know. :) | |
| May 10, 2017 at 4:50 | review | Close votes | |||
| May 16, 2017 at 3:07 | |||||
| May 10, 2017 at 4:37 | comment | added | Roman Reiner | Not a native speaker but wouldn't DoesSupportContentType be the most "grammatical" option? | |
| May 10, 2017 at 3:35 | answer | added | Harry | timeline score: 20 | |
| May 10, 2017 at 3:32 | history | tweeted | twitter.com/StackSoftEng/status/862148282784546818 | ||
| May 10, 2017 at 1:11 | comment | added | Stack Exchange Broke The Law | @Craig Unless the class is ContentType and some content types are support content types, of course - in which case IsSupportContentType would return true if the receiver is a support content type. But supported is a different word entirely. | |
| May 10, 2017 at 0:35 | comment | added | Craig Tullis | Since the intent is for the name to clearly convey state or behavior, and you would never say "this class is support content type X," the better name is CanSupportContentType. You would say something like "this class can support content type X." | |
| S May 9, 2017 at 22:56 | history | edited | candied_orange | CC BY-SA 3.0 | Simplified |
| S May 9, 2017 at 22:56 | history | suggested | Dan1701 | CC BY-SA 3.0 | Simplified |
| May 9, 2017 at 22:53 | answer | added | John Wu | timeline score: 136 | |
| May 9, 2017 at 22:46 | review | Suggested edits | |||
| S May 9, 2017 at 22:56 | |||||
| May 9, 2017 at 22:38 | review | First posts | |||
| May 17, 2017 at 21:51 | |||||
| May 9, 2017 at 22:35 | history | asked | Mediator | CC BY-SA 3.0 |