Serving the Quantitative Finance Community

 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

circle-ellipse inheritance problem

February 16th, 2016, 4:09 pm

QuoteOriginally posted by: Traden4AlphaQuoteOriginally posted by: CuchulainnQuote Maybe OOP should be avoided until version 2.0 when the domain is sufficiently well understood for creating a valid class hierarchy.As I said, inheritance is optimization. But C++ developers use it to simulate interfaces (wrongly).BTW it might be good if you define OOP. Do you agree OOP = Classes + objects + Encapsulation + InheritanceObject-based == OOP - Inheritance.//There is a C++ blind spot here .. it does not support interfaces. So we have this C++ legacy problem and people have to use abstract base classes.Those definitions seem workable although some would also add message passing to the mix.Whether C++ implements one definition of OOP or another or just something that is OOP-like seems like more of a discussion for purists.Yes, message passing should be in there. OOP has a strict definition independently of its observers. And C++ OOP != C# OOP.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

circle-ellipse inheritance problem

February 16th, 2016, 4:13 pm

QuoteOriginally posted by: CuchulainnQuoteEllipses are not flattened circles when it comes to approximating the object with a set of OpenGL line segments or triangles.They are never flattened circles in any context!But an ellipse can be transformed to a circle, do things in circle space and then transform back to ellipse space in 2d CAD.Here's how we did it in optics. It's very clever. In s/w, we say Ellipse is an acquaintance class of Circle.This raises the interesting issue of round-off errors both at the level of it being impossible to get a true circle from an ellipse (i.e., the result of the transform is still an ellipse with an eps difference in major and minor diameters) and the precision diluting effects of the forward and backward transforms.Moreover, there's a great many different data structures that can define a circle or ellipse in terms of some mix of foci, radii, axes, bounding edges, etc. Depending on the application, different definitions have different round-off issues.Most of the time, one can ignore these issues, but..........
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

circle-ellipse inheritance problem

February 16th, 2016, 5:06 pm

Your link is broke. Remove s from https.here is taxonomy Now, which one is the one you use? Does it have a name?
Last edited by Cuchulainn on February 15th, 2016, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

circle-ellipse inheritance problem

February 16th, 2016, 8:08 pm

I know the answer; it's like little Endians and big Endiasns.
Last edited by Cuchulainn on February 15th, 2016, 11:00 pm, edited 1 time in total.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

circle-ellipse inheritance problem

February 16th, 2016, 8:16 pm

QuoteOriginally posted by: CuchulainnI know the answer; it's like little Endians and big Endiasns. ChickenEgg is a subclass of Egg????
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

circle-ellipse inheritance problem

February 16th, 2016, 8:20 pm

QuoteOriginally posted by: Traden4AlphaQuoteOriginally posted by: CuchulainnI know the answer; it's like little Endians and big Endiasns. ChickenEgg is a subclass of Egg????The more I think about it I realize that developers are deeply religious. And dogmatic.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

circle-ellipse inheritance problem

February 16th, 2016, 8:33 pm

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: Traden4AlphaQuoteOriginally posted by: CuchulainnI know the answer; it's like little Endians and big Endiasns. ChickenEgg is a subclass of Egg????The more I think about it I realize that developers are deeply religious. And dogmatic.That's inherited from the superclass!The more I think about it I realize that humans are deeply religious. And dogmatic.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

circle-ellipse inheritance problem

February 17th, 2016, 7:35 am

