Bad method names and what it says about code structure

(Apologizes in advance if this is a re-recording, but I did not find similar messages)

What bad method name templates you saw in the code and what he told you about the code.

For example, I continue to see:

public void preform___X___IfNecessary(...);

I think this is bad because operation X has an inverse of conditions. Note that this is a public method, as class methods may legally need private helpers such as

+3
source share
4 answers

Sometimes developers seem to have a problem using a short wording. I had the one who called the procedure

InsertImportQueueRecord

I hated is the name. I changed it to

ImportItem

, , . , , , - QueueItemImport ScheduleImport, , . , - , , .

+3

(), doThing() reallyDoThing()

, , . , , - , , . ?

. . , , . , , .

+2

, , , .

ValidateFormData_PersistToDB_SendEmail().

#, .

+1

, , :

private void SOMETHINGBecauseOf__a__(..);
private void SOMETHINGBecauseOf__b__(..);
private void SOMETHINGBecauseOf__c__(..);

, OfOf, . switch/if .

+1

Source: https://habr.com/ru/post/1746910/


All Articles