Closed NeilBaner closed 3 years ago
In this particular example, I agree with you. There shouldn't be any case where a Notebook
is printing a title
of another Notebook
; that other Notebook
should call its own method, especially since the methods in question are private
, not public
. Perhaps if you are talking about public
methods using method 1 could be better.
Thanks for your input :) I think we'll go for method 1 then for now, because it's a bit cleaner too.
Suppose I have a class defined as follows:
Which of the two methods (1 or 2) is preferred for elegance and testability? @longngng argues that method 1 is better, because it makes the methods more general, and easier to test because they do not depend on the instance variables. I argue that method 2 is better, because in unit testing, we would have to instantiate the class anyway to test the methods, and using the parameters causes unnecessary redundancy and increased coupling.
Great day, everyone :D