<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Bill Dudney&apos;s Blog</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bdudney/" />
<modified>2008-01-02T17:42:16Z</modified>
<tagline></tagline>
<id>tag:weblogs.java.net,2008:/blog/bdudney/92</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2004, bdudney</copyright>
<entry>
<title>Test what you think of and even what you don&apos;t!</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bdudney/archive/2004/06/test_what_you_t.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2004-06-03T13:19:36Z</issued>
<id>tag:weblogs.java.net,2004:/blog/bdudney/92.226</id>
<created>2004-06-03T13:19:36Z</created>
<summary type="text/plain">Downloading code blindly off the net can be dangerous as seen is the bug described in this post. Always make sure to test everything you write and everything you download from the net as well.</summary>
<author>
<name>bdudney</name>

<email>bill@dudney.net</email>
</author>
<dc:subject>Community: Global Education and Learning Community</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/bdudney/">
<![CDATA[<p>
The other day I was taking with my friend Kent who works for <a href="http://www.agitar.com">Agitar Software</a>, a vendor of a really cool unit test automation tool called <a href="http://www.agitar.com/news/2004-000021-Agitator%20announcement.html">Agitator</a>, and he was saying that they found an interesting bug for one of their clients using the tool.
</p>
<p>
Have you ever searched google for a way to replace a regular expression with another string in Java? I did with <a href="http://www.google.com/search?q=Replacing+Substrings+in+a+String&ie=UTF-8&oe=UTF-8">this</a> search and found some interesting results (you will see how Kent fits in just bit so hang on).
</p>
<p>
The first hit (at least when I searched) takes you to the great site <a href="http://www.javaalmanac.com">Java Almanac</a> and a piece of code that seems to fit the bill.
</p>

<code><pre>
    static String replace(String str, String pattern, String replace) {
        int s = 0;
        int e = 0;
        StringBuffer result = new StringBuffer();
    
        while ((e = str.indexOf(pattern, s)) >= 0) {
            result.append(str.substring(s, e));
            result.append(replace);
            s = e+pattern.length();
        }
        result.append(str.substring(s));
        return result.toString();
    }
</pre></code>

<p>
Now comes the interesting part. This code has a serious bug in it and its not all together obvious when you first grab it. And besides its on the Java Almanac, it must have been tested a thousand time right!
</p>

<p>To see the bug in action try this test</p>
<code><pre>
     replace("Original String", "", "pattern");
</pre></code>

<p>Unlikely that you actually type code in like that but who knows what might happen when the parameters that are passed are values in your program. These could be parameters from a user that forgot to type in the pattern or some other such thing.</p>

<p>The really interesting thing is that the method never returns. This code will go into an infinite loop because the <code>indexOf</code> will always return zero for the empty string.</p>

<p>That is where Kent comes back into the picture. A few weeks back he was called in to assist some of their clients with some problems they were having with their applications. Kent went to help them apply the Agitator to their apps to see if they could nail down the bugs. Come to finde out of the four clients Kent visited everyone of them had coppied and pasted this very code into their applications. This infinite loop was at least part of the problem.</p>

<p>There are a couple of lessons to learn here. One you should always test the code you down load from the net. The people who post code are just that, people. They make mistakes and sometimes what they post is broken. The second thing is test what you think of and also what you don't think of. The bug in the string replace code is non-obvious and in most cases I doubt I would have recognized the bug right off hand if Kent had not pointed it out. If it had been me that copied this code I would have very likely tested for passing in null for the pattern and/or replace string but probably not for the empty string. That is where tools like Kent's Agitator come in very handy they help you to see the stuff you did not think of.</p>

<p>Happy Coding, and make sure to test everything!</p>

<p><i>BTW: I tried to send email to the Almanac but there was no contact info on the site that I could find. If you know how to contact them please post it in a comment!</i></p>]]>

</content>
</entry>
<entry>
<title>Colorado Software Summit</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bdudney/archive/2004/03/colorado_softwa.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2004-03-04T03:19:21Z</issued>
<id>tag:weblogs.java.net,2004:/blog/bdudney/92.148</id>
<created>2004-03-04T03:19:21Z</created>
<summary type="text/plain">Software Summit Calls for Papers</summary>
<author>
<name>bdudney</name>

