September 24, 2008
Mitch Lacey provides a video retrospective on a failed project. You always learn more from mistakes than successes, perhaps you can learn some interesting things from his mistakes.
Note: There’s a slideshow that goes along with it, but he covers the gist of the slideshow pretty well, so you can just listen to the video like a podcast while you do other things.
September 22, 2008
And you thought Cobol was a dead language with no future
As long as it has a Make file or other command-line compiler interface, you too can build Cobol systems via a CI system.
September 6, 2008
Tony Morris blogs about his solution to the problem of validating ‘balanced pairs’ of tokens in a command line argument
Read both the article and the comments. Then come back here. Don’t worry, the browser will wait patiently for you.
My thoghts:
- Tony Morris believes that he demonstrates that Haskell has better functional composition than Java. But given the examples of others in the comments, he has only demonstrated that he does not know how to produce well-designed Java.
- His Haskell example has a high complexity/size ratio (technical density, if you will) and it would be very difficult for anyone but a Haskell expert to decode it.
- There are lots of examples written in the comments, in various languages, many of which are more elegant (easy to understand, yet effective in small spaces) than anything Tony wrote
It’s clear from the article that Tony wrote these in a hurry, and I don’t want to sound like I think he’s a bad programmer or a bad person because I disagree with him about the ‘lesson’.
What is interesting is that Tony wrote the code with a certain mental model of what ’success’ meant. And the comments exploded with people coming up with different definitions of success, and different ways to succeed.
As an Agile Project Manager, if I can define success the right way (for me): “I want a balanced token matcher, that’s easy to maintain“, then I can step out of the way, and let the developers figure out how to meet that goal.
Kudos to Tony for bringing up this interesting discussion.
(Hat Tip: Ragenwald)
In the process of building a Monte Carlo simulation engine, I stumbled across Eastwood, and the Google Chart API.
Diving in, I’ve discovered that the Google Chart API is pretty solid for simple charts - easy to get started, and fairly simple to experiment with by manipulating the URL.
And, if you’re using Grails, Eastwood is a plugin that converts JFreeChart to use the Google Charts API. Very nice.
July 29, 2008
One frustrating thing I’ve discovered with Grails is the way data is sent to the view pages.
In Rails, it looks a little like this:
@scenario = Secenario.new
@scenario.title = "New Scenario"
@scenario.description = "Add A Description Here"
render :view => 'create'
This snippet creates a new Scenario object, populates it, and tells Rails to render the create.rhtml file, with the @scenario object in the page’s model, helpfully known as @scenario
In Grails, it looks like this:
def scenario = new Scenario()
scenario.title = "New Scenario"
scenario.description = "Add A Description Here"
render( view: create, model: [ scenario: scenario ])
and, similarly, Grails knows to render the create.gsp file, and the scenario object is available to the page as scenario
Which isn’t terribly different, and fairly easy to use.
The problem comes in because of the way Grails uses closures to provide the action methods on the controllers (edit, create, delete, save, etc).
In Grails, you might have a action method as such:
def create = { // closure of action method here }
Now, look at the previous Grails code. Do you see the issue? Yes - create is now overloaded, and in some cases, Grails will attempt to find a page named Controller_closure_blah_blah_blah.jsp, which is obviously completely wrong.
The fix is simple:
render( view: 'create', model: [ scenario: scenario ])
Basically, make sure you always use quotes for your string values, even though the Groovy language allows you to leave the quotes off. Otherwise, you’ll occasionally get frustrating and confusing results.
July 24, 2008
Interesting issue that left me scratching my head this morning…
using gsp tags, you can iterate over arrays:
<g:each in="${myarray}">
<p>${it.title}</p>
</g:each>
but if you do something slightly more clever:
<g:each in="${myarray}">
<p><g:link action='myaction' id='${it.id}'>${it.title}</g:link></p>
</g:each>
You’ll get null pointer exceptions.
Why?
Because the <g:link> tag creates its own instance of the special variable it inside its own ‘domain’.
Fix
add the parameter var=’myvar’ to the <g:each”> tag: <g:each in=”${myarray}” var=”myvar”>. Then, use ${myvar.id} and ${myvar.title} in your code:
<g:each in="${myarray}" var="myvar">
<p><g:link action='myaction' id='${myvar.id}'>${myvar.title}</g:link></p>
</g:each>
And everything should work again.
July 23, 2008
If you’ve used Rails, you’re familiar with the flash, and all the nifty things you can do with it.
In Grails, you have flash, but you also have an entire tag library of <g:hasError>, <g:renderErrors> and so forth. None of which, as far as I can tell, care one whit about the flash. They’re all focused on domain objects, and the errors associated with processing them.
(In my opinion, this is one of the frustrations of Grails examples - the tendency to get the domain connected to the view via scaffolding, and then the author changes the subject)
But you can use the flash, in much the same way as Rails. For example, I put the following in my top-level layout template:
<g:if test="${flash.error}">
<div class="errorbox">
${flash.error}
</div>
</g:if>
<g:if test="${flash.message}">
<div class="messagebox">
${flash.message}
</div>
</g:if>
(note that you’ll have to define the messagebox and errorbox css classes)
Putting information into the flash is straightforward:
flash.error = "Your error message here."
Hope this helps!
May 28, 2008
Some feel that software products have to be essentially perfect in order to even have a ghost of a chance to succeed. People point to the iPhone and the iPod as examples of products that are practically perfect, down to the last detail, and are very successful.
Of course, one can point to a lot of counter-examples - projects that are less than perfect, but still quite successful (MySpace, Facebook, Google Mail, Google Docs, Twitter, etc). And, the huge pool of unknown projects - things that were never released because they could not achieve this desired perfection, and thus you are not even aware that they existed.
I think the gap here is the definition of “successful”. Some feel that a project is only successful if it has raving fans. Others focus on being useful to a lot of people, without worrying so much about perfection to the last detail.
I suspect (without statistical evidence) that you have the following kinds of results for projects that focus on perfection, vs. those that focus on “good enough”:


(Sorry the scale isn’t clear, the categories are “Never Released”, “Failure”, “Moderate Success” and “Huge Success”)
In reality, these scales are misleading, since the number of “Never Released” items is probably 10x as large (on both graphs). But in general, if you demand perfection, you have a slim increase in the chance that it will be a huge success, and a fairly significant increase in the chance that it will never be released.
Having said that, smooth functionality, elegant design and attention to detail are worthwhile. But they can be deceiving.
May 20, 2008
I gave up on Hani Sulemain when I realized that his modus operandi could be described in two steps:
- Find something I don’t like
- Announce with great certitude how clueless and incompetent everyone is who disagrees with me.
Alas, the chickens have come home to roost, I guess.
There’s a certain sense of “insecurity” in Hani’s post. As if he’s suddenly lacking in confidence. After all, someone fully confident of their opinions wouldn’t care what others thought.   I find that surprising in someone who was once so self-assured he could shower hate down on Google Code.  Now it’s almost like he is tired of being beaten up and just wants people to leave him alone.
Sorry Hani - this is the life you chose when you first decided to call someone else an idiot in public for supporting something you thought was lame.
May 16, 2008
Mathias is perplexed at the animosity against JSR 308 - he says (paraphrased):
- As for generics, I gladly trade in the more complicated syntax for better static typing.
and
-  That’s not the case at all with annotations. If you like you can easily ignore the entire idea.
speaking only for myself, I’ll respond with:
- If one doesn’t like static typing to begin with, the fact that generics make it “better” is not a benefit
and
- In theory, one can ignore the entire idea. In practice, as a developer out in the field, even if I scrupulously avoid them in my own code, it will be inevitable that over time:
- Someone (Person A) will want to show how smart they are by implementing all sorts of too-clever-by-half annotations in their open source project or commercial project
- Someone else (Person B) will want to show off how smart they are, by trying to create annotations that are twice as clever as Person A’s
- Some third person (Person C), not knowing any better, or thinking they’re even smarter, will make a total mess of everything, creating bizzare new structures.
- Lastly, I will be called in to help figure out how to fix/refactor/automate testing of this code, and it will be a complete nightmare.
This is a classic and commonplace event in software - for various reasons, a wide swath of programmers are both very smart, and fairly OCD (Obsessive-Compulsive).  They learn a new technology, and obsessively abuse it, attempting to find ways to use it for every possible problem (see Maven2).  They’re not bad people, they’re just focused on using cutting-edge technology to solve problems, and become the proverbial man with a hammer who sees nails everywhere…
And so the likely result of JSR 308 is that we will end up with open source projects that are littered with cryptic and broken annotations that will be zealously guarded and protected by the chosen few, who see nothing wrong with adding incredibly convoluted new constructs to their program - after all, the code isn’t convoluted to them.  If mere mortals such as I struggle with comprehension, it just demonstrates how superior they are to me, no?
Groovy looks more attractive every day.
May 9, 2008
An excerpt:
       There once was a man who went to a computer trade show. Each day as
he entered, the man told the guard at the door:
“I am a great thief, renowned for my feats of shoplifting. Be
forewarned, for this trade show shall not escape unplundered.”
This speech disturbed the guard greatly, because there were millions
of dollars of computer equipment inside, so he watched the man
carefully. But the man merely wandered from booth to booth, humming
quietly to himself.
When the man left, the guard took him aside and searched his clothes,
but nothing was to be found.
On the next day of the trade show, the man returned and chided the
guard saying: “I escaped with a vast booty yesterday, but today will
be even better.” So the guard watched him ever more closely, but to
no avail.
On the final day of the trade show, the guard could restrain his
curiosity no longer. “Sir Thief,” he said, “I am so perplexed, I
cannot live in peace. Please enlighten me. What is it that you are
stealing?”
       The man smiled. “I am stealing ideas,” he said.
And another:
   A master was explaining the nature of Tao to one of his novices,
“The Tao is embodied in all software — regardless of how
       insignificant,” said the master.
“Is the Tao in a hand-held calculator?” asked the novice.
“It is,” came the reply.
“Is the Tao in a video game?” continued the novice.
“It is even in a video game,” said the master.
“And is the Tao in the DOS for a personal computer?”
The master coughed and shifted his position slightly. “The lesson is
       over for today,” he said.
April 15, 2008
(This cookbook assumes you know the basics about how to get started with Selenium RC. These examples are also in Java, but should be pretty much consistent for any language)
Finding text in a certain place on the page:
Use XPath, treating the HTML of your page as well-formed XML.
browser.getText("//div[@id='content']/table/*/tr[2]/td[1]“)
(In English: at any level of depth, find the div where the id=”content”. Then find the table element under that, and then give us the text of the first cell of the second row.)
Finding text anywhere on the page
browser.isTextPresent("Your Text Here");
Get the text of a URL link
Assuming you have text like: <a href=”…” > your link text here </a>, you could consider:
browser.getText("//a[@href='...']“);
Note the consistency with the other example above - anytime you have an opening and closing <element> </element> tag, you can use getText() and XPath to find it.
Get the href of a URL link
Again, assuming you have text like: <a href=”my_link_here” > your link text here </a>, you could consider:
browser.getAttribute("//a[1]/@href”);
which would return: my_link_here
Note the slight differences with getText() above, but the idea is generally the same.
How do I find what’s in my Select menu?
String[] options = browser.getSelectOptions(”//form//select”);
This would return an array of the option text from the only <select> element inside the only <form> element.
If you had more than one form, or more than one select:
String[] options = browser.getSelectOptions(”//form[1]//select[1]“);
This would return the options listed in the first select of the first form on the page.
April 10, 2008
If Test-First Development (TFD) is a specialized subset of Test-Driven Development (TDD), then surely the equivalent specialized subset of Behavior-Driven Development is Behavior-First Development.
Today I had my first experience in developing BFD.
I know what you’re thinking: BFD.
But it’s a BFD to me. Using a rather exotic concoction of DBUnit, HSQLDB, Selenium, Cargo and EasyB, I was able to write a story to describe some new functionality for a web application, and run that story as a test (via EasyB/Groovy), before I wrote any of the code to implement the functionality.
Other ingredients in this concoction: Tomcat, Ant, Junit, Struts2, Spring, Cobertura and four or five different logging frameworks.
Observations:
-  It is difficult to see what is going on when your story fails - the story failure is often fairly far away from the code failure.
- DBUnit throws multiple exceptions as part of normal operating procedure. That is a crime against humanity.
I’m sure everyone else in the world found and mastered XPath Checker long ago, but for those of you who haven’t, it is a fantastic Add-on for Firefox that lets you practice XPath expressions on real, live web pages.
Why would you want to do that?ÂÂ
If you want to write Functional webapp tests via Selenium, a good, solid working knowledge of XPath is essentially mandatory for all but the most trivial of tests.
What about Selenium IDE?ÂÂ
The Selenium IDE is incredibly helpful for navigating your pages, but it is not help at all with testing the content on those pages.
In other words, if you want to register a new user, add four things to your cart, visit your recommendations page and then check out, Selenium IDE will properly structure your clicks and everything else.
But if you want to find out if your checkout page lists your four items, and you need to be specific about where on the page those items show up, you have to use XPath with Selenium to get to the correct table, div, what-have-you.
Enter XPath Checker. During your Selenium IDE-driven recording session, control-click on the page, and experiment with the correct XPath query to get to the cell/row/etc you want to see.
April 4, 2008
Hudson
Good Continuous Integration tool. Nice charts, easy to use, fairly flexible out of the box.  A _lot_ less setup work than CruiseControl. And the plugin system is well done, and pretty nifty.
Struts2
An incoherent mess. Documentation is spotty, uses a lot of contrived toy examples that blow up on anything more complex than hello world. Documentation is also simply wrong in some cases (for example, the ‘var’ attribute on the iterator tag is not valid according to the TLD). Namespaces are nice in theory, but frustrating in practice.  I can’t get the wildcard action management to work reliably, although this may just be pilot error.
Good things:ÂÂ
The integration with Spring is nice, and I haven’t seen a web framework yet that is more friendly to unit testing. When it works properly, the wildcarding is very nice.  The Action.execute() model is useful, and easy in concept.
March 24, 2008
An oldy, but a goody, one that I haven’t seen before.
One comment I saw recently was “it means ‘practices of the best’” - as in “the things that the best software developers/consultants do”.
I don’t find that argument particularly persuasive. For several reasons:
- No one knows who the very “best” software developer is.
- No one even knows who the very best software developer is, in a particular practice area.
- Even if we could magically discern who the best software developer was, it is very likely that:
- Her approach would be highly tuned to the specific company/organization she was with
- She would have a hard time elaborating and generalizing her approach without diluting its effectiveness
- Others would point at this poor developer and say “She is only an expert on Y in situation X, but we are in situation Z”
So while I think it is an interesting concept (practices of the best), I can’t acept that interpretation as being any more valid than “the best way to solve this problem”.
March 17, 2008
It took me about an hour and a half to get the dashboard configured properly. Here’s what I had to do:
- I had to copy all of the cruisecontrol jars and all tornei poker on lineworld pokerpoker italiagame on line pokerdownload live pokerstrip poker livesrtip poker gratisgiochi cartepoker scaricabili gratistexas holdem calculator,texas holdem,poker texas holdemtexas holdem italiastreap pokerpoker in tourseven card stud onlinegiochi on line pokergiocare texas holdem online,poker texas holdem online,texas holdem onlineparty poker bonus,poker con bonus,poker bonusstreet poker onlinesexi poker onlinesexy poker onlinehow to play pokergioco carte pokerpoker carte gratistornei di poker gratisonline poker gameparty poker bonuscraps in lineavirtual gamblingscaricare casino gratisonline casino gamesbonus dei casinogioco keno gratiscasino on line roulette,roulette on line,giochi on line roulettegiochi keno inlineagiochi casino pcsistemi roulettecasino tropezgioco craps in lineawww giochi casinoblog casino onlinekeno inlineacasino poker gratisbest casino onlineautomatic video pokercasino tropez bonus codegiochi video pokerroulette strategyrisposte eurobarre casino on netvincere casino onlinelista casino online of the xml-related jars (saxon, jdom, xerces, xml*) into the WEB-INF/lib directory of the dashboard war
- I had to update WEB-INF/web.xml and add a context-param to specify the location of the config-xml file.
Note: You might think that you can give it the correct filename at the web interface, but that never worked for me, no matter how I tried to tweak it.
At the end of the day, cruisecontrol requires a great deal of by-hand tweaking to get it to work for your project. That’s not necessarily the end of the world, but it is a little disconcerting, since the documentation isn’t really clear about how you do this setup, where and so forth.
Well, I’m having a bit of an adventure with CruiseControl. Some tips, perhaps just for myself:
- You have to check your project out of source control into the appropriate checkout directory under the cruisecontrol/ build directory before CruiseControl proper will consider building it.
- You have to merge unit test results in by hand
- You have to set up your dashboard by hand, and (at least as of today) you have to find the missing classes that it needs and include them
More later…
Having taken up the task of learning Groovy, I stumbled early, as I tried to figure out how to integrate groovy-based unit tests with my java code. I had a java class called ContactScreen, and I wrote a groovy test case:
class ContactScreenTest extends GroovyTestCase {
void testStandardEmailScreen() {
screen = ContactHelper.getStandardContactScreen( Contact.EMAIL )
assertTrue( screen instanceof AnyDayEmailScreen )
}
}
Which failed when I tried to run it via Eclipse, giving the following error:
testStandardEmailScreen(ContactScreenTest)groovy.lang.MissingPropertyException: No such property: screen for class: ContactScreenTest
I stared at that error for a long time, wondering what the heck it meant. I mean, I’ve seen all sorts of example groovy scripts that don’t require definitions. In fact, the code I was modeling mine after used this very format. What is going on?
Finally, I turned to the groovy user group to help debug my groovy test case. Here’s what I found:
- The code I was looking at, circa 2004, is now victim to a fairly significant shift in language specification. In other words, it won’t compile anymore.
- The rules for declaring variables is different for scripts versus classes. In other words, if you are just running a script, you don’t need to declare variables. If you are building a class, you have to declare the members of the class via def.
So the working code looks like this:
class ContactScreenTest extends GroovyTestCase {
void testStandardEmailScreen() {
def screen = ContactHelper.getStandardContactScreen( Contact.EMAIL )
assertTrue( screen instanceof AnyDayEmailScreen )
}
}
February 11, 2008
This image is sadly in-tune with my experiences and personal opinion of Oracle, and the complexity of their tools.
