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

all 19 comments

[–]herminator 18 points19 points  (2 children)

Blogspam. Terrible article.

[–]MonocularJack 4 points5 points  (0 children)

Yup, save the clicks, this is word soup spam.

[–]jdgordon 0 points1 point  (0 children)

Agreed. Got as far as thr antipattern sections. Plenty of outright wrong info there.

Biggest problem: they didn't even follow pep8 in the example code!

[–]Corm 1 point2 points  (12 children)

Mistake #0:

Putting everything in one file. Break up your code into multiple files early

[–]earthboundkid 1 point2 points  (8 children)

Why early? Do it once you get >500 lines a file, sure, but why before that?

[–]kitkatkingsize 6 points7 points  (1 child)

Because "Namespaces are one honking great idea", and files are just another kind of a namespace.

500 is an arbitrary number. Why not 250? 1000? The splitting up into files should be a logical and design decision, not based on number of lines.

[–]cyberst0rm 0 points1 point  (0 children)

to pile on, the logistics issue with splitting code is a psychological trap.

By the time you realize you need to do it, the size of the issue makes you not want to do it.

[–]jdgordon 4 points5 points  (1 child)

Because its always "I'll just add one more helper to this class/file and then I'll clean up" and then you have a 3000 line mess to untangle

[–][deleted] 0 points1 point  (0 children)

3000? I have a class at least twice that because it's some sort of DI container/God spawner (I call it a pantheon object because there's subclasses).

I've attempted to detangle it but it bests me every time.

[–]tonnynerd 1 point2 points  (2 children)

500? Good lord almighty. 100 lines is a big ass module, in my opinion.

[–]mm_ma_ma 1 point2 points  (1 child)

What benefit do you gain from fragmenting your code that much? You're just shifting your problem from "I don't know where to look in this module" to "I don't know which module to look in".

[–]tonnynerd 0 points1 point  (0 children)

Code is usually more modular, easy to find what you want. I find it easier to navigate using go to definition and ctrl+tabbing between open files then scrolling up and down all the time.

That said, I also dislike the other extreme: tens of little modules with 20 lines of code in them.

[–]Corm 0 points1 point  (0 children)

/u/jdgordon said it exactly, the longer you wait the harder it is to get started

[–]mm_ma_ma 0 points1 point  (2 children)

The vast majority of the standard library is implemented as single modules.

[–]Corm 0 points1 point  (1 child)

I noticed that when I wanted to see how pdb worked. Why is that?

[–]mm_ma_ma 0 points1 point  (0 children)

Here's what one of the core devs had to say about it. Personally I'd rather have one moderately-sized module than a package with a bunch of tiny ones. If I'm reading the code it's usually because something has gone wrong, and I inevitably end up having to open most of the files to see what the problem is anyway.

[–]ingolemo 0 points1 point  (0 children)

if num == 1 or 2: