Skip to main content

Timeline for Method naming: to vs as vs get

Current License: CC BY-SA 3.0

7 events
when toggle format what by license comment
May 3, 2020 at 12:04 comment added George Forman Good answers. And it can get murky if you've got a method that may have to dynamically decide whether to create a new object (of the desired type) or just a cast (such as returning a List from an Iterable object which happens to already be a List). This happens plenty in static factory methods. "from": You also see .from(Type) or especially if there are variant static factory/constructor methods that need to distinguish different meanings for parameters: .fromSlopeIntercept(double,double) and .fromRadiusAngle(double,double)
May 1, 2018 at 12:13 audit First posts
May 1, 2018 at 12:14
Apr 27, 2018 at 11:21 audit First posts
Apr 30, 2018 at 1:05
Apr 25, 2018 at 8:35 comment added Laiv Good enough. Looks like there's a sort of agreement around the premises you introduced. I gather this sort of "resources" for me to have some guidelines to follow during the development. Thank you!
Apr 25, 2018 at 8:26 comment added David Arno @Laiv, Having had a look, it may well be a convention that I've picked up over time. For example, looking at the link that Deduplicator provides in his comment to the question has answers that are all over the place.
Apr 25, 2018 at 6:31 comment added Laiv sometimes in in other words, It depends on the developer's ability to name things. So, no, they don't have special meaning but the one the developer had in mind. Your answer sounds a convention to me, and I like It, however I have never read it as a Java naming/style convention. Do you have any reference or link to share?
Apr 25, 2018 at 5:53 history answered David Arno CC BY-SA 3.0