You are viewing a single thread.
View all comments View context
8 points

I don’t have issue with methods being 200 lines, as long as they have a singel concept and is easy to follow.

permalink
report
parent
reply
6 points

If the method does a long thing, the keep it long. I do a lot of data analysis and simulation, and so often people who came before had this urge to shorten methods, so we get:

def do_calculation(N, X, y, z, a, b, c):
    # Setup stuff
    for i in range(N):
        calclation(X[i], y, z, a, b, c)`

Sometimes there’s a place for that, like if calculation could be swapped for a different function, or if calculation is used all over the program. It’s a pretty good clue that something is up though when the signatures are almost identical. Of course, that has just led to people writing:

def do_calculation(big_struct):
    read_data(big_struct)
    calculate(big_struct)
    write_data(big_struct)
permalink
report
parent
reply
2 points

There are various exceptions where up to 200 lines is still okay, yes. The 50 lines rule is more a good rule of thumb.

permalink
report
parent
reply

Programming

!programming@programming.dev

Create post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Community stats

  • 3.2K

    Monthly active users

  • 1.8K

    Posts

  • 30K

    Comments