Thursday, December 24, 2020

How to name a method.

Class Names and Method names are more important like the most programmer expect. If your software is longer then 30 lines, you should invest some time to find a good name. If you don't know what I'm speaking about, please read this book Clean Code.

If you look more into the naming topic, you will see that the amount of method names or name patterns are very limited. But on service level you find a vary amount of strange names. To avoid mixups, following the SQL query pattern for method names, eg. 

List <Product> getProductsByCostumerIdSortedByDateAsc(final String customerId) 

is a rely good understandable method name, the concern is clear, and the meaning of the method parameter is clear and the side effect (sorted) is also clear. 

No comments:

Post a Comment