Skip to content

Tag: oop

Can I improve this code to a more oriented OOP paradigm?

I am improving this code to a student, here is the image: So I rewrite this using list compreenssion and oriented to a formal class, so the second question is: Can I improve yet more this code? Answer Yes you can improve your code to be more “Object Oriented”. It doesn’t make sence that Alun…

how to pass variables to method

I want to pass variables to the method. which of the following is better? (x and y are constants) or: Answer I’d argue the second one is better with regards to function purity, though this is a principle of Functional Programming rather than Object Oriented Programming. The only thing I’d wonder t…

a simple way to produces classes with global state

Suppose I have a class, defined, for example, thus: Now, I want to create a class which is identical to testclass except I don’t want testclass’ state cl, but rather its own individual state. Experiment shows that inheriting from testclass inherits cl, so that does not work. Any words of wisdom ap…