Author Archive

No Fluff Just Stuff, April 2008

Tuesday, June 17th, 2008

With forecasts of April snow, our 2Paths contingent of two headed off at the crack of dawn one Friday for Bellevue, WA to attend the No Fluff Just Stuff - Pacific Northwest Software Symposium (NFJS). Having only spent 10 minutes at the border (whew!), we arrived early enough in the Seattle area to fit in some Fluff (aka shopping and dining) before getting into the Stuff.

After a quick introduction by Evangelist Scott Davis, and with hopes of winning an IPhone by the end of the weekend, I headed right into his double-bill of sessions about Groovy. The first one entitled “Groovy, the Blue Pill: Writing Next Generation Java Code in Groovy” was a good gentle introduction to neophytes like myself on Groovy basics. Now that my interest was piqued, I was eager to continue on with Scott’s next session “Groovy, The Red Pill: Metaprogramming, the Groovy Way to Blow a Buttoned-Down Java Developer’s Mind”. Never mind the Blue Pill - the Red Pill is where it’s at!

Scott’s enthusiasm for Groovy was definitely contagious, and my mind started churning, trying to think of ways to start introducing Groovy into current projects or future projects at 2Paths. An allure of Groovy is that it’s a dynamic language and can be run on the JVM. Groovy is implemented in Java, so the two languages offer seamless interoperability. Groovy compiles down to Java bytecode, so Groovy code can call Java code, and vice-versa. This would make integration into our existing infrastructure much simpler.

The Blue Pill was starting to take effect, as Scott showed us the terseness of the language. No need to labouriously write getters and setters, amongst other many nifty language shortcuts. Who needs semicolons or parentheses anymore? Because Groovy really is Java under the hood, programmers unwilling to let go of that extra baggage can continue to use it and nothing will break. We were then shown demos on how much more quickly we could bang out Unit Tests in Groovy.

In the next session, the Red Pill stuff was pretty mind-blowing. Introducing method pointers, closures, the ExpandoMetaClass. Method pointers make our code more readable and understandable by allowing us to alias methods with semantics tailored to our own business logic. Closures are an exciting and powerful inclusion in Groovy that aren’t available in Java, allowing us to pass around executable snippets of code. And last but certainly not least, there’s the ExpandoMetaClass that lets us either do a lot of really cool stuff, or get ourselves into a heap of trouble. With the ExpandoMetaClass we can intercept methods and inject methods into any Class. Scott showed us some fun examples that got us all fired up wanting to try more!

With my introduction to Groovy setting the stage for the weekend, I went on to choose more sessions on Groovy (Design Patterns, Testing, Groovy with Spring), but also attended other sessions such as Spring Configuration, Regular Expressions, and GIS for Web Developers. I found most of the other sessions mostly affirming knowledge I already had, but augmenting it with good snippets here and there that were new to me. Venkat Subramaniam was the other main Groovy Prophet, and I came home with his book “Programming Groovy” in hand, eager to start integrating Groovy at least into our testing infrastructure.

The atmosphere at NFJS was inspiring, as the speakers all had great enthusiasm for the technologies they were touting, and the audience was generally equally as keen. It felt great to be in a large conference hall amongst so many other like-minded programmers, all sharing, and getting fired up about what we do, and our seemingly unlimited potential. I fully recommend NFJS (regardless of me not winning an IPhone), and would love the opportunity to go again!

Persistence

Friday, April 11th, 2008

Any developers working on projects involving databases will need to be aware of persistence strategies, and take these into consideration at design time. Persistence strategies are tailored to specific projects depending on a variety of circumstances such as if they are read-only or read/write, how important the timeliness of data is within the application, and how likely it is for data-collisions, etc. If coupled units of work involve writes to various tables, the units of work will need to be wrapped in transactions to avoid data corruption, and have proper rollback strategies in place. Optimistic or pessimistic locking strategies need to be put in place where there are possibilities of data collisions. Appropriate isolation levels need to be associated with the transactions.

These concepts are all database-agnostic, but there are specific tools for use with Java, Hibernate, and Spring to assist in persistence strategy integration. For more information, see the wiki here:

https://dev.2paths.com/wiki/display/2pathsTECH/Persistence

A North Carolina PostgreSQL Adventure

Wednesday, April 4th, 2007

I recently attended a PostgreSQL Administration Course put on by the Open Technology Group in Morrisville NC. The course was excellent, covering a wide range of administrative PG tasks, and I learned lots of tricks and gotchas that I wish I knew many years ago when I first started using postgres.

Chander Ganesan
Our Instructor Chander Ganesan

The course was taught by Chander Ganesan who really knew his stuff. The pace of the class was very good, and Chander took lots of time to answer all our questions. There were 12 of us in the class, spanning a wide range of occupations, industries, and geographical locations, but we all seemed to have similar experience levels in postgres which made the class go very smoothly. I of course was the only Canadian, but at least I was not the only female as is often the case for me in the programming world!

Kurt and Jacob came from the Java world in Utah, working for Smile Reminder, a software solution for reminding patients of dentists appointments. Then there were Shane and David from Minnesota who work for the Metropolitan Airports Commission, where their mandate pertains to air traffic noise levels in the community. They felt right at home at our strange little microcosm by the Raleigh/Durham airport, with airplanes zooming overhead all day (and night) long, and kept us informed as to the appropriate noise levels we should be tolerating. There was a smattering of other states represented: Massachusetts, Florida, and even someone from Fargo North Dakota. It seemed like most of us were Java Developers, but there was at least one Python Developer in the mix too.

