Reasamp,

Yes, you should not duplicate code. If the code is going to be used in two different places, make it a function, that way, if there are bugs or improvements, they only have to be done in a single place.

Functions are also appropriate as a way to help document the code and make the algorithm as clean as possible. I suggest you read Fowler's book on /Refactoring/, http://www.amazon.com/exec/obidos/ASIN/0201485672, if you get the chance. Refactoring is something that most experienced programmers have always done, to some extent, just as a part of good programming practice, but Fowler discusses several excellent techniques and clarifies the risks and benefits involved.

Ray

P.S.: You should be able to find the book at any decent library, too.

Reasamp wrote:
Just found another very minor, related, issue
After I make the change Dan described just inside DocumentPane.setHTMLView of SimplyHTML, it misses the change when the HTML code panel opens first on clicking a node. Say if I OK a particular change while the HTML code window is open, and re-click on that node, the Editor opens with the HTML view still open - and with our tag stripping undone.

So I tried to take care of it by making adding the same code in DocumentPane.setDocumentText

      case VIEW_TAB_HTML:
*      if (!Util.preferenceIsTrue("writeHead","true"))
*        sText = sText.replaceAll("(?ims)<head>.*?(<body)","$1");
        sourceEditorpane.setText(sText);
        setHTMLChanged(true);

Or, in case with the heavier replaces suggested in my previous post, that code replaces this.

      case VIEW_TAB_HTML:
*      if (!Util.preferenceIsTrue("writeHead","true"))
* sText = sText.replaceAll("(?ims).*?<body.*?>\\s*(.*)</body.*","$1")
*                     .replaceAll("(?m)^ {0,4}","");
        sourceEditorpane.setText(sText);
        setHTMLChanged(true);

Maybe it's starting to look like the stripping code could be put into a separate function right? Maybe something like this?
public static String snip(String html) {
        return html.replaceAll...       // Whichever of the above code used
}

Reasamp

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Freemind-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemind-developer


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Freemind-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemind-developer

Reply via email to