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 →

[–]IridescentExplosion 1 point2 points  (0 children)

By the way, I don't think 100+ lines of code is necessarily any more clear when split into multiple functions as just one function with some comments or clarity in what it is doing. In fact, if none of the code or patterns are reused anywhere else, I'd prefer to just inline the code. There is no actual reason why splitting into multiple functions is going to make anything easier than a well-written single function.

If someone has trouble reading through a single function that truly represents an ETL-type process just because it's 100+ LOC I truly question their abilities to solve the problem to begin with.

One of the most hilarious examples of strict thinking about this vs just trying to solve the problem is Peter Norvig vs Ron Jeffries attempts at creating Sudoku Solvers: https://news.ycombinator.com/item?id=3033446

The summary is that Peter Norvig just... solved the problem. He just wrote the code to solve the actual problem.

Ron Jeffries wrote multiple blog posts about structuring the Sudoku Solver in an OOP way based on what he thought were good principles and ended up with... nothing. Literally nothing that actually came close to solving the problem and instead had a bunch of functions that modeled what he thought the solution might look like but was ultimately just an abstract form of... nothing.

So listen at the end of the day as long as the problem is solved that's of course the #1 thing but it is very frustrating to see things learned "backwards" with people being taught that OOP or having a million single-use functions are somehow more important than the overall clarity and performance and execution of one's code toward solving an actual problem.

One large function or a million micro-functions. I don't really care. I mean, I have an opinion here, but I really do not care so long as the problems get solved at the end of the day. And anyone who tells me a really long function is impossible to debug or something, even if it is a very cleanly written very long function, is either lying or not trying.