<email>bill@dudney.net</email>
</author>
<dc:subject>Community: Java Web Services and XML</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/bdudney/">
<![CDATA[<p>
The Colorado Software Summit is calling for <a href="http://www.softwaresummit.com/2004/papers.htm">papers</a>. I went last year for the first time and absolutely loved it! I <a href="http://bill.dudney.net/roller/page/bill?catname=Software%20Summit">blogged</a> about each session I went to. It is a geeky place for sure, everyone there is a geek. No stuffed shirts and you just can't beat <a href="http://www.softwaresummit.com/2004/keystone.htm">Keystone CO</a> for a fantastic place to learn new stuff.
</p>

<p>
This years focus is on web services with Java. I highly suggest you submit a proposal and if you are not keen on public speaking then I suggest you sign up today to go. Its going to be a blast!
</p>]]>

</content>
</entry>
<entry>
<title>JSF: UIComponent.getAttributes() -- good, bad or ugly?</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bdudney/archive/2004/02/jsf_uicomponent.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2004-02-14T23:49:09Z</issued>
<id>tag:weblogs.java.net,2004:/blog/bdudney/92.138</id>
<created>2004-02-14T23:49:09Z</created>
<summary type="text/plain">With all the recent talk about accessors I thought it would be fun to bring up a pattern in the latest JSF beta release that I found fascinating.</summary>
<author>
<name>bdudney</name>

<email>bill@dudney.net</email>
</author>
<dc:subject>J2EE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/bdudney/">
<![CDATA[<p>
Back in September <a href="http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html">Allen Holub</a> said that accessors are evil, there was also a long <a href="http://www.theserverside.com/news/thread.jsp?thread_id=21310">thread on TSS</a> about Allen's article. Then very recently <a href="http://beust.com/weblog/archives/000083.html"/>Cedric Beust posted</a> that he thought accessors are here to stay and that Allen Holub was all wrong (I tend to agree with Cedric on accessors but Allen did make a couple of good points). Which all seem to have very little to do with JSF I know but...
</p>
<p>
Consider the <code>UIComponent.getAttributes() : Map</code> method, which is new in the latest beta release. This method returns a map that gives you get and put access to the JavaBean attributes on your component (all those evil accesors:). This fascinates me and I think its a cool thing to do. Tools have a very simple (<code>java.util.Map</code>) API to use and we as programmers have the accessors for the stuff we need typed access to (its likely to be a little quicker too but probably not called often enough to matter much). So for example;
</p>

<code>
<pre>
  public class MyComponent extends UIComponentBase {
    ...
    public static final String FOO = "foo";
    private String foo;
    public void setFoo(String foo) {
      this.foo = foo;
    }
    public String getFoo() {
      return foo;
    }
    ...
  }

  public class MyRenderer extends Renderer {
    public static final String BAR = "bar";
    ...
    public void encodeBegin(FacesContext context, UIComponent component) {
      // instead of casting component to MyComponent I can use the attributes 
      // map to get at 'foo' or I could cast and call getFoo() either way
      // it works the same (the map is of course a bit slower)
      ...
      String foo = (String)component.getAttributes().get(MyComponent.FOO);
      ...
      // even more interesting I can get at the renderer specific
      // values put into the component by the creator of the component
      // (usually a JSP tag) with the same logic
      // Typically I'd be setting the value of bar in a JSP tag
      // also using the map interface like this
      // component.getAttributes().put(MyRenderer.BAR, valueSpecifiedInJSP);
      ...
      String foo = (String)component.getAttributes().get(MyRenderer.BAR);
      ...
      
    }
  }
</pre>
</code>

<p>
The spec calls this 'attribute-property transparency'. I like this a lot better than the way that the API was laid out in the EA4 version of JSF. In that world you had to keep everything in a Map and if you wanted accessors they had to delegate to the Map. This is a lot cleaner in my opinion.
</p>

<p>
Another side effect is that you can just assume that <code>put(Object, Object)</code> will 'just work' and will call the underlying <code>set</code> method when it can and put the value into a map otherwise. Thus we will be able to iterate through properties in a very straightforward way. This comes in very handy in the way JSP custom actions (tags) are implemented. The first example in the spec in section 9.3 shows how this could/should work.
</p>

<p>
With this API components could conceivably be writen without any accessors and no fields. All the instance data would be stored in the map. I think there is a certian danger of abuse like this.
</p>

<p>
On the positive side tools can access the whole component without having to know anything about it. This is a key aspect of the tooling requirements behind JSF and was possible in EA4 but uglier.
</p>

<p>
I've seen this sort of thing done on a limited scale on other projects but I've never seen something like this in a project like JSF (that will be used by lots and lots of people). What are your thoughts on doing this? Will it scale up in terms of usability? Will it get abused so much that we will end up with lots of nasty code? What do you think?
</p>]]>

