Somewhat Daily Mutterings : Programming http://www.samoht.com/weblog/gemcast.rb Somewhat Daily Mutterings http://www.samoht.com/gemcast_images/header_portrait.jpg samoht.com http://www.samoht.com/weblog/gemcast.rb Programming in Color http://www.samoht.com/weblog/gemcast.rb/Programming/programming_in_color.html <p>Whoa. Just Whoa.</p> <div class="photo" > <a href="http://scienceblogs.com/goodmath/2006/11/programming_in_color_fixed.php#more"><img src="/weblog_img/piet-4.jpg"></a> <p>This is source code</i> </div> <p>Mark Chu-Carrol has just officially <a href="http://scienceblogs.com/goodmath/2006/11/programming_in_color_fixed.php#more">blown my mind</a>. </p> My First Paying Rails Gig http://www.samoht.com/weblog/gemcast.rb/Programming/Ruby/rails_gig_1.html <p>OK, my <i>first ever</i> Ruby on Rails gig is also a paying gig. I can't go into too much detail at the moment, but I just started moonlighting on a Rails project for a friend of mine. It's a fairly small site, basically to provide some information about his consulting practice and to give access to his articles and scheduled appearances. As such, it is pretty much the perfect starter Rails project.</p> <p>My first step was to generate a rails project and "pour" his prototype into the public directories. Having done that, I can start the rails server and look at the content as served by rails. This will give me something to refer to while I move bits of the static content over into view implementations.</p> <p>Next steps are to get the code into a repository at the hosting service, so we can start collaborating on the app. I'll post more details here, as appropriate, as the project proceeds. Rails Studio Denver, Day Three http://www.samoht.com/weblog/gemcast.rb/Programming/Ruby/rails_studio_day_three.html <p>Day three was kind of divided into two parts: completion of Rails basics before lunch, then a grab-bag of more advanced topics after: </p> <ul> <li>sending email <li>controller hooks and filters <li>web services <li>security <li>deployment issues <li>deployment using SwitchTower </ul> </p> <div class="photo"> <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?show_name=1&count=1&display=earliest&size=m&layout=x&source=all_tag&tag=RailsStudioDenver&user=76198982%40N00"></script> <p>More <a href="http://www.flickr.com/photos/tags/RailsStudioDenver/">Flickr photos tagged with RailsStudioDenver</a></p> </div> <p>Lunch itself was combined with the much-needed exercise of building a small app from scratch. Of course, my bud <a href="http://blog.billeisenhauer.com/main/2006/01/denver_rails_st.html">Bill</a> (who came up from Dallas) and I burned up most of the allotted time cutting up in the back of the room over our lunch, and thus had only about 40 minutes to build the app. We did so by pairing-by-sharing, whereby he shared his hard drive and we worked on separate parts of the very same project. It worked out OK, but our app didn't turn out to be very sophisticated.</p> <p>I really hope that Dave and Mike plan on creating an advanced RoR class, because in all, this class was not as deep as I'd have liked. I kind of felt as though I could have gotten nearly as much from going through Dave's excellent RoR book and following along with the Depot project on my machine. This is not to say that the class was bad - I know some folks appreciated it at the level it provided, and as I said before, you can't please everybody. However, I do think a class that focuses on actually building an app from start to finish, with the class perhaps dividing into teams, would be a big success. Perhaps the format could be: mornings spent covering the previous day's foibles, then some RoR feature training, then the entire afternoon spent applying the training.</p> <p>That said, the class was a great way for me to immerse myself in RoR training to a degree which I probably would not have done on my own. I paid for the class myself (and used vacation time), and thus was quite compelled to take an interest. It was also a great networking opportunity, and having Bill in for a visit was fun, too.</p> Rails Studio Denver, Day Two http://www.samoht.com/weblog/gemcast.rb/Programming/Ruby/rails_studio_day_two.html <p>We dug deeper into Rails today and covered a huge range of topics: <ul> <li>link generation <li>session management <li>ActiveRecord relationships <li>Ajax <li>rails form binding <li>web "components" </ul> </p> <div class="photo"> <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?show_name=1&count=1&display=latest&size=m&layout=x&source=all_tag&tag=RailsStudioDenver&user=76198982%40N00"></script> <p>More <a href="http://www.flickr.com/photos/tags/RailsStudioDenver/">Flickr photos tagged with RailsStudioDenver</a></p> </div> <p>The format today was mostly presentation, with few exercises. This was a double-edged sword - a lot of information was provided (much more so than day one), but there was little opportunity to experiment with what was presented.</p> <p>After class, a group of eight of us headed into downtown for Indian food. It was a bit of a wild goose chase finding the restaurant, but then we enjoyed great Indian food and beer. Aside from the usual geeking out, we were regaled with entertaining tales by an French expatriate attendee named Fernand. </p> Rails Studio Denver, Day One http://www.samoht.com/weblog/gemcast.rb/Programming/Ruby/rails_studio_day_one.html <p>Just a very short entry, because that's all I have time for. The class is composed of about 50 attendees, from all sorts of development backgrounds. In terms of content, Dave and Mike first did a very short Rails history, then spent the morning on a Ruby review. Even though I've been coding in Ruby (inconsistently) for a few years, I picked up a couple of new things. The afternoon was spent getting up to speed on Rails basics, digging shallowly into ActiveRecord and static and dynamic scaffolding. Probably the most interesting and useful topic was that of <a href="http://jamis.jamisbuck.org/articles/2005/09/27/getting-started-with-activerecord-migrations">migrations</a>, which allow you to "version" changes to the database schema (and data!) as you progress through a project. </p> <p> <div class="photo"> <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?show_name=1&count=1&display=random&size=m&layout=x&source=all_tag&tag=RailsStudioDenver&user=76198982%40N00"></script> <p>More <a href="http://www.flickr.com/photos/tags/RailsStudioDenver/">Flickr photos tagged with RailsStudioDenver</a></p> </div> <p>In all, the day moved a bit slow for me, but I'm sure there were folks for whom it was just right. You can't please everybody.</p> <p>After class, a few of us headed into downtown Denver for dinner at P.F. Chang's, and had a good time geeking out over beers, lettuce-wraps, and other sodium-filled goods.</p> Strangling Legacy Code Roundtable http://www.samoht.com/weblog/gemcast.rb/Programming/strangling_roundtable.html <p>I'm hosting a <a href="http://tinyurl.com/aptrj">roundtable</a> in support of my article "Stangling Legacy Code", which appears in this month's <a href="http://www.stickyminds.com/BetterSoftware/magazine.asp"><i>Better Software</i></a> magazine. The roundtable runs from Oct 10 through Nov 10. If this topic interests you, please stop in and add your insights. </p> An Interesting Reference to <i>The Costanza Principle</i> http://www.samoht.com/weblog/gemcast.rb/Programming/interesting_reference_to_costanza_principle.html <p>In my Strangling Legacy Code presentation and article (Better Software, Oct 2005), I coined the term: "The Costanza Principle" (TCP). TCP It refers to the <i>Seinfeld</i> character George Costanza, and is basically a funny way of saying "learn from past mistakes". Anyway, I was doing some "strangling" research, and came across this interesting <a href="http://villane.blogspot.com/2005/02/on-sit-coms.html">reference</a> to TCP on Villane Bardak's site. Although he's a Java developer, the post has nothing in particular to do with software: </p> <p class="quote"> "Secondly, Seinfeld is way above Not Too Shabby. You can simply tell that from the various contexts it is often referenced in. The jokes are often quite unique, compared to other sit-coms. Or even if they aren't, they sure fooled me. For example, google for "Costanza principle" and download the powerpoint file "Strangling Legacy Code", then search for "Costanza" in the file again. It shows how a joke from one the episodes can apply to solving a real-life software engineering problem." </p> <p style="text-align: center;">----</p> <p>Correction: I <i>thought</i> I had uniquely coined the term for my presentation, but when I run the Google search he suggests, I come up with a million (OK, actually 109) similar "coinages". Bummer. Well, I can honestly say that I independently coined it, but not that it was a unique. </p> A Napkin-sketch Look and Feel http://www.samoht.com/weblog/gemcast.rb/Programming/Java/napkin_look_n_feel.html <p>In a stroke of pure genius, Ken Arnold <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=52241">introduces</a> his "napkin look and feel". The purpose behind it is to keep stakeholders reviewing the design from considering it "done". I think this has two dimensions: 1) it makes it seem easier to change, and 2) it doesn't look as though it can be shipped.</p> <p>If only we were developing a Swing app at my shop, we'd definitely be using this technique. Instead, we build static HTML prototypes that our UI guy always polishes to perfection (even though I've repeatedly mentioned that we should not try to make it look to pretty). Maybe we should attach an "ugly" stylesheet to the prototype, although we could never get the same great hand-drawn effect. </p> Watching Ruby on Rails Metastasize... http://www.samoht.com/weblog/gemcast.rb/Programming/Ruby/ror_metastasizing.html <p>... and I mean that in a good way. One of my favorite examples is how Justin Gehtland has moved from a RoR experimenter flush with early success to a full-on <a href="http://www.relevancellc.com/blogs/?p=60">proselyte</a>. It's been interesting reading his <a href="ihttp://www.relevancellc.com/blogs/?p=29">accounts</a> of RoR <a href="http://www.relevancellc.com/blogs/?p=31">experimentation</a> and seeing the <a href="http://www.relevancellc.com/blogs/?p=57">transformation</a> in <a href="http://www.relevancellc.com/blogs/?p=57">progress</a>. Of course, he's a <a href="http://www.relevancellc.com/blogs/?p=63">consultant</a>, so it makes very good sense for Relevance LLC to <a href="http://www.relevancellc.com/blogs/?p=62">jump on the RoR bandwagon</a> with both feet and a bag of chips (mixed metaphor very intended) but let's not get too cynical (it's hard, but I try).</p> <p>Thanks for the posts, Justin. I'm only a <i>little</i> envious.</a> Gemcast 0.1.0 Available http://www.samoht.com/weblog/gemcast.rb/Programming/Projects/Gemcast/gemcast-0.1.0.html <p>I've done some major refactorings in <i>gemcast</i>, the Ruby-based weblog engine that runs this site. I've rewritten some pieces, and added new features here and there.</p> <p>The two main new features are a "Top" entry for the Categories sidebar, and the ability to display a single weblog entry, <a href="gemcast.rb/Creations/Photos/ft_zachary_taylor.html">like this</a>. This latter feature I'll be able to use for "real" permalinks (although they'll only be permanent if I don't move or rename my blog entries), rather than the anchor hack that I was using before (and that stopped working as soon as the entry scrolled off the bottom of the blog). As a side-effect of the latter, I've also started down the road of making <i>gemcast</i>'s URLs compatible with <i><a href="http://www.blosxom.com/">blosxom</a></i>'s URLs, which is reasonable, given that <i>gemcast</i> is a ruby-based knock-off of <i>blosxom</i>. </p> <p>Read more about <i>gemcast</i> <a href="/wiki/wiki.pl?Gemcast">here</a>.</p> <p><a href="/gemcast-0.1.0.tar">Download <i>gemcast</i> 0.1.0</a></p> OSCON 2005 http://www.samoht.com/weblog/gemcast.rb/Programming/oscon_2005.html <p>I was in Portland last week for the O'Reilly Open Source Convention. It was a great time, as was the larger, 1+ week, vacation for myself and MB that wrapped around the convention (more on that in a different post).</p> <p>I mostly concentrated on the <a href="http://www.ruby-lang.org">ruby</a> track, since I paid the entry fee myself, and by God, I'm gonna get as much ruby as possible! One more thing on ruby before I shut up about it - it definitely had the buzz at OSCON. No doubt about it. Much of it was fueled by <i>Ruby on Rails</i>, which is a shame (no reflection on Rails, per se). Ruby is good enough that it should be able to stand on its own, and Rails is just another good thing about it.</p> <p>Anyway, I've posted <a href="http://www.flickr.com/photos/76198982@N00/sets/716330/">some photos from the convention</a> on flickr.com (at the moment you can see a random photo directly on my flickr sidebar). </p> Note to Self: Read this Article http://www.samoht.com/weblog/gemcast.rb/Programming/Java/caching_article.html <p><a href="http://www.theserverside.com/news/thread.tss?thread_id=31691">Cameron Purdy on Caching</a> (via The Server Side). </p> Bug in Hibernate UserType Example http://www.samoht.com/weblog/gemcast.rb/Programming/Java/hibernate_example_bug.html <p>In Gavin King's excellent book <i>Hibernate in Action</i>, there lurks an insidious bug. If you follow his custom UserType implementation example on page 203, you're in for big trouble and lengthy debugging sessions. Here's the example</p> <pre> public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException, SQLException { if (resultSet.wasNull()) return null; // <------- BUG!! BigDecimal value = resultSet.getBigDecimal(names[0]); return DataUtils.toPercentage(value); } </pre> <p>The problem with the above code is that the wasNull() call is not preceded by a get*() call. In our particular circumstance, once wasNull() returned true (due to a null value in a given column), it kept returning true for every column that was mapped using the UserType. This, of course, resulted in the subsequent fields of this type being given null values, even if the column did not contain a null value.</p> <p>Do I need to say that this is a very subtle bug that pops out in odd places, and is extremely difficult to find? I spent hours with log messages and the debugger. The right way to do it is as follows.</p> <pre> public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException, SQLException { String name = resultSet.getString(names[0]); // <----- You GOTTA do this! if (resultSet.wasNull()) return null; BigDecimal value = resultSet.getBigDecimal(names[0]); return DataUtils.toPercentage(value); } </pre> Fall 2004 RMSS Report http://www.samoht.com/weblog/gemcast.rb/Programming/Java/rmss_fall_2004.html <p>First, a link for those who may be looking for the updated slides to my <a href="/wiki_downloads/StranglingLegacyCode.ppt">Strangling Legacy Code</a> session. The presentation went smoothly (from my side, anyway), and I appreciated the attendance and comments. I averaged a 3.9/5.0 in overall rating, which ain't bad for a first time presentation of this content.</p> <p>As an attendee, I enjoyed all the sessions that I attended: <ul> <li>First, Erik Hatcher's <i>Ant 1.6 Hacks</i> was a great (re)introduction to many of the features I'm not using on my project, even though we're using Ant 1.6. I have a renewed interest in upgrading our buildfiles now. <li>Stu Halloway's <i>Design Patterns Revisited</i> was a great two part talk on using reflection and AOP to simplify (or factor out altogether) some common design patterns. I especially appreciated his treatment of Iterator and iteration in general. His generic iteration helper class has me reconsidering my project's use of Commons Collections (although we're quite happy with CC in general). Stu has made a nice niche for himself in this area. I finally got around to buying his book <i>Component Development for the Java Platform</i> at the RMSS bookstore. <li>Another Erik Hatcher session, <i>Tapestry by Example</i> held my interest a bit less than the other stuff. This isn't Erik's fault, it's just that web frameworks don't really hold my interest very well. I did feel that the overview was important for me to see, and that's what I got, and more. <li>Ted Neward's two-part <i>Effective Enterprise Java</i> talk was entertaining and informative. One of the more effective and amusing bits was when he used two audience members to demonstrate the concept of a two-phase commit. What was so effective was that he mapped 2PC onto a common human transaction -- a marriage ceremony (yours truly being one of the "transactional resources" in the demonstration).<br> There were times however, where I have to admit that the enterprise development issues Ted brought up were so various and many and intertwined that it got a bit overwhelming. Still, the issues that he brought up must be considered when developing enterprise systems, and Ted is obviously encyclopedic in his knowledge. <li>Next up was back-to-back SOA talks by Justin Gehtland: <i>SOA Explained</i> and <i>SOA with Axis and WS-I</i>. Fabulous job in both cases. <i>SOA Explained</i> did a good job convincing me that I already had a pretty good handle on the 30k-foot level of SOA (especially the part where nothing much has really changed, diagram-wise, since I was a Vitria BusinessWare consultant in '99). <i>SOA with Axis and WS-I</i> was much more about code, and Justin did a great job of demonstrating just how easy it is to create web services with Axis and also of describing and demonstrating the implementation of WS-I standards implementations via Axis' layered request-handling architecture. <li>I also went to this great talk with the provocative title of <i>Strangling Legacy Code</i>. Well mainly I went because I had to present it :-). <li>After my session, I stuck around for Nick Lesiecki's <i>AOP Applied</i> talk, which was very organized and informative. I definitely left with a better understanding of AOP, both conceptually and in practice, but I have to admit I've not quite come to grips with moving it into center stage on my current project. Thanks to Nick also for being very gracious when my talk butted right up against his due to a scheduling SNAFU (and my somewhat lacking time management skills). </ul> </p> <p>I really enjoyed this particular RMSS, and I appreciate Jay giving me the chance to speak. I now have the bug, or at least the beginnings of the bug. I'm considering developing another session on speculation of getting to present it somewhere. As a teaser, I'll say that it has to do with a couple of my favorite things: visualization and code.</p>