I’m not sure to which Clean Code advice you’re thinking of, but indeed some languages (e.g. C++) allow to make a method (member function) const if it doesn’t change the state of the object itself.
This is useful to determine what method can be called if the object itself is const or passed as a const parameter. So, yes, it is a good practicegood practice to mark such functions as const, independently of any coding practice, even if they change state of other objects. (Not doing so would prevent you the safeguard against accidental by using const objects or parameters whenever possible).
By the way:
- If you want to make sure that other objects passed as parameter are not modified either, C++ provides you the possibility to mark as const
constthe reference parameters as well. (doing so whenever possible is a core guideline) - If you want to be sure that the method doesn’t change any other objects, avoid globals and make best use of encapsulation, in addition to marking parameters as const (if the language allows it).