3 ms·
> code diet . . . (limit of 10K lines) Yes, sort-of, although . . . A simple example 'in the small' to consider: function/procedure size. Should we (syntactic
by hxa7241 15y ago
> code diet . . . (limit of 10K lines)
Yes, sort-of, although . . .
A simple example 'in the small' to consider: function/procedure size. Should we (syntactically) limit functions to, say, <30 lines?
What we are really trying to do here is limit complexity. And that is not simply a result of length, but more of interrelation.
If we recall Dijkstra's intent with 'Structured Programming', it was to make complexity proportional to program length. It is not the total amount, but the way it is arranged or broken up. Strict size limits in effect sort-of do that -- they make complexity nearer constant (since it is bounded) within each part.
> should create a DSL at their particular level
And that leads to why the DSL idea (or something else to do a similar job) is more important than the simple limit idea. What we want primarily is different structuring.
In terms of the function-size example, we can (rather ideally) compare imperative with functional programming. FP languages seem to tend away from the length problem: because they are more trees of expressions instead of sequences. They have different structuring basics that control interrelation complexity more.
To put it briefly: we want it so you cannot add length without also adding 'depth' (of abstraction, of levels, of separation).
Expressed more fully here: 'Should there be hard limits on program part sizes?' http://www.hxa.name/notes/note-hxa7241-20101124T1927Z.html http://www.hxa.name/notes/note-hxa7241-20101124T1927Z.html
- DanielBMarkham 15y agoI agree. But I think you've missed it. My point was about human behavior, not the innards of program structure. To rephrase: would imposing arbitrary code length restrictions along with DSL-type training automatically drive programmers to write better quality code? I believe the answer is yes. You are correct in that the technical issue is more complicated than that, but my point was asking if making an arbitrary rule would drive teams into making those kinds of design choices, instead of just being happy with the way things were and continuing to expand the code base ad infinitum. I was trying to draw in several lines of thought I gleaned from the essay and synthesize something new. I also think there's a big difference in creating an arbitrary limit on function size and doing the same for an overall project. I wouldn't like the idea of limiting function size at all. You can do a lot in 10K lines of code. There's a lot more freedom there. Once again, my thrust is human behavior. Telling somebody that each little piece of code they write is subject to somewhat arbitrary restrictions is a lot more onerous to me than simply making a "budget" for the entire project.