</content>
</entry>
<entry>
<title>Software Summit - What a Blast!</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/bdudney/archive/2003/11/software_summit.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2003-11-02T23:39:55Z</issued>
<id>tag:weblogs.java.net,2003:/blog/bdudney/92.356</id>
<created>2003-11-02T23:39:55Z</created>
<summary type="text/plain">I just finished with geek heaven week in Keystone Colorado. The conference is over and I had a blast. From meeting others with a passion for the same stuff I love to having a chance to go to a lot of really good presentations. This was a great week!</summary>
<author>
<name>bdudney</name>

<email>bill@dudney.net</email>
</author>
<dc:subject>Community</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/bdudney/">
<![CDATA[<p>
There were about 700 really smart people at the <a href="http://www.softwaresummit.com">conference</a>. Every talk I went to was chock full of great content.
One of my favorite things in the world is to learn something new and man has this been a feeding frenzy. I had many great conversations with the people I've meet ranging from Lego Mindstorms to process and methodology. Here I'll try to sum up what I saw and I learned. I have detailed notes from each of these talks on my personal blog, if you are interested in more detail.
</p>
<p> <i>
OK so enough fluff here is the stuff :-)
</i> </p>

<p>
<b>Monday:</b>
<p><b>Keynote - <a href="http://www.softwaresummit.com/2003/speakers/soyring.htm">John Soyring</a></b></p>
The basic point of John's talk was despite the outsourcing that is happening there are jobs for people that have deep technical skills. He laid out eight areas where he (as the leader of IBM's services org) sees significant demand.
<ul>
  <li>System and/or Solution Architects</li>
  <li>Business Process Integration</li>
  <li>Portal Design and Legacy Integration</li>
  <li>Performance Analysis & Tuning</li>
  <li>Security and Privacy</li>
  <li>Orchestration and Provisioning</li>
  <li>Linux Server Management</li>
  <li>Virtualization</li>
</ul>
An encouraging talk all around. One of the biggest things he sees happening is Portals. He ranked them 5 out of 5 last year and he was wrong, they ended up being bigger than he could have guessed.
<p>
Another cool thing that he mentioned was the IBM <a href="http://www.alphaworks.ibm.com/tech/dptk">Design Pattern Tool Kit</a>. I have not had a chance to play around with it yet but is sounds really cool.
</p>
</p>
<p>
<b>Monday Sessions:</b>
</p>
<p>
First I went to one of the many web services talks. This one was given by <a href="http://www.softwaresummit.com/2003/speakers/hatzidakis.htm">Denise Hatzidakis</a> and covered the myriad of standards that make up what we call 'web services'. I enjoyed the talk and learned that someone needs to consolidate the specs :-) The treatment of WS-I was good too, I got a good feel for whats in there and what the point of the spec was.
<p>
The next talk was about J2SE 1.5 by <a href="http://www.softwaresummit.com/2003/speakers/reinhold.htm">Mark Reinhold</a>. Overall a good intro to the new stuff in 1.5. I had heard of everything that Mark went over but the meta-data (now annotations) info was really cool. I have been meaning to read up on that for a while but just have not had the time. His overview was quick but good. There is another talk specifically on the meta-data stuff that I'm hoping to get to by <a href="http://www.softwaresummit.com/2003/speakers/nash.htm">Simon Nash</a>.
</p>
<p> The evening ended with a Q&A session where I learned that I'm not the only geek teaching my 8 year old how to build robots with java and lego-mindstorms. :-)</p>
</p>
<p>
<b>Tuesday Sessions:</b>
<p> The first one was on XSLT 2.0 given by <a href="http://www.softwaresummit.com/2003/speakers/ricca.htm">Bonnie Ricca</a>. It was good. I was hoping for more info on the standardization of integration but that was not to be. What I did learn is that XSLT/XPath 2.0 is going to make our lives easier in many ways. One of my favorite things is that XSLT and XPath now use the schema data types. Just from a cognitive perspective it will make the lives of those doing XSLT much easier only having to learn one XML type system.</p>
<p>Next I went to the portlets talk by <a href="http://www.softwaresummit.com/2003/speakers/landers.htm">Dave Landers</a> and learned a ton of useful info about Portlets. I am planning to do some heavy portlet work early next year so this was most useful. I learned that Portlets are basically a step back in terms of rendering (who wants to put HTML into their Java code anyway). So I'm anxious to dig into some implementation to try it out and see if I can make JSP's work better with portlets. I will also be putting some JSF UI's into some portlets, when I'm done I'll repost with the results.
</p>
<b>Wednesday Sessions:</b>
<p>The first was on JSF by <a href="http://www.softwaresummit.com/2003/speakers/stelting.htm">Stephen Stelting</a>. He did a great job of presenting the basics of JSF. I enjoyed his presentation. I especiallly liked that he demonstrated some typical error conditions that happen with new developers. He also did a long example that showed several aspects of the JSF framework. A good presentation.</p>
<p>The second presentation was on Grid computing given by <a href="http://www.softwaresummit.com/2003/speakers/giangarra.htm">Paul Giangarra</a>. All I had done before this talk was watch IBM's commercials that hint at grid computing (computing becoming a utility). So watching Paul go into detail and demystify the concept was great. I am really excited about the promise of Grid computing, but we will have to wait and see if the promise becomes reality. If it does we will be able to do some really cool stuff in the future. Grid computing (or actually the way apps have to be written for the Grid) reminds me of the way math apps had to be written for the Cray. He mentioned <a href="http://www.globus.org">Globus</a> and that looks like a cool place to start playing around with the ideas. If only I could quit my day job and play with new stuff full time!
</p>

