Solutions to Extremely.Long.Lines.of.Code.Scrolling.Off.The.Window

I was writing this line:

inputField.validation.maxValue.Substring(9,inputField.validation.maxValue.LastIndexOf(“}”,9,1))

and thinking there’s got to be a better way. This is an extremely long line of code and really it could be longer. On how many browsers is the line above wrapping around, because the screen isn’t wide enough.

What if the IDE did what the filesystem does for long file paths?

in…maxValue.Substring(9,in…maxValue.LastIndexOf(“}”,9,1))

Or God forbid we actually go back to Assembly language and use Macros, which are variable names that have meaning to the IDE and are translated before they reach the compiler. My idea is to have a list of Macro definitions so you are not using lines of code like variable declarations.

ifValid.max.Substring(9,ifValid.max.LastIndexOf(“}”,9,1))

This is something wholely within the IDE and for display purposes only. Let’s take advantage of some of these “Advanced” features or inheritance to spread the Macro. In the above inputField is inherited from something that has a maxValue. We provide a Macro to make all maxValues into max and inputField.validation into ifValid. This would necessarily be complex, because of the many possiblities of scope; namespace, class, function, inheritance, etc..

The first criticism of this is that it makes code unreadable. We’re going back to the bad old days of single character and cryptic variable names. I submit that we’re going to far with the object.collection.item.property.function().function(). The key difference between short variable names and these proposals it that the later is optional. click a button and you can see the full path. This isn’t a new idea. It’s been used in filesystems for decades.

The important thing is that you can quickly see what is important or unique about each line of code. Creating lines of code that scroll of the window due to their verbosity is contrary to this purpose.

Leave a Reply

You must be logged in to post a comment.