Comment topic function / method naming

The other day I was looking at American sign language ... and I noticed that building the language was a commentary topic. Like in "The weather is good." This made me think about why we call methods / functions as follows:

function getName() { ... } function setName(v) { ... } 

If we think about naming in a topic-comment function, the function names will be

 function nameGet() { ... } function nameSet() { ... } 

This might be better for a class having multiple goals. IE:

 class events { function ListAdd(); function ListDelete(); function ListGet(); function EventAdd(); function EventDelete(); function EventGet(); } 

Thus, the functions are grouped by "topic". If, as the previous name, the functions are grouped by Action-Noun, but sorted by noun.

I thought it was an interesting POV that other people think of function names / methods. Comment topic?

Obviously, confusing naming conventions in one project would be strange, but overall?

+4
source share
2 answers

Modern OOP methods should allow us not to indicate the topic of our function, but only the action, therefore for Ex.

The event class should only have add / delete / get, and you should have a separate Event_List class, which should also have add / delete / get.

therefore, depending on the language, it will be called event_obj.get() or event_obj.delete() ... etc.

like event_list_obj.add() etc.

This actually matches what you said about sign language, which is very good.

+1
source

I'm going to guess and say that your event class must have a List object that has an add, receive and delete along with its own add, receive and delete. I find this redundant when you see the class name repeated in its methods.

0
source

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


All Articles