Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How do you namespace methods when your Queries instances get too big? #2118

Unanswered
preslavrachev asked this question in Q&A
Discussion options

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?

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /