Managing Static Assets in your ATG Application

The issue of where and how to manage your static assets for you ATG application is one that comes up in every application and every deployment.  This is my recommendation based on 13 years of ATG experience both on the development and ATG hosting sides of the house:

Application Assets” go in the EAR in your store’s WAR.  Application Assets include CSS, JS, and all the images used for the application look and feel: logo, navigation images, css images, and so on.  These files typically only change in conjunction with a code/JSP release, and they need to be easy for the developers to manage on their local development instances.  Keeping everything needed to build, run, and browse the application in SVN and built into the EAR makes it easy to run developer instances and be sure you have the correct versions of the assets, etc…  It also allows you to leverage things like pack:tag which I discuss in my post about Secondary Asset Loading Time.  My only complaint is that ATG doesn’t have a built-in mechanism for handling versioning of static assets, which allows you to set long expiration dates in the caching headers without the issue of stale browser caches corrupting the view of your site after a deployment.

Obviously you don’t want your JBoss instances handling every request for every static asset in production, but by utilizing cache headers, transparent caching on your web servers, or a CDN solution, this is easily avoided while still keeping all of the benefits of managing the Application Assets within the EAR.

Catalog and Marketing Assets” get deployed to the web servers.  These assets typically include product and category images, promotional images, white papers, PDFs, etc…  These files are changed frequently by the marketing team or by data feeds from an internal catalog management system on a schedule independent of code/JSP releases.  The files also tend to be larger.  The assets are often managed via SFTP, or ATG Publishing deploying to a Web Publishing Agent, or a combination of the two.

By managing your files in this way you get the most benefits with the least downsides.

First brush with Ruby On Rails

Earlier this week I was hanging out with a friend talking about a project he was working on and I decided to poke at it a bit with him, and as such got my first hands on experience with Ruby on Rails.

Ruby on Rails or RoR obviously has huge buzz and is a very popular web application development framework lately.  Lots of people have praised it and lots of great sites have been built using it.  I’ve never bothered to learn it myself for a few reasons.  First I’m a Java guy (ATG and Seam) and have been for years.  Given limited time and limited brain capacity I’d rather learn more Java/Java Frameworks/etc… than try to learn a whole new language.  Secondly many trusted friends advised me that while RoR does somethings REALLY well and makes some things REALLY easy, once you need to try to break outside of the pre-imagined structure/features that RoR provides out of the box, things rapidly go downhill.  Those reasons aside, the high level of buzz has meant I’ve always been somewhat curious, so this opportunity to finally get my hands a little dirty with RoR was welcome.

Getting started with RoR on Mac OS X is very easy.  It’s pre-installed and works right out of the box.  However after upgrading Rails and the gems I ran into a known blocking bug which after some Googling I was able to fix by downgrading rake to 0.8.7 in the Gemfile.  So not a 100% smooth start, but not too bad.

The Rails generate scaffold commands make it very easy to create a data object, the related schema changes (managed through the rake migration mechanism), and related CRUD pages and controllers.  You can be up and running very quickly and creating, browsing, editing, and deleting records.  This can make it very easy to get a basic application laid out, and provides lots of plumbing automatically.

I didn’t get much farther than some simple controller modifications, outbound e-mail sending, etc…  so I’m far from a real RoR developer.  However I ran into enough pain points so far that I don’t think RoR is for me.  I don’t want to start any language/framework wars, but here is what I ran into:

A lot of the “magic” seems great at first, but as soon as you want go outside of the box or tweak how things are working, it becomes a massive liability.  For instance when using the generate scaffold command to create data objects you can setup relationships/foreign keys by passing in a column name that matches the form OtherClass_id:integer, which will be interpreted to be a FK association to the other class’s id column to join the objects.  This is great.  However, what if you want to add two relationships to the same Other class?  For instance an Message has a Sender and a Recipient, both of which are Users.  I can use user_id:integer for one, but how do I do the other?  How do I use column/property names that don’t fit that naming convention, for instance I’d want sender_id and recipient_id.  None of the getting started guides I was able to find covered that.  Googling for things like “scaffold multiple foreign keys” didn’t answer the question, etc…  I’m sure it’s possible, but finding out how wasn’t easy, and the default way hides and obscures the actual plumbing so it’s not easy to figure out how to make simple changes or additions.

Data object classes in the app/model area all extend ActiveRecord::Base and as generated by generate scaffold are completely empty.  There’s no clue or indication of the fields, any logic available, any relationships, property types, etc…

Emailer classes use magic mappings between method names and e-mail templates.  Because it’s “magic” I have no idea how to change a template file name if I wanted to.  App/helper classes are created, but they’re empty, so I have no idea what they are doing, or meant to do.  And so on.  If I was an expert RoR developer I’m sure I’d know, or if I read a few books I’d understand, but starting from scratch and trying to learn as I go, it proved very frustrating.

The much touted RoR Community proved to be more of a liability than an asset to me.  Especially when combined with the many, rapid, backwards incompatible, RoR releases that have come out so far.  When looking for information, guides, and answers related to RoR you end up finding things spread all over: blogs, forums, mailing lists, Ruby sites, RoR sites, groups, etc…  Most of these posts/documents refer to older versions of RoR.  Most of them don’t have dates or specify which version they are working with.  Many questions on forums are unanswered.  The end result is you find what you hope is a reasonable solution for an issue only to find that the code sample or directions are written for a previous version of RoR, and trying to follow the instructions or paste the code in the current RoR version results in weird errors or worse.

Each new version of RoR seems to massively change and/or break common APIs and change how things are supposed to be done, etc…  I ran into several situations where it seems like a method was renamed, with no backwards compatible alias left in place, for no other reason than they wanted to change the name, which breaks older code for  no real purpose.

I’m also not a fan of weakly typed languages.  Strongly typed languages provide compile time validation, IDE auto-completion, and easy to navigate API documentation.  With larger, more complex projects, or projects involving many developers, or projects utilizing many 3rd party libraries, these advantages become significant in my opinion.

So from my standpoint, JBoss Seam provides most of the advantages of RoR, including several improvements, without many of the liabilities.  Plus it’s in Java which is my strongest programming language.  I’ll stick with Seam, but I’ll still respect the creations of folks who use other tools, including RoR.

Stealing my Resume? Try Learning ATG First.

Apparently someone decided to copy big chunks of my resume and put her name at the top and then go apply for at least one (maybe more) ATG positions. The resume got her a phone screen, but things quickly came to a halt when it became apparent that she didn’t know ATG at all.

It didn’t take long before someone figured out that her resume was actually my resume.

Imitation is the sincerest form of flattery?

It’s hard to fake your way in to “hard” technical fields where either you know your stuff or you don’t and it’s pretty quickly apparent which side you’re on. But the ATG community is so small that it’s doubly silly to try to pass someone’s resume off as your own.

Anyhow, I thought that whole story was pretty crazy so I had to share.

ATG User Group in Boston!

Spark::red ATG Hosting is pleased to sponsor an ATG User Group in Boston! We invite everyone who works with ATG software and technologies to join us on January 12th (Wednesday) from 6 PM to 9 PM for an evening of great food, free drinks, networking, and a few enlightening presentations.

Boston is a hub of ATG activity, and we would like to bring the community together for a casual evening of meeting new people and learning a bit at the same time. Both business and technical attendees are welcome and we plan to offer content for all audiences. We plan on making this a regular occurrence, but let’s kick off 2011 with a great ATG User Group event!

Click here: Sparkred ATG User Group – Boston for details and to register for this FREE event! I look forward to seeing you there!

JBoss Performance Tuning and MasterTheBoss

I review technical book manuscripts for a few different publishers, and recently had the pleasure of working on an upcoming book called JBoss Performance Tuning by Francesco Marchioni.  It’s coming out in December 2010 and will be a must have addition to your bookshelf if you deploy applications on JBoss.

The book contains extensive performance/load test results giving you hard data to work with when deciding which changes to make in your environment.  Some of the results were very surprising and the book has a lot of valuable data.

The author, Francesco Marchioni, also runs a popular JBoss related blog called MasterTheBoss.com.  There are a ton of great articles and posts there, so check it out!