Blog

  • E4X Doesn’t Suck

    I’ve spoken on past occasions about how un-excited I am about E4X (ECMAScript for XML) with regards to ActionScript 3. Macromedia (now Adobe) made a strong push for XML for 3 player versions. Flash Player 5 had both a built-in XML parser as well as the XMLSocket connection. Flash Player 6 greatly optimized the XML parsing routines and Flash Player 7 did it again.

    Problem was, for application developers dealing with nTier systems (fancy way of saying connecting to various backends), XML wasn’t the most succinct way of communicating, and those messages sometimes were a non-portable, made up language. By then, I was delving into the worlds of WebServices and Remoting. While SOAP implementations utilize XML in the underlying guts of how it works, you as the developer certainly feel like you’re writing regular code talking to code on some other server.

    So, in building a prototype app using Flex 2, Cairngorm 2, and Ruby on Rails, I’m dealing with copious amounts of XML. I feel like I’m in middle-school again. It frightens me to hear myself say that as that same arrogant, holier-than-though attitude of non-big-company technologies is what I used to loathe when talking to Enterprise programmers. I can remember not just me, but countless others accomplishing a lot with just XML strings parsed by hand with very effective outcomes.

    Either way, the thing that is different now is that I have E4X at my disposal. I’m the only one on the planet who feels that the old syntax is ok to use instead and isn’t overly verbose. I guess growing up with firstChild.childNodes makes you numb to the pig-latin you speak in code to get at your data. E4X, unintentionally, I perceived as more verbose because I am trying to learn as well as all the ActionScript 3 packages, mx packages, and countless other new API’s & methodologies at the same time. Spending 40 minutes on getting a new for each loop to work, referring to the docs twice, is all the temptation I need to say, “Fuggit, the old way works just fine, I know it well, and it’s faster at runtime than E4X anyway… why bother with this bs when the syntax isn’t that much cleaner?”

    Many would disagree. I debated with the top Flash minds twice in the past, all with next to no support. Many fawn over it. While I was visiting my boss in Des Moines, Iowa, he took it upon himself one evening to show me some refactored XML to E4X code. He was overjoyed… I didn’t care. Granted I was happy he was happy. He went from 5 verbose lines to 3 cleaner ones.

    “Ok… you’re still parsing… parsing blows.”

    I don’t have a choice with Ruby on Rails. Maybe I do, and don’t know it. There is so much stuff I don’t know about ROR, but I’m going with what I got, and what I got is a consistent and readable messaging schema between Flex and Rails. Rails sends easily understood XML messages, and the ones I send to it, it can read just fine. However, after writing my Delegate to speak the CRUD methods to my Rails controller methods, I really wasn’t looking forward to writing a gigantic Factory class to convert Rails XML messages to Array’s of Value Objects, and vice-versa.

    I’m still not, but found a really easy way to implement it. And thus, I get to why E4X doesn’t suck… I didn’t know it, but E4X supports binding, just like Flex does for binding variables to other variables. Suddenly, my ValueObjects who already implement a toString method to ease debugging:

    public function toString():String
    {
            var s:String = "";
            s += "[class ProjectVO";
            s += " id=" + id;
            s += " projectName=" + projectName;
            s += " updatedDate=" + updatedDate;
            s += " creationDate=" + creationDate;
            s += " ]";
            return s;
    }
    

    Now have a nice way to get their XML equivalent:

    public function toXML():XML
    {
    	var updatedDateString:String = DateUtils.getRubyDateString(updatedDate);
    	var creationDateString:String = DateUtils.getRubyDateString(creationDate);
    	var xmlified:XML =
    		<project>
    			<updated-date type="date">{updatedDateString}</updated-date>
    			<creation-date type="date">{creationDateString}</creation-date>
    			<id type="integer">{id}</id>
    			<project-name>{projectName}</project-name>
    		</project>;
    	return xmlified;
    }

    Now, for my HTTPService, I can just do:

    service.send ( myProjectVO.toXML() ) ;

    It’s also really easy to update in case the Rail’s side changes for whatever reason. I usually can just copy from ServiceCapture, paste into the VO class since XML can now be written without quoting rules, and swap the values with bindings to the VO’s public properties… nice!

    I don’t apologize for all the things I said, but wouldn’t have been so non-enthused had I known about bindings.

    …so… uh… anyone got Remoting working for Rails yet? Or at least a WebService way of using Rails vs. frikin’ HTTPService?

  • Searching for Warmth in a Label

    I’m having a tough time at my current job. The project itself is going well, though, and the code I’m writing is cool and fun. I’m a consultant working with a small team on a large software project. My 2 failings are being ineffective in communication with the client and not giving accurate time estimations on tasks. There are a plethora of other minor frustrations, but the reason, to me, they are a big deal is that it has all caused me burnout in a 2 month time frame. I typically go in 6 to 8 month intervals. The bipolar reaction from manic to reserved state is easy to see in retrospect. I was subscribed to over 40 email lists, most of which I read and responded to regularly. Reading the blogs was a 6 times a day routine. Nightly I’d dive into something code or technology related.

    Now, I’m not subscribed to any email lists, hit the blogs twice a day, and generally don’t even respond to personal emails. I’ve nearly exhausted my supply of games, and am ever searching for additional outlets, physical preferably at this point. I awake early and skip lunch to ensure I am not interrupted when her majesty arrives since I work from home and get easily distracted when not alone. This allows me to “clock out” earlier than normal. Daily, I pull from emotional reserves, almost scraping my deep set beliefs, all in an effort to conjure up a positive attitude to wear for the day. I refuse to mope around like some pathetic survivor. I’m in this game to win or die trying.

    Two separate, non-related events happened recently that really negatively directed my opinion towards my current career course. I immediately started to recognize the difference between Contracting and Consulting. At least, they were perceived that way to me. I started to write a blog entry in my head… and figured I’d go do some reading before I made up my mind. Even before that, I figured I’d give it some time… a lot of time. A few days to churn on my thoughts, and finally some spare time to read. Contracting vs Consulting on Google pulls up a lot of results. The first 10 provided a lot of good reading on just one instance of this comparison in the blogsphere. Even cooler was the comparisons between the UK and US which I can somewhat corroborate from talking to friends in the UK.

    My goal was to get a real sense of the word, Consulting. The comparison to Contracting helped, but so did the wide array of opinions. I had assumed that if you were in consulting, you were a consultant. However, it seems a lot of people are seeking identity through the term, and this offends others who view said terms as mere unimportant formalities that have very little substance. I found common ground on a lot of the writings and it’s nice to read something out of my Flash / Flex / CF comfort zone. It’s also nice to know the majority of the definitions revolve around perception. While its’ natural for software engineers to loathe a loosely defined term (how could something so good, OOP, lead to soo many passionate flame wars for example?), one clear theme is that the definitions of the words contracting and consulting are in the eyes of those procuring their services, and are hence re-enforced after the fact to those who fit the client’s mold of what the word meant to them. So, while at first glance Consulting may mean someone who advises, and a Contractor may mean hired code muscle, both definitions quickly crumble under scrutiny.

    I was hoping to affirm, deny, and challenge my assumptions, and I feel this is a really good first pass. When things start to suck, I tend to do a lot of quick justifications for my situation. I dare say I do my best to ensure 100% are NOT delusions constructed to deny the inevitable and/or obvious, but rather silver linings, and hopefully better perspectives. For example, in all the times in my career where I hated my current situation, I could always find some redeeming factor. Not necessarily redeeming of the forces that contributed to my suffering, but rather some positive and endearing that arose, and continues to do so while I am still there. While it’s sad I need to get into such dire straits to really appreciate and even recognize some, it’s not always that way. I’m pretty quick to recognize good learning and growing opportunities, whether good or ill, regardless of the weather. It’s just easier on the willpower if you give it some reason(s) to buttress it up.

    Case in point, 5 years ago I was at the studio at my former job furiously clicking away at 11:30pm at night, alone on a Friday night, my 3rd one in a row. I was building a website for my boss to sell his house. Rather, I was making changes that my boss wanted via email communication. What did I learn? Don’t use Fireworks to build a website. I use Fireworks to this day for mockups, image editing and compression as well as it being at the hub of my production art workflow. You don’t, however, see 37signals spouting, “Yes, we use Fireworks-created image maps for every page of our site.” And, those tortuous 6 weeks got me extremely good with Fireworks.

    Small potatoes in the grand scheme of things, but valid for me nonetheless.

    Either way, some hour and a half’s gallivant on Google to challenge assumptions has confirmed some, denied others, and learnt me on some new concepts. The jury’s still out, but two things are certainly clear. First, I have no intention of consulting the rest of my life. I had a lot more enjoyment in contracting, and labeling myself under either of the definitions is not what I want to do longterm. Secondly, I have a ton more to learn about consulting.

    Yes, I’m aware the statements contradict themselves, but the latter receives precedence. While I’m frustrated I have no tact with clients, and I refuse to give up when Flex won’t take my 32bit transparency thus taking more hours than approved, I recognize I have a lot more to learn, and should withhold any long term judgments. I’ve learned a lot already, those lessons are valuable, and the influx of them hasn’t slowed down.

    …still, f’me this is frustrating. Flex? You my bitch. Consulting? :: WHAP! :: Thank you… can I have another?

    Some good links I found on just the first page of a Google search. I’m sure if I read some books, periodicals, and talked to others I’d get some more context. Still, this was great for just a 1 hour investment.

    Great Overview of the definitions

    One take on how you are sought after

    10 things to ensure you don’t do with your client

    Consulting vs. Contracting

    Followup

    Original Article

    .NET’rz rebuttal

    Recruiters?

    Honesty

    Best Response

  • Ruby Chronicles #1: Blocks and Yield

    A “wtf” at lunch today while reading this book. There is a section on the 2 types of blocks in Ruby’s methods, and a description of the “yield” method. Totally jacked; it’s basically like sending an anonymous function in ActionScript seperate from a method’s parameters. The function then in turn runs that block of code for every yield statement. The yield statement can also pass parameters to this code block. Why you’d do this is beyond me, but when I yield, I’ll be using yield… imagine that?

    For example, here’s Ruby calling a method, passing a block that the yield will run inside of the method:

    def method
       puts "start of method"
       yield("this'll be arg1", "this'll be arg2")
       yield("this'll be arg1", "this'll be arg2")
       puts "end of method"
    end
    
    method {|arg1, arg2| puts arg1 + ", " + arg2}

    It’ll output (I think):

    start of method
    this’ll be arg1, this’ll be arg2
    this’ll be arg1, this’ll be arg2
    end of method

    The equivalent in ActionScript 1 is:

    function method ( someFunc )
    {
       trace("start of function");
       someFunc.call(this, "this'll be arg1", "this'll be arg2");
       someFunc.call(this, "this'll be arg1", "this'll be arg2");
       trace("end of function");
    }
    
    
    method(function(arg1, arg2){ trace(arg1 + ", " + arg2); });

    Which outputs:

    start of function
    this’ll be arg1, this’ll be arg2
    this’ll be arg1, this’ll be arg2
    end of function

    The only difference is the ActionScript example sends it as an argument whereas in Ruby, it appears to be sent as a seperate entity from the methods invocation parameters.

    Don’t get me started on the Archeologist degree one needs to read printf statements…

    Anyway, weird stuff.

  • Flickr’s New Non-Flash Organizer

    Just read Nathan Pitman’s report about the updated Flickr Gamma version. One particular note was the Organizer is no longer done in Flash. Scanning the the announcement page, help page, and bug list, I couldn’t really find any information or context as to why. Anyone have any more info?