-
Notifications
You must be signed in to change notification settings - Fork 926
How do you namespace methods when your Queries instances get too big? #2118
-
When a Queries
instance starts accruing a lot of methods, it becomes difficult to find the right one. Without some sort of a naming convention, it may easily turn into scrolling through all the methods every time.
I was wondering what conventions people are using to mitigate this issue. Go's idiomatic way of handling this would be to compose Queries
out of multiple smaller XXXQueries
instances - e.g. UserQueries
, OrderQueries
, etc. I know that this has been suggested in the past, but was not voted in favor of, so we are left to come up with a clever way of naming each method.
In one of our projects, er ended up prefixing the methods with the name of the table/entity they deal with:
User__UpdateAge
Order__Create
Order__MarkSold
I am aware that this type of naming is not really Go-idiomatic, but it has helped us somewhat with the glanceability.
What other conventions have people come up with?
Beta Was this translation helpful? Give feedback.