It doesn’t make sense to think about a maximum number of lines.<p>There may be a complex function of many variables which is not simplified by splitting into multiple functions.<p>Most often though, the code in a function has several logical parts which have their own temporary variables and are good candidates for splitting into separate functions.<p>Generally it makes sense to split code up so that it can be encapsulated at different levels. For example if you have a validation routine for a record, it may make sense to have different functions to test different properties, so that you can see which validations are being performed at a high level and then zoom in when you need to.<p>Encapsulation should be done to manage scope of temporary variables, and to make the code easier to read and to test. But there’s no hard and fast rule, really.