public MyJSplitPane getMyJSplitPane() {
MyListener myListener;
MyArray[] myArray;
myArray = source1.getMyArray();
if (myJSplitPane == null) {
myListener = getMyListener();
myJSplitPane = new MyJSplitPane(myArray, myListener);
}
return myJSplitPane;
}
/**
* @return Returns the myListener.
*/
private MyListener getMyListener() {
MyJSplitPane myJSplitPane;
if (myListener == null) {
myJSplitPane = getMyJSplitPane();
myListener = new MyListener(source2, myJSplitPane, this);
}
return myListener;
}
20091221
Funny Programming Mistake
20080324
While and Comment Differences
I just thought I'd share what I thought about a couple of differences between JavaScript and VBScript.
Loop Difference
I think it's better that JavaScript doesn't have a do...until loop. The do...until loop seems kind of superfluous to me, since the same can easily be accomplished with a while loop. For example, these two are equivalent:
Do Until (x)
' do something
Loop
while (!x) {
// do something
}
Comments Difference
Notice the difference between the comments in the examples above. That was the other difference I wanted to mention. I tend to think that faster is better, and it's faster to type the single quote (') than it is to type 2 forward slashes (//). On the other hand, JavaScript provides for making part of a line a comment anywhere in the code, like this:
if (x /* == true */)
As you can see, the end parenthesis ")" comes after the comment. I don't know if VBScript provides any way of making comments like that. Does anybody else know?
20060210
3 digit for loop
var curr = -1; for (var n1 = 1; n1 >= 1 && curr == -1; --n1) { for (var n2 = 9; n2 >= 0 && curr == -1; --n2) { for (var n3 = 9; n3 >= 0 && curr == -1; --n3) { for (var n4 = 9; n4 >= 0 && curr == -1; --n4) { for (var n5 = 9; n5 >= 0 && curr == -1; --n5) { var version = "" + n1 + n2 + n3 + "_" + n4 + n5; try { var versioned = new ActiveXObject("JavaPlugin." + version); curr = new Number("" + n1 + n2 + n3); } catch (e) { continue; } } } } } }:-) :-) :-) Well, I thought it was funny.
20060131
Extreme Driving (XD)
If you've never heard of Extreme Programming (XP), you probably just won't get it. As a matter of fact, you might not get it anyway, but that's ok.
XD is a deliberate and disciplined approach to driving motor vehicles. If everybody just tries to drive whatever way, it will take longer to get anywhere, and there's more of a danger of a crash. That's why you must have and follow a driving methodology.
First of all, it's absolutely essential to have lots of "Call Up Meetings," which involve everybody calling and talk to each other on cellphones while driving. Never drive without them.
"Collective Mechanical Ownership" is another critically important concept of XD. It means that any driver must have access to change the mechanics in the vehicle at any time. So if one person wants to get in and rewire the starter, or another person decides to change the spark plugs, there doesn't have to be centralized oversight of all that.
And don't forget that you need to Unit Test every single step of the drive. The Unit Test consists of using a separate vehicle to attempt performing each action in advance, just to see if the performance of the action really results in the action being performed. For example, before turning left around a corner:
- Stop and exit the vehicle being driven.
- Enter and start the test vehicle.
- Perform the action of turning left around the corner.
- Verify that you have actually turned left around the corner.
- Stop and exit the test vehicle.
- Go back, re-enter, and restart the actual vehicle.
- Actually perform the real left turn, now that the action has been tested and you're sure it will be safe and efficient.
And last of all, at the heart of XD, is the principle of "Pair Steering". Pair Steering simply means that two different people have their hands on the steering wheel, steering the motor vehicle at the same time. This way, if one person makes a steering mistake, the other person, having more specific experience in that area of steering can correct it immediately. Also the steering gets done much faster when the workload is divided up and shared- the old "divide and conquer" strategy.
Thank you.
20051207
XML is Not a Database
XML is good- but only for some things. XML is very good at describing ordered lists, documents like they will be printed on paper, and simple trees, like family trees. For other things, XML is really bad. All other computer data with a more abstract nature has trouble conforming efficiently to the tree hierarchy of XML. Programs which use XML to describe and retrieve all kinds of data indiscriminately, suffer intense processing delays- particularly while attempting to traverse an ordered list to retrieve unordered data.
The strongest feature of XML is that it's very close to the ubiquitous HTML. It's easy for many people to learn about XML because they're used to HTML. Data described by XML can be transformed into HTML very easily.
XML works great to describe lists of items, like feeds of syndicated content for things like a news feed, stock quotes, or a series of audio or video episodes. It's great at describing outlines, with bigger sections broken down into smaller and smaller sections. It describes forms of data entry like control panels (buttons, sliders, and switches,) and parts of forms (like text entries, check boxes, and selections from a list of multiple choices.) Really it's pretty good for describing visual documents for direct human consumption, as they'll be printed on paper or displayed statically on a flat screen.
But it's for "documents," not for "data!" This is important because the data in XML documents will always be in a specific order. If it's about books, the books will either be listed by title, or by author. If you want to look up a book in the document, by title, when they're listed by author, you'll have to traverse all the authors looking at every title- unless you create some additional artificial layer cross-indexing the document. Easy you say- make two lists in the file that work both ways. But when you have a million books and also need the ability to search by ISBN, publisher, and copyright date, how efficient will that be? :-)
Don't panic. There's a solution which has been invented. Actually, this invention took place many years ago, and has been proved solid to many people through intensive usage. Have you ever heard of the Relational Database? Unlike the XML document, the Relational Database has been specifically designed to store and retrieve every type of data, for every usage imaginable. And it's super efficient, too. I hope you know SQL.
20051109
findmercy.com
- findmercy.com
- This is my own personal web site. If you'd like my web site to be your home page, please set your home page to findmercy.com . If you want to bookmark my web site, please be sure that your bookmark is set to findmercy.com .
- i.findmercy.com
- This is the web site of my computer program business. This is where you can work on good programs and other files for computers. Please consider adding i.findmercy.com to your bookmarks.
20050419
A Window Into My Work Day
WARNING: Highly technical stuff ahead. Do not proceed without a pocket protector.
Here's a good puzzle for you. How do you use a literal quotation mark in quoted XML text in a string wrapped by the same kind of quotation mark in an XPath query?
If you say:
comments[text()="There's a 48" door."]
The quotation mark after the 48 ends the text quotation, and the final part of the string (" door.",) is unexpected, and causes a syntax error. Simple enough so far, right?
A literal quotation mark in an XPath string is NOT automatically escaped to it's character entity to indicate a literal quotation mark. Instead, it's naturally used as part of the XPath code, to break the XPath string.
Your first impulse might be to switch quotation mark types. I disdain the switching of quotation mark types. In my opinion, the double quotation mark should always be used to indicate a string quotation, and if it must be escaped, it should be escaped. Some people prefer to use the alternative single quotation mark, but as I'll demonstrate, that doesn't really get you anywhere. It generally just makes things more complicated. Consider our example.
To solve my problem, you might try changing the query to:
comments[text()='There's a 48" door.']
This was a great thought, because now the double quotation mark in the quoted text won't be used to terminate the XPath string, like it was before. Astute observers, however will instantly discover another problem. The single quotation mark, used in our example for an apostrophe, WILL terminate the string, which is now wrapped in single quotation marks, and we're back at square one.
Switching between wrapping a string in double and single quotation marks, doesn't solve the problem of how to indicating that a double or single quotation mark is to be taken as a literal part of the string, instead of as a string terminator.
No problem, I told myself. I'll just use the special XML character entities to escape the literal quotation marks. XML defines two character entities to indicate that a quotation mark is a literal part of the string instead of a string terminator. The entities are " for a double quote, and ' for a single quote.
So I fixed my query like this:
comments[text()="There's a 48" door."]
I thought that XPath string should now literally contain my quotation marks. But then I was really shocked. I don't know whether this is an error with my XPath implementation, or what, but now the real fun begins.
Naturally, XPath assumed I couldn't possibly be wanting to put a literal ampersand character in the string, and start an entity. What? How am I supposed to indicate an entity within an XPath string? XPath promptly converted the ampersands to the XML character entity for literal ampersands, &.
The query, of course, only matches strings that actually look like this:
There's a 48" door.
I wonder why it took me so long to realize this now obvious rule:
Ampersands, along with less than, and greater than symbols, ARE automatically converted to their literal character entities when used within XPath strings, because XPath queries themselves are XML strings.
Wow. Doesn't this present a blissfully fun, uniquely challenging puzzle? This is the kind of thing we programmers really like.
Two ideas immediately hit me to solve this problem. First, I figured, why not just double-escape the quotation marks by escaping the characters in the escape sequence?
Now my query starts out like this:
comments[text()="There's a 48" door."]
We're getting in deeper!
When the query is converted into an XML string, I assume it will come out like this:
comments[text()="There's a 48" door."]
When the XPath string is actually processed as part of the XPath, I assume the new ampersands will be converted back to real literal ampersands in the query itself:
comments[text()="There's a 48" door."]
And then the ampersands in the string will indicate literal ampersands to the query processor, like this:
comments[text()="There's a 48" door."]
And the query processor will process the string as an XML string when it's querying the XML, so the entities will be un-escaped again, and match text like this:
There's a 48" door.
Which is what I wanted all along. But, I was wrong again. The selectNodes and selectSingleNode DOM methods don't use XML strings, so it still doesn't work.
Another idea I've had to far is that maybe one of the processing layers will skip numeric character code entities, instead of treating them the same as the named character entities, and so I'll be able to indicate literal
quotation marks using the character code numbers in numeric XML entities. How would that work?
How about if I catted the entity together, like this:
concat("&nb","sp;")
Would that help? What would that do?
Otherwise, the thing left that I can think of to do is to put the XPath string in it's own node or param/variable, and refer to the variable/param/node from
the XPath. But how do I use a variable with the selectSingleNode method?
I found out that somebody else had the same problem.
Just a little thinking out-loud, and a little window into the world I work in all day.
Oh, uh- did I mention what Blogger does when you try to put all these escape characters and escape codes for escape characters, and everything, in your blog? Let's just say it adds even more fun. Maybe I'll post another message later about the Hebrew language I'm learning- that shouldn't be too much more complicated to understand.
