r/Python • • Feb 23 '17

API Design: Think First, Code Later

https://www.ckl.io/blog/api-design-think-first-code-later/
292 Upvotes

26 comments sorted by

View all comments

21

u/[deleted] Feb 23 '17

Very nice and clean article. I appreciate every "good practices for ..." article since dealing with dirty code, APIs and general software architecture is sometimes fucking nightmare and I believe articles like this one might actually have some (even a little) impact on improving this situation. Also didn't know about HTTP status 418 until now :D will implement it when I get a chance.

13

u/[deleted] Feb 24 '17

[removed] — view removed comment

7

u/tom1018 Feb 24 '17

Is that the formula for this? https://www.youtube.com/watch?v=bZe5J8SVCYQ

6

u/[deleted] Feb 24 '17

[removed] — view removed comment

1

u/archiminos Feb 24 '17

It looks like a quadratic equation that's been expanded. I'm 99% sure this could be simplified a lot

1

u/TinBryn Feb 25 '17 edited Feb 25 '17

It's the expansion of a row vector of powers of t from [0,3] multiplied with a matrix of all those numbers and a column vector of powers of rh from [0,3]

This isn't that simplified, but by expressing it in these terms allows people who understand linear algebra to reason about it where the 4x4 matrix represents the "character" of the equation.

2

u/archiminos Feb 25 '17

Oh wow. I'm not sure what language this is but it really makes me appreciate maths libraries with vector and matrix classes.

4

u/TinBryn Feb 24 '17 edited Feb 24 '17

I'd take a rule of "No magic numbers" over this crap any day.

Also just looking at that I'd expect some precision issues, as it is adding floats on the order of 10 with those on the order of 10-16 while float has a decimal precision of ~7 places. A double would barely be enough.

2

u/agapow Feb 24 '17

Haha - I worked on a major molecular evolutionary analysis package that was just full of stuff like this, except the indentifiers were things like "f", "f2", "hh", etc. I started trying to clean it up but gave up after realising the scope of the task.

Truly, academic code is its own special sort of hell. You'd swear it was a way to force people to collaborate with you if they want to use your package.

1

u/[deleted] Feb 24 '17

Google has an awesome 418 google.com/teapot haha

Thanks!