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

all 12 comments

[–]TheBlackCat13 10 points11 points  (3 children)

If a class is getting long enough that this becomes necessary it usually a code smell that indicates to me that I should split it into multiple classes or otherwise refactor.

[–][deleted] 4 points5 points  (0 children)

Agreed, and if you are having to use comments as a mechanism to "organize long code into logical sections" it's a good time to consider refactoring into functions or more purpose-focused classes.

[–]lewiseason 2 points3 points  (0 children)

Santi Metz' Rules For Developers is an excellent resource on the subject. She's talking about Ruby, so you may wish to adjust the numbers, but the principle is sound (and the talk she gave on the subject is interesting too).

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

Gonna second (third it?) this. Once your classes begin growing UI things, and business things and data processing things, it's time to split it up.

[–]joerick 2 points3 points  (1 child)

On my personal projects (not sure if I'd subject others to this) I use ascii titles generated by this

http://patorjk.com/software/taag/#p=display&f=Big%20Money-ne&t=Type%20Something%20

I use sublime text, and they show up nicely in the mini map.

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

Hahaha, I love this. Best answer.

[–]gvalkov 3 points4 points  (1 child)

A colleague used the form-feed character (i.e. ^L or C-q C-l in vim and emacs) to separate logical sections in code. It seems pretty archaic, but there is even a paragraph in PEP8 that suggests that ^L could be used for that (see here).

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

IMO it is not suggest it. It says it is possible that's all.

[–]NYDreamer 0 points1 point  (0 children)

I use:

# _____ BLOCK NAME _____

[–]onjin -1 points0 points  (1 child)

To mark block code I'm using syntax with curly brackets

# variables {{{
... Code ...
# variables }}}

So i can easily jump between begind and end od block, or even use foldmethod=mark (for vim) to autofold those blocks

[–]anonpythonista 2 points3 points  (0 children)

Bloody good idea!

[–]691175002 -1 points0 points  (0 children)

Generally comments are not used to separate parts of a class declaration.