Skip to content

Custom getters and setters #1006

Answered by akuleshov7
cldfzn asked this question in Q&A
Discussion options

You must be logged in to vote

We have described that case in https://github.com/cqfn/diKTat/blob/master/info/guide/diktat-coding-convention.md#-618-avoid-using-custom-getters-and-setters

we think that in case the developer needs some custom logic - he can create a new method with a proper name. In this case the logic is not confusing for the user of the library. If the user calls GETTER he expects simply to get the value without any side effects and complex computations.

BUT, you can always disable that rule in config or SUPPRESS using a @Supress annotation in code

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by akuleshov7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants