This question: Naming Classes - How to avoid calling everything a "<WhatEver>Manager"? contains many examples of suffixes and prefixes that can be used to come up with precise name for your class.
What about methods? For example, how to name a method that should execute some action upon validation of some state - ExecuteIfSomething
, if we imagine that some transition in state should be executed after checking if something is true - ValidateTransition
(kind of ok, but reading it makes me think that it should just validate something - not additionally execute some action), TranslateUponValidation
?
Basically it would be very useful to have list of common parts that can be added to action/topic/... to describe method.
Here are some that I can come up with at the moment:
- Get
- Set
- Contains
- Add
- Remove
- Push
- Pop
- Clear
- Close
- Lock
- Open
- Unlock
- Enqueue
- Dequeue
- Activate
- Deactivate
- Translate
- Move
- Jump
- Fill
- Empty
- Draw
- Take
- Give
- Stash
- Group
- Shuffle
- Mix
- Sort
- Merge
- Inline
- Validate
- Check
- Execute
- Apply
- Compose
- Decompose
- Decay
- Break
- Gather
- Fuse
- Grow
- Rise
- Drop
- Fall
- Pick
- Select
- Accept
- Decline
- Retire
- Upgrade
- Degrade
- Increase
- Decrease
- Stop
- Continue
- Pause
- Resume
- Process
- Advance
- Create
- Destroy
Maybe, I have put too many of them.
As you can see now - many if not almost all verbs can be used depending on the situation. Using them or finding the matching one shouldn't be a problem. The problem is on how to combine them or use some of them to describe complex situations or complex executing sequence. The one I have described as an example is the most common one that I haven't found a good solution for. Personally I am interested in this particular one. But having some way/approach (not a formula like Object
+ Action
+ ...) to define/come up with method/function names can be very useful.
If people consider this question as too broad I will delete it. But main question here is how do you name a method as the one described in the example?
Aucun commentaire:
Enregistrer un commentaire