Too many lines of code -- use inherits?

I’m down to Line 6753 on a particular form script, and I may be only about 30 percent done for that form. It’s sort of a “home” form with many menu items and other options.

Would it make sense to inherit another form, which would be blank, but would provide another place in which to move some of the code? If I do that, do I need to do anything special, or will the calls from the form / form menus be able to execute as is?

Or would it be better to continue to accumulate more lines on the same script, knowing it might go up to, say, 20,000 lines?

Thank you,
Don

Hi Don,

It kind of depends what the code does. If I where you I would try to split up the code in different categories according to their scope and nature and move them to scope libraries. I don’t know if you are using Servoy 6.0 yet but the new scope levels of globals are prefect for defining seperate libraries of code. The trick is to make your code as generic as possible and to try and call the generic procedure where you pass in local specifics by parameter. As a rule of thumb a single piece of code ideally should not grow larger than 10-30 lines or you should identify chunks of functionality and split them up again. Over time this will give you several major advantages: readability, simplicity and reusability.

Of course this is not an exact science and everybody has his or her own ways of doing things. Hope this helps.

BTW, the 10-30 lines of code rule of thumb that Omar mentioned above is per function. I don’t think that you have written (or want to write) thousand of lines of code in a single function. You can have as many functions (methods) as you want in a single form.js file. They all can add up to the thousands of lines of code you are talking about, but still follow Omar’s advice and use the scope levels of globals.

BTW, If you are not in Servoy 6.x +, you should. And if you are going to migrate, install 6.1 since a lots of the 6.0 issues were solved. Also, Servoy 6.1 is an improved version of in 6.0.

Best, Carlos

Hi Omar and Juan Carlos,

I am using 6.0.7 at present. I tried 6.1 but many things seemed to be broken so I stayed back.

I googled “Servoy scope library” but didn’t turn up much. There is some mention of “Multiple TopLevel scopes” in the Servoy 6.1 “news in this release”, but I don’t see any explanation of how to make use of it.

Is there some documentation?

Thank you both for replying,
Don

Hi Don,

Top level scopes became available in Servoy 6.1 so you won’t find them in 6.0x.

[attachment=0]scopes.jpg[/attachment]

Normally, you only had globals to place application wide code in, but now you can create seperate libraries of code which allows clearer separation and organization of your code.

scopes.jpg

Hi Omar,

So if a method is located in the “core14” scope, the reference in another location would be to “core14.methodName()”?

Thanks,
Don

scopes.core14.methodName()