Number of lines in code editor

Hi,

What is the maximum number of lines that I can write in a method, so that compilation is possible?

Regards,
Payam

How would you even read that? I would try to break it up, it's much more readable and makes finding the source of NOE easier (among other benefits.)

rare time that I agree with Tim… when it gets to the point that this question is even concievable… its time to step back a refactor what you are doing.

here are my “commandments” for writing code…

First Rule: 
		The code must be READABLE
Preferable with copious comments, but the code should be as close to self explanatory as possible, this is not only for yourself, but for anyone else who in the future may have to work with the code.

Second Rule: 
		The code must be MAINTAINABLE
This should be done in such a way as to provide the minimum conflict with the First Rule.

Third Rule: 
		The code must be SCALABLE
This should be done in such a way as to provide the minimum conflict with the First or Second Rule.

Fourth Rule: 
The code should be EFFICIENT
This should be done in such a way as to provide the minimum conflict with all other rules.

and method or module where the numbers of lines encroaches on the IDE limit violates every one of these :slight_smile:

They sound familiar in structure … But shouldn’t there only be 3? :wink:

(an Asimov reference, for those who don’t get it)

  • Karen

I usually just say that you are not writing code for you right now, but you six months from now, and you six years from now. Developing a standard is a really good way of going about it so that future you knows what now you is thinking.

And judicious comments are helpful. That is all. :slight_smile:

Maybe it’s for autogenerated code, not something to be read by humans, the OP doesn’t say.

My guess is the limitation is just memory and time, ie not some hard coded artificial limit.

Could be tested by generating a million line method and seeing if it opens and the time to compile. Make several of different lengths and complexities and plot it out to what you need bounds around.

hummm. Are you thinking at a feature request: add line numbering in the code editor ?

[quote=320035:@Karen Atkocius]They sound familiar in structure … But shouldn’t there only be 3? :wink:

(an Asimov reference, for those who don’t get it)

  • Karen[/quote]
    Yes it is very "Asimov"ian… :slight_smile: and if you were up to date on the last of the series of books he had written… you would be aware that a 0th law had been added… “Will not harm Humanity…”… so there are in fact 4 laws of Robotics today :smiley:

So they are law #0, law #1, law #2 and law #3: you are both right ! :wink:

While that’s quite plausible, I have to say the only examples I know of entire production level apps being contained in one method are when I’m reading horror stores of people trying to outsource to “do-it-cheap” countries.

Years ago I had a method with a massive CASE statement with people’s names and it returned ‘male’ or ‘female’. It would malfunction (give weird errors or never return an answer) with over about 5000 names/lines. I have since put it into an SQLite database.

Here is a relevant old thread about this topic: https://forum.xojo.com/15000-method-is-too-long/9#p122948

Julen