3 ms·
I wonder if the same stats apply to stateful versus stateless languages. I'm working a lot with PHP these days (not my favorite language) and for historical re
by neilk 18y ago
I wonder if the same stats apply to stateful versus stateless languages.
I'm working a lot with PHP these days (not my favorite language) and for historical reasons we even avoid the use of objects. I've noticed that even experienced practitioners in the PHP world write super-long functions. Forget 200 lines, more like 1000 or even 2000. When I try to refactor these, I usually find that I start causing worse problems, passing values around all over the place, using globals and so on.
It seems to me that if your language is relatively underpowered, a long method can help contain the messiness.
- randallsquared 18y agoSometimes there's a local minimum, where you really need to rethink the whole chunk you're working with to come up with a better design. If you're in this situation, which you can get to gradually, there's might be no easy way to refactor a piece at a time. But this isn't (ever in my experience, at least) because a super-length function is really the best solution, but because the design wasn't great in the first place.
- eru 18y agoWhen I last tinkered with PHP they did not have lexical scoping. That makes refactoring stuff out into separate functions a pain in the head.
- randallsquared 18y agoI dunno about 10 years ago, but for a long time now, you could just use a class to avoid globals and still keep some handy variables around. It's slightly painful (I came from Python, and I still end up typing $objectname.methodname() and then going back and putting in '->'), but not nearly so much as I used to think before I had to work with PHP every day. :)
- neilk 18y agoThey still don't. And, as I pointed out above, we don't even use classes. This might seem crazy, but this project was started before PHP had actually decent objects, and now all the special workarounds have become part of the house style. So I'm living in a world of pure procedural programming right now. It's the 70s again.
- deleted 18y ago[deleted]
- hedgehog 18y agoAny theories on why? I'm working on a PHP code base where some of the classes are 2500 or so lines and I find it quite puzzling.