Edit Hacks - view

Most text editors are capable of keeping multiple files open at the same time. What if, whenever a file was opened, a minimized version (in which "unnecessary" spaces and tabs have been removed) was also created and opened. The user could read or edit either version of the file, but only the normal version would be used for testing, distribution, etc.

Example

Let's start with a (nonsensical) example in Ruby:

Module Foo
  @foo = { bar:   42,    # foo[:bar] is 42
           baz:   43  }  # foo[:baz] is 43

  @bar = <<EOT
Melbourne      Australia
San Francisco  USA
EOT

  def bar(test)
    if (test)
      puts "Hello...    World"
    end
  end
end

A naive approach to minimization might turn all sequences of spaces into single spaces:

Module Foo
 @foo = { bar: 42, # foo[:bar] is 42
 baz: 43 } # foo[:baz] is 43

 @bar = <<EOT
Melbourne Australia
San Francisco USA
EOT

 def bar(test)
  if (test)
   puts "Hello... World"
  end
 end
end

Issues

We can predict assorted issues in appearance, functionality, readability, etc.

Appearance

Although edits in one view could propagate to the other on a continuous basis, changes to the minimized version might not result in the desired spacing in the normal version. So, after editing in the minimized view, the user might need to make some "clean up" edits in the normal view.

Functionality

Because the spacing in here documents and quoted strings has been modified, the functionality of the minified version would probably be affected. So, it might produce different results (or simply crash). Consequently, any testing should be performed on the normal version.

Language-sensitive minimization code could certainly be developed, based on parsing technology, but this would have to be done for each syntax the user wants to edit. This isn't all that difficult, in theory, but it could entail a lot of work and might still run into problems with domain-specific languages, embedded syntax, etc.

Readability

Programmers add spacing to source code to enhance its readability. So, removing these spaces can be expected to negate this effort. This is somewhat mitigated by the ability to alternate between views, using whichever one works best at the moment.

To be continued...


This wiki page is maintained by Rich Morin, an independent consultant specializing in software design, development, and documentation. Please feel free to email comments, inquiries, suggestions, etc!

Topic revision: r4 - 22 Jun 2016, RichMorin
This site is powered by Foswiki Copyright © by the contributing authors. All material on this wiki is the property of the contributing authors.
Foswiki version v2.1.6, Release Foswiki-2.1.6, Plugin API version 2.4
Ideas, requests, problems regarding CFCL Wiki? Send us email