A good program is 500 lines or less.
Programs should be Small
11–20 of 75 posts
Re: Programs should be Small
#12A good program is 500 lines or less.
I type at least 60,000 characters before inserting a line break. I joke, but I've seen some php before that was at least 600 chars before line breaks, I have no idea how they wrote it like that.
Re: Programs should be Small
#13Solving complex problems in the physical world usually results in complexity in the source code world.
It is always overwhelming to jump into a new gigantic code base. Talk to someone who's been on it a while and they won't have the same drowning outlook.
Re: Programs should be Small
#14Re: Programs should be Small
#15A good program is 500 lines or less.
I'm not sure I agree. How about: "there's no such thing as a bad short program".
Re: Programs should be Small
#16The problem is that software has a tendency to become complex. The proposed solution is to break up the software into smaller programs. There are certainly advantages to having smaller components. It allows you to rewrite components in a different language should you want to, for example. But there are disadvantages to: smaller components means dealing with failure at a much finer granularity. In my opinion, the reas…
Re: Programs should be Small
#17A good program is 500 lines or less.
Wow, it seems rather arbitrary. Can you elaborate?
Pretty much all good code that I've read or written was compartmentalized into units of roughly 500 LOC. A big program may be composed of many such units, but it was almost always a bad sign when a divisible part would exceed the "magic" number.
What comprises a divisible part of course also varies by language; at the least it'd be the LOC-per-file, but usually it'd be a self-contained and separately tested module.
In a moment someone will probably come up with a great piece of software where this doesn't hold true, I'd actually be curious to see it.
Re: Programs should be Small
#18Re: Programs should be Small
#19The problem is that software has a tendency to become complex. The proposed solution is to break up the software into smaller programs. There are certainly advantages to having smaller components. It allows you to rewrite components in a different language should you want to, for example. But there are disadvantages to: smaller components means dealing with failure at a much finer granularity. In my opinion, the reas…
I am really curious why you see this as a disadvantage. At my current job, I've had the experience of moving from a relatively small backend system that was broken up into discrete message-passing parts to a larger frontend system that was mostly one monolithic project. The former was by far much easier to debug, despite it being much older, less sophisticated, and having less logging, simply because it was easier to isolate and reproduce problems. The queues also made it very easy for us to bring down, diagnose, or scale individual components as they ran in production.
I couldn't see this as anything but an advantage, and one that's well worth the added complexity once you pass a size threshold.
And sure you can just go cowboy and say "I'll make it simple anyway!," but firstly, interface-enforced simplicity is not the only reason you would go with queues and RPC (other reasons have been mentioned in the article or by myself), and secondly, it is much more difficult than you think to enforce such abstract common disciplines on a large project.
Re: Programs should be Small
#20Sometimes decomposition results in problems at the other end of the scale such as communication performance, data duplication, extremely nested abstractions, messaging complexity, contract and API versioning hell etc.
Getting the sweet spot between monolithic coupled blobs and fragmented latent deathtraps is an art which can't be puked out in a blog post. It takes literally years of experience and some guesswork and testing and thinking.
Ultimately, lots of small programs are just as painful as a single large one if they have to talk to each other or do IO.