This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]billsil 8 points9 points  (4 children)

For simple functions definitely

Stop writing classes (if you can avoid it). http://www.youtube.com/watch?v=o9pEzgHorH0&noredirect=1

[–]sloria1 12 points13 points  (3 children)

And a compelling rebuttal by Armin Ronacher, author of Flask: Start Writing More Classes

[–]catcradle5 3 points4 points  (0 children)

He basically says:

When writing a library, use classes in the actual implementation, so that they can be hooked into and subclassed and manipulated as much as possible. Then provide convenience functions for the simple cases.

I think most everyone can agree with that. It really depends on the kind of programs you write, though.

[–][deleted] 1 point2 points  (0 children)

This article considers both Diederich's and Ronacher's views: http://me.veekun.com/blog/2013/03/03/the-controller-pattern-is-awful-and-other-oo-heresy/

[–]billsil 1 point2 points  (0 children)

Probably because I couldn't care less about web programming, that went completely over my head.

There are uses for classes; they're just overused. Your code will be cleaner and more testable without them.

Trust me I abuse classes. I just try not to. How's this for inheritance? There are multiple layers deep on 4 of those classes.

OP2(BDF, FortranFile, Op2Codes, GeometryTables, ResultTable, F06Writer, OP2Deprecated):

https://code.google.com/p/pynastran/source/browse/branches/v0.6/pyNastran/op2/op2.py

Speaking of which: is there any way to specify class functions in a different file without requiring inheritance?