Trendyol / ios-guidelines

125 stars 12 forks source link

Avoiding get in Function Names #71

Open beyzasgnms opened 3 months ago

beyzasgnms commented 3 months ago

A short summary of issue: Using get in function names can lead to ambiguity and reduce the clarity of the function’s purpose. It often doesn’t convey the full action or result expected from the function.

Reasoning and motivation: Using descriptive names instead of get helps to better communicate the function’s role and behavior. For instance, fetchUser() or retrieveUser() are more descriptive and suggest that some action beyond simply returning a value is being performed. This practice enhances code readability and maintainability, making it easier for developers to understand and work with the code.

Sources: I reviewed Airbnb and Kodeco style guides but couldn’t find an example of this guideline. However, it was included in our previous code style guide.

eyupgoymen commented 3 months ago

I agree, since "get" has several meanings, we should be selective for prefixes. We can also consider properties and computed properties besides functions, they should not have "get" prefix too imo.

aniltaskiran commented 3 months ago

Earlier version of this document has that logic. Actaully we choose it with team. I think existing rules should be stay. For example this one.

CleanShot 2024-08-02 at 12 08 54@2x

https://github.com/Trendyol/ios-guidelines/blob/b635320c45f40b8cd76ed4d0b18fc37a2ab84fe5/code_style_guideline/code_style_guideline.md#naming

aniltaskiran commented 3 months ago

By the way, if you removed everything from the previous rules, we will talk about these topics again. I think this will make us waste time. Like this issue, we already agreed on that :D

eyupgoymen commented 3 months ago

Since this rule was part of the previous guide and not existing in our guide, Workgroup will re-review existing rules by considering your comments next week and let you guys know about the action, thanks for your feedbacks 🙌🏻