ITT: Solutions for the circle-ellipse problem

Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

You are currently reading a thread in /g/ - Technology

Thread images: 5

Anonymous

ITT: Solutions for the circle-ellipse problem 2016-01-26 05:56:25 Post No. 52627739

[Report] Image search: [iqdb] [SauceNao] [Google]

ITT: Solutions for the circle-ellipse problem 2016-01-26 05:56:25 Post No. 52627739

[Report] Image search: [iqdb] [SauceNao] [Google]

File: b1bdd27d-1ade-4190-b8df-8e8468a3f132..png (4 KB, 184x164)
Image search:
[iqdb]
[SauceNao]
[Google]

4 KB, 184x164

ITT: Solutions for the circle-ellipse problem
Anonymous
2016-01-26 05:56:25
Post No. 52627739
[Report]

I say we make circle and ellipse a specialized subclass of squares, but with bendy edges.

>>

>>52627739

https://en.wikipedia.org/wiki/Superellipse

>A superellipse, also known as a Lamé curve after Gabriel Lamé, is a geometric figure defined in the Cartesian coordinate system as the set of all points (x y) with (+ (expt (/ x a) n) (expt (/ y b) n)) where n, a and b are positive numbers

>[...]

>For n = 1 The curve is a rhombus with corners (±a, 0) and (0, ±b).

>[...]

>For n = 2 the curve is an ordinary ellipse (in particular, a circle if a = b).

[note by me] For n -> inf the curve tends to a rectangle with corners (±a, ±b) (in particular, a square if a = b).

Your new hierarchy would have:

Superellipse <|-- Rectangle

Rectangle <|-- Square

Superellipse <|-- Ellipse

Ellipse <|-- Circle

>>

>>52627882

Holy shit it works.

>>

what the actual fuck are you lads on about

>>

>>52627932

The circle-ellipse problem is a problem with OOP systems where a superclass has lass strict invariants than a subclass.

For example:

If you make circle a subclass of ellipse, how is setWidth and set height on the ellipse class applied to the circle class?

If you make ellipse a subclass of circle, how does the ellipse handle the circle invariant that height is always the same as width?

>>

>>52627739

Just don't have circles or squares.

In general just have it set so if you include 2 arguments draw a circle and if it includes 3 draw an ellipse.

>>

>>52627975

Setting the width sets the height too and vice versa. Boom.

>>

>>52628006

This is disgusting. Any methods written to handle ellipses that assume the invariant hold suddenly break.

>>

>>52628041

All solutions are inherently disgusting in some way or another. Deal with it.

>>

>>52628052

The whole point of the problem is that is a fanning example of why inheritance is shit. Using the "fuck it ship it" approach and ignoring the problem is missing the point.

>>

>>52628086

Whole procedure:

>fuck it

>ship it

>invoice it

>charge it

>dev it

>make(1) it

>sudo(8) it

>make(1)s us

>harder

>better

>faster

>stronger

>>

>>52628109

manigga

>>

>>52628134

Purists cry about rectangles and squares too. Circle-ellipse is just the common example.

>>

why don't people just do what you are supposed to do and not use inheritance?

>>

>>52628374

Better solution:

https://en.wikipedia.org/wiki/Circle-ellipse_problem#Change_the_programming_language

>literally using Common Lisp master race

>>

>>52628531

CLOS is God tier.

>>

>>52627739

>use private/protected inheritance

>implement set_radius(a:double):void using ellipse's methods

Done. You shouldn't use public inheritance here.

>>

>>52627739

>drop dynamic dispatch

>use type traits

done

>>

>>52628374

I use inheritance because I want to make use of specialization and generalization. Inheritance makes this very easy.

Thread images: 5

Thread DB ID: 482550

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.

This is a 4chan archive - all of the shown content originated from that site. This means that 4Archive shows their content, archived. If you need information for a Poster - contact them.

If a post contains personal/copyrighted/illegal content, then use the post's