<p>
<b>Thursday:</b>
<p><b>Keynote - <a href="http://www.softwaresummit.com/2003/speakers/phipps.htm">Simon Phipps</a></b></p>
Great talk, Simon's basic point was the Open Source is not about free as in money free, but free as in freedom. Open source is enabled by the massively connected nature of our world. As expected (being from Sun and all) he talked a lot about the network being the computer. It was not a sales pitch at all but very interesting. Simon made the point that if we really thought the network was the computer then applications would be licensed differently and would run differently (and Sun is making some strides in the right direction with the $50/employee licensing). Lots of other cool stuff. Very entertaining and interesting talk.
</p>
<p><b>Thursday Sessions:</b></p>
<p>
First presentation was on Portals by Paul Giangarra. Cool presentation with only a little over lap on the Portlet presentation. I basically learned that the race is on to provide good Portal stuff (i.e. portlet containers) for the big vendors and that IBM's intranet has some really cool Portal stuff.
</p>
<p>
Finally made it to <a href="http://www.softwaresummit.com/2003/speakers/nash.htm">Simon Nash</a>'s talk on annotations (i.e. JSR 175). There is some really cool stuff that could be done with the implementation of this. I was kind of tweaked that there is no definition of how to process the annotations though. I love the fact that I can declaritively say that my class is a websource but I'm not at all jazzed that I have to cook up my own way of getting to the annotations (i.e. parse the source, the class file or use reflection at run time). The talk was great though. Simon was really cool and you could tell he loved this stuff.
</p>
<p><b>Friday Sessions:</b></p>
<p>
The last session of the conference (I had to speak in the morning) was on the Globus tool kit (the grid computing stuff referred to by Paul Giangarra). Very cool content and very cool stuff. The tool kit basically enables you to do grid computing according to the Open Grid Services Architecture (OGSA) standard. <a href="http://www.softwaresummit.com/2003/speakers/brown.htm">Mike Brown</a> did a great job of showing some of the cooler stuff you could do with the tool kit. The demo he cooked up was really cool (even though it didn't work). Each of the willing participants downloaded <a href="http://www.globus.org">Globus</a>, installed it and copied a web service from Mike's machine. Then with a simple Swing GUI Mike started up an SVG renderer service on each machine and got the results back on his machine to display the final JPEG. There was some bug somewhere that made it not work on everyone elses machines so he ran a threaded version on his own machine. Anyway it was really cool and I learned that I if I ever get the chance to do some grid computing I'll jump on it.
</p>
<p>
One of the coolest things last week was that the list of stuff to read or research that has been piling up on my desk for the last few months is finally starting to go down. I have learned so much that some of the items will just be pushed off the stack until I need more detail. This was an absolutely great conference and I highly recommend you comming next year if you have any money in your budget for such things. It was fantastic!
</p>]]>

</content>
</entry>

</feed>