Whether using the Repository pattern with an Interface or just implementing DataAccess methods in an application, I often see methods with either a 'Get' or 'Find' verb preceding the method description. I struggle a bit with differentiating between the (2), because I see conflicting examples when looking at DDD repository examples, or any other Architecture using a similar naming convention. For example take a look at the following:
Function FindAllEmployees() As List(Of Employee)
Function GetAllEmployees() As List(Of Employee)
Let's not look too closely at the subject of 'Employee', it is just an example; it could be anything. I am really interested if there are some guidelines on when to describe a method with a 'Get' vs. a 'Find' verb at the beginning.
Can anyone explain this or elaborate please? Thanks!
use "get" for a method which returns a cheaply available piece of information (and can probably be inlined or otherwise optimized away), or for a piece of information uniquely owned by this object. use "find" for a method which does work to get a piece of information, or uses other objects to find it.
Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized. Except for variables, all instance, class, and class constants are in mixed case with a lowercase first letter. Internal words start with capital letters.
I think fetch is usually more polite when requesting that somebody brings you something: "fetch me that book" is a request, whereas "get me that book" sounds like an order. Obtained can also be used to simply mean that you came into possession of something—not necessarily that you got it yourself.
To me, FindAllEmployees indicates that it might accept a predicate with which to filter the results, whereas GetAllEmployees would do just that, return the complete list.
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