QuoteOriginally posted by: Traden4AlphaQuoteOriginally posted by: CuchulainnBTW any ideas on options;)What is the purpose of Option, CallOption, PutOption?I can imagine at least four very different data structure & behavior sets that might all be called "Option":1. Option pricer2. Option data storage (i.e., data + code for managing historical data on options)3. Option composition objects (i.e., a data structure & methods useful for constructing straddles, condors, etc.)4. Option contract model (i.e., text data structures and configuration code in which instances define complete and consistent bespoke/OTC contracts)No doubt, there are others.e.g.1. There are different ways to price an option(s) type(s).The big questions are:A. 1-4 is a mental model of 1 person; it may not be correct, complete or even solving what the client wants. And it can change in time.B. The impreciseneess of textual descriptions.There's no point communicating via text because it is context-sensitive and unstable. An no programming paradigm can resolve this problem.
Last edited by Cuchulainn on February 16th, 2016, 11:00 pm, edited 1 time in total.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

circle-ellipse inheritance problem

February 17th, 2016, 10:57 am

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: Traden4AlphaQuoteOriginally posted by: CuchulainnBTW any ideas on options;)What is the purpose of Option, CallOption, PutOption?I can imagine at least four very different data structure & behavior sets that might all be called "Option":1. Option pricer2. Option data storage (i.e., data + code for managing historical data on options)3. Option composition objects (i.e., a data structure & methods useful for constructing straddles, condors, etc.)4. Option contract model (i.e., text data structures and configuration code in which instances define complete and consistent bespoke/OTC contracts)No doubt, there are others.e.g.1. There are different ways to price an option(s) type(s).The big questions are:A. 1-4 is a mental model of 1 person; it may not be correct, complete or even solving what the client wants. And it can change in time.B. The impreciseneess of textual descriptions.There's no point communicating via text because it is context-sensitive and unstable. An no programming paradigm can resolve this problem.1-4 are four different systems that each have a class called "Option".Programming languages are also context-sensitive and unstable given the confluence of language versions, compiler versions, library versions, OS versions, hardware dependencies, and the occasional bout of DLL-hell. The worst part is deprecation by which formerly functioning code breaks.What % of Windows 95 applications still run today? What % of 1995 books are still readable today?I'd say code is much much worse than text.
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

circle-ellipse inheritance problem

February 17th, 2016, 6:23 pm

It's a stupid question, but your job is to make it into something that can be answered as though it made sense.Was this one of the dipshit questions that Resource Solutions/Robert Walter ask ?A good interviewer is largely uninterested in whether the answer is right, but the quality of the thinking that led you there. So when asked questions like this show how you decide what to do.Firstly of course, any class can inherit from any other, circle can inherit from potato, the question is does it make for better code ?The first part of an answer to that they clearly would have a base class in common, since most methods and properties you'd want are the same.You might want to talk about an abstract base class 'Shape'. This is a good way to gain the initiative in the interview. If you demonstrate that you know about abstract bases, you are talking in your comfort zone and will sound smarter. This is better than them asking about ABCs (or whatever) because they might ask something you don't know, or you my misunderstand the question (we've all done that), or indeed because you seem to have been interviewed by Resource Solutions, you may get a bad question and they may not understand your answer.One kind of IS-A relationship is that you implement one class using another, which applies to your correct point that a circle IS-A ellipse.There are cases where you'd want a circle to be treated differently, a good interviewer would be interested in your knowledge of them. Some graphics hardware can draw circles faster than ellipses and in some types of manufacturing process perfect circles are deprecated because they are harder to get out of the mould. In the case of a CAD package implementing circles it may post process the object you've designed to make it the circle just non-circular enough. The reason I include non-quant examples is that I'm too stupid to give a quant one (I'm just some headhunter) and part of class design is to think "how would this be used by other people ?"Another type of IS-A is specialisation, so a circle could be an ellipse where you chose to hide the eccentricity.In writing a drawing package, you'd want to allow the user to change radius, but not bug them with a superfluous control for eccentricity.
 
User avatar
Cuchulainn
Posts: 20252
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

circle-ellipse inheritance problem

February 17th, 2016, 6:51 pm

QuoteA good interviewer is largely uninterested in whether the answer is right, but the quality of the thinking that led you there. So when asked questions like this show how you decide what to do.And I suppose a good interviewee is able to accommodate multiple-solution scenarios?