Click here to Skip to main content
15,888,461 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: triplet or what ? Pin
Randor 31-Mar-19 8:34
professional Randor 31-Mar-19 8:34 
GeneralRe: triplet or what ? Pin
k505431-Mar-19 8:45
mvek505431-Mar-19 8:45 
GeneralRe: triplet or what ? Pin
Randor 31-Mar-19 9:04
professional Randor 31-Mar-19 9:04 
GeneralRe: triplet or what ? Pin
Vaclav_31-Mar-19 16:20
Vaclav_31-Mar-19 16:20 
GeneralRe: triplet or what ? Pin
Randor 31-Mar-19 17:21
professional Randor 31-Mar-19 17:21 
GeneralRe: triplet or what ? Pin
leon de boer1-Apr-19 0:49
leon de boer1-Apr-19 0:49 
QuestionCombination or inheritance Pin
元昊 潘31-Mar-19 5:04
元昊 潘31-Mar-19 5:04 
AnswerRe: Combination or inheritance Pin
leon de boer31-Mar-19 6:12
leon de boer31-Mar-19 6:12 
The question comes down to is distance fundemental to point or is it a function executed and that is up to how you intend to use it.
The general rule is function over inheritance and it's clearly covered by wikipedia

Composition over inheritance - Wikipedia[^]

If point has shapes that derive from it and distance is the closest point between the two shapes then we can provide a clear implementation of how it must work.

The only way to reconcile the closest point between two complex shapes will be to run each geometry (line,arc,spline etc) of each shape against the other shape or scanline the two shapes in a minimal box that includes both shapes. Either of those two processes will require these functions
1.) reset or seek so a geometry index will be the next out (seek_geometry(i))
2.) retrieve the next geometry from the shape (read_geometry(i))
3.) check if this geometry was last, if not back to 2 we go (check_geometry_end).

Essentially the geometry callback function(s) will be inherited from point but the distance will be another object because it will take two objects and run the process. Distance can then evolve to take a list of objects or different sorts of objects.

It is easy to see in that situation distance is not really a function of a shape it is a function between two shapes. However it could also be between a shape and something else such as a bounding box or grid or something yet to be thought of. So from a flexibility and reuse point of view you code for functionality and make point and distance two different objects.

In the simplest example it would make little difference but the functionality coding would make it easier to extend, reuse and more flexible. Ultimately you are more likely to reuse the more flexible code.
In vino veritas


modified 31-Mar-19 12:21pm.

SuggestionRe: Combination or inheritance Pin
David Crow1-Apr-19 3:31
David Crow1-Apr-19 3:31 
Questioni really need help with this Pin
Member 1420332729-Mar-19 5:13
Member 1420332729-Mar-19 5:13 
GeneralRe: i really need help with this Pin
Richard MacCutchan29-Mar-19 5:58
mveRichard MacCutchan29-Mar-19 5:58 
AnswerRe: i really need help with this Pin
Victor Nijegorodov29-Mar-19 6:43
Victor Nijegorodov29-Mar-19 6:43 
GeneralRe: i really need help with this Pin
Member 142033272-Apr-19 4:14
Member 142033272-Apr-19 4:14 
QuestionRe: i really need help with this Pin
David Crow29-Mar-19 9:24
David Crow29-Mar-19 9:24 
AnswerRe: i really need help with this Pin
Member 1420332730-Mar-19 3:52
Member 1420332730-Mar-19 3:52 
GeneralRe: i really need help with this Pin
k505430-Mar-19 4:48
mvek505430-Mar-19 4:48 
GeneralRe: i really need help with this Pin
Member 142033272-Apr-19 4:13
Member 142033272-Apr-19 4:13 
SuggestionRe: i really need help with this Pin
David Crow30-Mar-19 5:33
David Crow30-Mar-19 5:33 
AnswerRe: i really need help with this Pin
Gerry Schmitz29-Mar-19 10:40
mveGerry Schmitz29-Mar-19 10:40 
AnswerRe: i really need help with this Pin
Vaclav_1-Apr-19 15:43
Vaclav_1-Apr-19 15:43 
QuestionPutting declared const into a print statement Pin
SEmmett28-Mar-19 10:45
SEmmett28-Mar-19 10:45 
AnswerRe: Putting declared const into a print statement Pin
k505428-Mar-19 11:01
mvek505428-Mar-19 11:01 
AnswerRe: Putting declared const into a print statement Pin
CPallini28-Mar-19 11:06
mveCPallini28-Mar-19 11:06 
GeneralRe: Putting declared const into a print statement Pin
SEmmett28-Mar-19 11:34
SEmmett28-Mar-19 11:34 
GeneralRe: Putting declared const into a print statement Pin
k505428-Mar-19 12:01
mvek505428-Mar-19 12:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.