Should an API provide Rect::contains(Point) or Point::is_inside(Rect) or both? or Math::contains(Point, Rect) cause it’s symmetric?
The same Q goes for LineSegment::contains(Point), Rect::fully_contains(Circle) etc.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Rect::contains(Point)makes most sense as it is a building block. The other is not really necessary as you would expect every specific shape to implement the operation, whereas thePointdoes not have to know about every possible shape. The same answer goes forLineSegment.Regarding the relation between
CircleandRectit is more tricky using most object oriented frameworks and does not have any definitive answer. Some other style of object oriented like CLOS do it by using generic functions and methods making it a non question.