Blog

  • Agile Web Development with Rails First Impressions

    Can’t sleep (as usual) so figured I’d write up my first impressions of Ruby and Rails after reading the first 8 chapters of Agile Web Development with Rails Sunday afternoon. Let me precursor this with I’ve only read 8 chapters in 1 book in a 7 hour period over 2 days. Anything stated below are my first impressions, and my opinions are preliminary and fleeting at best. As I learn more, I know what I think will change.

    Rails? Really nice.

    Ruby? No opinions yet, don’t know enough about the language.

    ERb? Hate it.

    Rails itself, at least from an implementation standpoint, seems to do all the things people hand-code themselves a lot of times. They keep re-iterating convention over configuration. This statement scores a lot of points with me because there are a lot of frustrating things I’ve had to do with Java projects. OpenAMF + Hibernate + Spring == XML hell. While I usually don’t have to deal with it since I’m client boy, I inevitably was drawn in on a few occasions, and hated it. I don’t mind configuring something if it’s going to work when I’m done, but time and time again, I felt like I was doing a form of coding (as were the Java guys) whilst playing with XML. I’m sure it scales, but I never really saw it run for more than 1 hour.

    I’ve been pretty shielded from the ColdFusion project I’m currently on. The JRun + CF + SQL setup was an all day affair, and I only had 1 hiccup since. While I attribute part of that success to an extremely talented team, I must say I’ve been impressed; the only times things break is when my code is involved. In all fairness, the server-side code isn’t really worthwhile without the client, and vice-versa. Can’t test it till I get done and start to integrate.

    Still, the VO’s are a monotonous pain to write, and I’m sure the server-side CRUD methods are as well. It should by automated at this stage of the game.

    I remember when learning OOP, then design patterns, then frameworks like ARP and Cairngorm, you start following conventions. They are known, ingrained, and the decision to use them is intentional. You knowingly write more code to accomplish the same thing knowing that the extra code pays off later. This is where I’ve seen conventions, in a small part, pay off time and time again. So, while I’m sure there are a few things Rails disregards on purpose, I have faith in conventions, and how they have improved my programming results over the years. Thus, I have faith in Rails.

    I still think, though, configurations are powerful and should not be disregarded. Just not sure where that fine line is, nor the ramifications for crossing one or the other.

    It boggles my mind to think this hasn’t been implemented yet in Java, CF, or PHP yet. I’ve heard briefly information about Tapestry, and when it was explained, it sounded like the same thing, only the AWDWR book took a stab at it. I know CF has a gazillion frameworks for it, and even read 2 blog entries about CF on Rails awhile ago, so I’m sure someone’s already got something “good enough”. I’ve heard of Cake and a few other PHP frameworks, but the thing I’ve always found about PHP stuff is that unless you can read and understand PHP, you cannot really grasp the power of most of what I’ve seen. For example, going to the bookstore, or even your local user group, and you get someone to give you the gist of Fusebox for ColdFusion, or Rails for Ruby… but Cake for PHP? I don’t know, I just get the impression that the communities are smaller, and those who get it are smart enough to do so without documentation, or some sort of developer evangelism. Bottom line, I don’t trust my knowledge of server-side frameworks to really question that something of Rail’s caliber doesn’t already exist. I just know in reading those 8 chapters, I got it pretty quickly and would rather do that than write DAO’s in PHP all day. If I were a full-time server-side developer, I would probably know more about what tools are truly available and thus would have better context.

    Nothing to say about Ruby yet.

    The ERb’s bring back nightmares of ASP & PHP projects I’ve seen which have sql statements embedded in the page, and someone wanted me to “modify” it. Ugh, run. While I think their templating mechanism is straightforward and simple, I still feel that ERb’s are gross. One third of that is my past experience with ASP, PHP, and JSP which is admittingly (and thankfully) little. For simple projects, or simple data accessing components for Flash, they do their job and do it well. For anything else, hell no. The 2nd third is because to me, CSS & HTML are limiting. While HTML & CSS certainly offer a neat way to show text, display it, and control layout (for the most part), the whole page based metaphor feels like it’s only scratching the surface of Ruby on Rail’s potential. While I think they did an effective job using Controllers to not only give scoped variables for the view to use and built-in mixin methods which inject functionality at runtime, it’s the actual “pages” that makes me dislike it. Why pages? I know, I haven’t hit the AJAX parts yet, but still, I’d rather use Flex to handle all of the state, sections, and even session data. However, I can’t figure out yet how I’d write my Controller code once you add a stateful client to the mix. Steven says you can expose Ruby as webservices… perhaps that’s the ticket?

    Furthermore, it’d be really neat to learn some of the guts of the automation routines and write MXML & AS files on the fly, compile with mxmlc, and generate those auto-CRUD pages into a single SWF; a Flex app with a richer, and more central & self-contained GUI as a front end. Again, those CRUD pages aren’t necessarily supposed to be your de-facto admin pages, but if you have a better GUI tool that can integrate into Rail’s automated nature, why not use it?

    Overall, the ActiveRecord, after talking to Steven on the phone, and then reading about it Sunday, pretty much is what hooked me. While I still feel the pull of databases driving my projects, writing a class representation of a table and having that transparently save, update, etc. is just off the hook. I still don’t get why some of that stuff, like parent_of and foreign keys, etc. isn’t automated, but the book had a few footnotes talking about database disparities.

    Either way, it’s fuggin’ pimp looking for a version 1.0 framework.

  • Passing ActionScript Classes to ColdFusion via Remoting

    Something I just found out today is you can pass ActionScript classes to a CFC method via Flash Remoting. I was under the impression that this only worked in OpenAMF, AMFPHP, and Flash Remoting for Java. I have publicly stated in the past that it cannot be done, and I was wrong in doing so.

    Typically, the structs I get back from ColdFusion are either objects with properties that have uppercase names, or arrays of structs. I write Factory code in either Flash or Flex, ARP or Cairngorm, to convert these transfer objects to value objects which are basically ActionScript classes that match their CFC counterparts, property for property. This is done so both I and the server-side developer can be on the same page when we discuss what a “Person” really means. If we both have a class that has data for the person defined in properties in our respective languages, it allows us to communicate effectively, both in code and over the phone, email, and IM.

    A lot of time is spent writing Factory code, and is one of my frustrations with using Remoting with ColdFusion. OpenAMF isn’t any better if you don’t have a Java guy with Flash Remoting and/or OpenAMF experience. While your VO’s may technically work, you’ll spend weeks configuring it. AMFPHP just works.

    However, as of today, I found out you CAN send ActionScript classes instead of just plain Object’s to a CFC method as long as you do 2 things:

    1. Wrap it in an Object with 1 property. That property must be named the same as the cfargument tag
    2. Make a deep clone of the VO you are sending back

    If your CFC’s cfargument tag looks like this:

    <cfargument name="someVO" type="struct" required="false" default="" />

    Then you’re service call in ActionScript looks something like this:

    var clonedVO:SomeClass = myVO.clone();
    service.method ( {someVO: clonedVO} );
    

    Notice how the someVO matches the cfargument tag’s name. The first part makes sense, but the clone still baffles me. Regardless, it works, and cuts down on 40% of the time I spend writing Factory code to transpose ActionScript value object classes to plain old vanilla objects.

    This post is irrelevant with Flex 2 and ColdFusion > 7.0.0 since Remoting works like you’d expect it to (at least, from what I’ve seen in the demo’s, haven’t played with Mystic yet).

  • Chunk vs. Picard, Juggernaut, & Ruby on Rizz-nails Weekend

    *** Warning: links are not work safe ***

    BANG, BANG sucka (turn up your speakers), I’m the Juggernaut. Imma hit chu wif ya own pimp!

    Talked to Steven Wednesday night, guy who sent me bang bang, about Ruby. I got to ask a bunch of questions about it and apparently, it does all the crap I hate doing in back-end code for me. Her majesty’s gone for the week, so I’m going to give Ruby & Rails a run through this weekend; gotta bunch of docs to read + 2 hosts. Ben Jackson I believe already wrote a Remoting-esque implementation for Flash so at least this isn’t 100% new territory.

  • How to trace every remoting call without ServiceCapture

    This isn’t a replacement for ServiceCapture; it should definately be used when you are doing some serious debugging between your client and server (or HTTPLook which isn’t as good with AMF traffic). However, if you have your own debug window, or just want another way to do it all in Flex 1.5, Flash MX 2004, and Flash 8, here’s how:

    import mx.services.Log;
    import mx.remoting.Service;
    
    private static var contructedApp:Boolean = contructApp();
    
    static function contructApp()
    {
            Log.prototype.onLog = function(message:String):Void
            {
                    trace(message);
            };
            _global.mainLog = new Log(Log.DEBUG, "mainLog");
            Service.prototype.log = _global.mainLog;
    }
    

    I believe that’ll show HTTPService calls for Flex 1.5 as well. Naturally, you can route trace in the onLog to whatever you want, or even use a Delegate to have the onLog function point and/or do something entirely different.