Language/Class Design Question of the Day

chromatic on 2008-01-27T05:03:52

How would your code look if your language had a maximum logical SLOC size for classes of 1024? (I like 2^10.)

What other features would your language need to support the types of programs you write if this constraint were in place?


I know this!

jhi on 2008-01-27T18:09:31

FORTH.

Re:I know this!

Aristotle on 2008-01-29T02:22:39

*wistful sigh*

Re: Language/Class Design Question of the Day

Adrian on 2008-01-27T21:15:47

"What other features would your language need to support the types of programs you write if this constraint were in place?"

<bitchy>Vaguely decent developers?</bitchy>

If you're not including documentation 1024 lines is a bloody long class in a language like Perl/Ruby/Lisp/Python. Refactor that sucker.

Re: Language/Class Design Question of the Day

Sidhekin on 2008-01-28T18:12:53

Oh. For each class?

... right. Carry on.

No different

drhyde on 2008-01-29T14:30:56

It would look pretty much the same, and so the language would need no changes. In fact all the .pm files in my CVS repository which are over 1000 lines (and that includes documentation) are either someone elses code that I bundle with mine for compatibility (cos the new release of DBM::Deep isn't portable enough for my tastes) or are mostly __DATA__ noise. The biggest objecty file that's all my own work is 381 lines including doco and is actually three classes.

But not all my code is OO, so it isn't all in classes. Until recently, I maintained a sprawling 8000 line program all in one file. OK, that includes documentation, but at a guess it's 5000 lines of code. While I did make a few changes during my time with the Maintenance Hat (added a couple of little bits of functionality, fixed some bugs) I was always itching to refactor it but never got the time. Part of the reason I didn't is because the test suite was nowhere near comprehensive enough.

The lack of good tests, incidentally, doesn't mean that the code is broken. It works really well and I don't think there are any outstanding bugs at all. Nor does it make it hard to find bugs when they're reported. But it does make refactoring hard and made certain types of changes hard to do.