I am creating a query builder class that will help in constructing a query for mongodb from URL params. I have never done much object oriented programming, or designed clas
While it's common for methods of an object to directly modify its state, it can sometimes be advantageous for an object to be its own "client", and access themselves indirectly through (typically) private access methods. In Python you can do this easily by creating using the built-in property() class/function.
Doing this provides better encapsulation and the benefits that follow from it (insulation from the implementation details being the major one). However doing so may be impractical because it would require too much additional code, and is often slower which might affect performance adversely an unacceptable amount — so trade-offs may often have to be/are made with respect to this ideal.