▲ 342 ▼ What are your programming hot takes? (lemmy.ml) submitted 3 years ago by 257m@lemmy.ml to c/programming@programming.dev 894 comments fedilink hide all child comments
[–] MaximumPower@lemmy.world 8 points 3 years ago (2 children) I don't have issue with methods being 200 lines, as long as they have a singel concept and is easy to follow. permalink fedilink source parent hideshow 4 child comments replies: [–] its_pizza@sopuli.xyz 6 points 3 years ago 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 fedilink source parent [–] phoenixz@lemmy.ca 2 points 3 years ago 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 fedilink source parent
[–] its_pizza@sopuli.xyz 6 points 3 years ago 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 fedilink source parent
[–] phoenixz@lemmy.ca 2 points 3 years ago 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 fedilink source parent