PostgreSQL Administration Course Students
Fellow Students (Kurt, Scott, Jacob) in front of our classroom

I’ve written another blog that covers the actual content of the course, so I thought I’d talk instead about our stay in North Carolina. Almost all of us had chosen the all-inclusive option, so the glorious Microtel Inn (with their Micro rooms) would be our home for the week. This was across from an eerily abandoned outlet mall that we endearingly referred to as “The Mall of the Dead”. We went on many dining expeditions, attempting to find culinary options other than Quiznos, Taco Bell, and the convenience store at the Mobil (which, incidentally, is where I dined my first night). The two gems that were my stomach’s saving grace were a great Indian restaurant, and Carmen’s, a really good and oddly out of place Cuban restaurant, yum!

Lunch at Carmen's
Lunch at Carmen’s

We soon discovered that North Carolina hasn’t yet tuned in to the wonderful invention called The Sidewalk. Well, actually, it seemed more like they had heard of them but didn’t understand their true purpose. As we trudged down the side of the highway in pursuit of a phantom movie theatre and restaurant district we had heard of, we would walk on perhaps a 20 foot chunk of sidewalk that would then abruptly turn into grassy overgrown garbage-filled bushwacking, and then nothing passable where we would have to risk our lives stepping onto the highway. But then we would come to intersections and there would be another 20 foot chunk of sidewalk just on the corner, coming from nowhere, and leading to nowhere complete with TWO wheelchair ramps. We wouldn’t want all those wheelchair users having to jump down the curb after 4×4ing through the bush now would we? We would want them to safely roll into the highway traffic instead!

Sidewalk to Nowhere
Sidewalk to Nowhere
Wheelchair Accessible Sidewalk
Wheelchair Accessible Sidewalk

On this particular adventure we were misinformed by Google maps as to the real location of the movie theatre, for when we arrived at a gas station 2 miles later (that according to Google maps was actually a movie theatre), we were informed by the friendly man at the counter that the movie theatre was still another 4 miles. Incidentally, before you trust Google’s directions, make sure your address isn’t truncated in the results. In this case, reversing the to and from addresses produced the correct results, but without reversing one address got truncated. Shame on you Google! We gave up on the movie and headed back, suburban bushwacking our way back to the hotel. The next night we got a little smarter and actually took a cab to a movie theatre, where all the guys saw 300, and I saw Black Snake Moan. Here I was, clear across the nation (in a different nation for that matter), and it was very 2Paths-like: all the guys wanting to see a movie all about death and killing, and me being the odd woman out!

Well, the course came to an end on Friday, just as a big storm hit the northeastern states. This of course interfered with a lot of flights, and one unfortunate classmate was informed he wouldn’t be flying out until Sunday. I crossed my fingers and hoped for the best, but no luck. My first flight to Chicago was quite delayed so my connecting flight to Vancouver left without me. That meant a motel in Chicago without my bag and a flight back home in the morning, which is where I sit right now, writing this.

It’s too bad - I would have loved to check out part of North Carolina, and also Chicago, but my only impression of these places is from my experience staying in motels near the airport, which doesn’t really reflect the true culture of the areas. At least, I’m assuming it doesn’t!

I’d totally recommend a class with the Open Technology Group. Perhaps in the future we could arrange to get Chander out to Vancouver. We have lots of sidewalks here!

PostgreSQL Administration Course, Morrisville, NC, March 2007

Wednesday, April 4th, 2007

In mid-March I attended a PostgreSQL Administration Course put on by the Open Technology Group http://www.otg-nc.com in Morrisville NC. Our instructor Chander Ganesan took us through the full gamut of PostgreSQL administration and configuration, from manual installation to performance tuning to third-party replication tools. Our course covered items such as secure access, user management, schemas, tablespaces, backup and recovery, triggers, and query plan analysis.

Chander Ganesan
Our Instructor Chander Ganesan

If I wasn’t already convinced of the necessity to migrate from PostgreSQL 7.4 to 8.x, this course certainly drove that point home. Many of the performance tuning configuration variables we delved into are not even available in 7.4. One fellow classmate noted a 25% increase in database performance after migrating to 8.x in their workplace. I will cover Postgres Configuration & Performance Tuning more in-depth in a future blog.

Performance aside, 8.x offers a lot of other improvements from 7.4. One thing I especially like is the ability to write functions with dollar-quoting instead of single-quoting which is the only option in 7.4. I’ve needed to write a lot of complicated PL/pgSQL functions, so this makes things a lot less of a pain.

In the course I learned lots of tricks and tips that I wish I knew long ago, such as the psql meta-commands \timing (logs all statement duration times to the client), \x (toggles expanded display), and \e (opens a vi editor for your query). I also learned that views can be mutable by placing rules on them that mutate the underlying tables. This is especially useful for restricting write access of specific table columns, or customizing write access to specific users.

The course also covered backups and replication. I found the point in time recovery section very useful. We also did an exercise of installing and configuring Slony for replication, which our company is now considering as an option. I will cover these topics more in-depth in a future blog.

Chander was extremely knowledgeable and very helpful in answering the multitude of questions we threw his way. The class size (12) gave the right balance between personal attention and good class discussions. The subject matter of the course was very relevant to the work we do here at 2Paths, and my training has been a catalyst in getting an action plan into place for our company-wide database version migration and performance tuning standards. I would highly recommend this course, and would also consider taking the advanced PostgreSQL Performance Tuning course as a follow-up.

Future Blog Installments:

  • Database Backup, Recovery and Replication
  • Postgres Configuration & Performance Tuning