Functions in or out classes
in
Programming Questions
•
1 year ago
Depending on the "Learning Processing"-book, its better to have a function that tests the intersection of object INSIDE the class for that object.
Instead it seems more logic to me to have the function OUTSIDE any class, so you can call it for every object you like (not only to check if Ball Objects intersect, but also if other objects intersect).
Isn't this true?
Instead it seems more logic to me to have the function OUTSIDE any class, so you can call it for every object you like (not only to check if Ball Objects intersect, but also if other objects intersect).
Isn't this true?
Since we have programmed the balls in an object-oriented fashion, it is not terribly logical to suddenly have an intersect( ) function that lives outside of the ball class. A ball object should know how to test if it is intersecting another ball object.
1