Closed bdelespierre closed 3 years ago
I should think a little more about terms of clarity or performance. Regardless of clarity or performance, in my opinion there is no reason why points values should be mutable. Is there any reason to expose the function as public to change the values of points? I usually design as private unless there is a reason to make it public. Changing from private to public is easy. It's hard to go in reverse.
Is there any reason to expose the function as public to change the values of points?
None actually.
I usually design as private unless there is a reason to make it public.
That's good practice!
Let's make points immutables in the next version :+1:
To make Point immutable, we would just need to make the following method private:
https://github.com/bdelespierre/php-kmeans/blob/46e205156a92e1488edd06fc8e32ec30664a9467/src/Point.php#L27
Would it make sense for points to be immutable? Is there a way we benefit from this in terms of clarity or performance?
@battlecook what's your opinion on this?