Robotlegs and Signals
Just a short note for this, the first Flash Friday post of 2011. Just last week I started a new job in the social game space. It is a very exciting opportunity to work with some new people and learn new things. One thing to learn is the code base that they use, some which is open source. Two OS projects that I am now working with that I've never worked with before have caught my eye. These two projects are Robotlegs and Signals. First there is Robotlegs, an MVCS framework that is similar to PureMVC but if you've used any MVCS framework ( such as Cairngorm ) the concepts are similar. Robotlegs is cool because it does a really good job of keeping classes well decoupled through the use of metatags and injection. If you code any games or rich internet applications with flash I highly recommend giving it a look to see what you can use from it.
Second is AS3 Signals. Signals is an Observer pattern framework that you can use instead, or in conjunction with, the actionscript event model. I've been a fan of the observer pattern for a while, using the AsBroadcaster class back in AS2. When AS3 came around I relished in its event model, not because it was perfect but because it was better than using AsBroadcaster ( or rolling your own setup ). Signals improves upon some of the shortcomings of the AS3 event model in a few different ways.
All in all these are the two big new frameworks I am using at my new gig and I plan to share some lessons as I learn them. There is also much more that I'll learn about as well and I plan to share them as well. For now, check out Robotlegs and AS3 Signals and see what bits of them you can use or just get some good ideas for your own code. I hope if you do you'll share them in the comments.
Have you used either of of these frameworks? What do you think? Any gotchas you need to watch out for? I'd love to hear what you've encountered in the comments below.
Sunday Funnies - Roscoe's Rug Emporium
Back when I lived in Seattle we had a sketch comedy show that came on the half hour before SNL. It was great local comedy and many of the jokes just aren't funny to people outside of the Seattle area. However, some sketches seem to be funny regardless of locale. The following videos regarding Roscoe's Rug Emporium are two that always come to mind when I see furniture stores "Going out of Business." Watch and enjoy!
[youtube=http://www.youtube.com/watch?v=T0q1i2mqMgs&w=480&h=385]
[youtube=http://www.youtube.com/watch?v=0lIb_7KyOsg&w=480&h=385]
The molehill that is a mountain: 3d flash APIs
Last year around this time I wrote about what 2010 would bring in the world of flash. Write now I want to talk about one specific change that seems to be coming in 2011 - project:Molehill ( 3d APIs for flash Player ). The following video ( if you are viewing this on a flash capable device ) is from the announcement at this year's Adobe Maxx event.
For me this is quite exciting. Back when I worked at Provis we talked a lot about using 3D for web interfaces. Because we we're a video heavy agency we even had a 3D person on staff and we experimented with different libraries from time to time. Unfortunately, not much came of it as it never seemed worth the time investment to change our pipeline that much.
Now I work in the social media game space and true 3D in flash with decent performance opens up a whole new realm of games for social media. It does this just in time. Social media gamers are becoming mature gamers fast and will demand a better experience sooner, rather than later.
My only concern is that, as stated in the video above, these are very low level APIs and I have no experience programming 3D ( though I am very excited to learn ). This problem should be reduced by the many 3D framework projects that will use these APIs under the hood. Those frameworks I do have some experience with and it is quite fun.
So what do you think we will see in the social media gamespace ( facebook, mySpace, vKontakte, orkut, vznet, google me, etc. )? First person shooters? Racing games? MMORPGs? The first M in MMORPG means massive and this could really mean massive. World of Warcraft has something like 13 million users and Farmville still has around 55 million monthly ACTIVE users. That is a comparison that always makes my jaw drop.
Until then I'd love to hear what you think and even what you are working on.
Coming to the end of 2010
As we come to the end of 2010 I say, "Thank Goodness!" 2010 has been a very eventful year, and not necessarily in the best way for many of those events. 2011 is going to be different. I am making a commitment to post at least one blog posting a week on my blog. Heck, I might even post from my phone to keep them short and sweet occasionally. 2011 is going to be a great year and I'd like to share as much of it with you as I can. See you in the new year, or maybe earlier ;)
Improv 101 - My first class
Recently my therapist asked me what I do for fun. I tried to list out some things but my list seemed pretty sparse. In order to fill those gaps I signed myself up for an Improv class at my local comedy club, the Dirty South Comedy Theater. Going into the evening I was nervous, but in the best possible way. I had no idea what to expect but I had a pretty good idea that it was going to be fun. After the initial meet and greet we circled up and got the ball rolling. A friend of mine had told me that nothing from the real world exists in these improv classes and our first exercises made this clear. We did some very basic exercises to get into the mindset we needed for the class. After that we got into the rest of the night which was variations on the "yes...and..." theme.
The yes...and... practices were so much fun. The consisted of variations on 2 people on stage having a conversation where each following statement agrees with what the person said and adds to it, moving the story along. We still need some practice to know how to keep that story interesting but some very funny situation came to be on stage last night. Lots of fun and it will only get better.
All in all, last night was awesome and I can't wait for next week's class. Thank goodness the Dirty South has improv shows I can watch between now and then.
Watching Wrestling Again
It has been a long time since I've watched wrestling with any regularity since I myself retired from the ring. Occasionally something would bring me back for a short while. Jericho's code breaker return had me watching for a short while but I never quite kept up watching. The main reason? 2 little boys who I thought it wasn't good to watch wrestling with them because of their ages. Lately though I've noticed a couple things, one I miss wrestling and two my 4 year old loves wrestling more than I ever did and he's hardly watched it. So after reading Jericho's book I decided watching wrestling with my boys is part of being a good father. They enjoy it anyway and who better to teach them to be smart while watching it than a former wrestler?
So going back to wrestling is tough for 2 reasons. The first is I have no idea what is going on in any of the story lines. This is easily fixed by watching because they constantly remind you why every rivalry is where it is. The other tough thing about watching wrestling is - who the heck are these guys ( and gals )? I honestly don't know who many of them are and some people have changed so much they might as well be new guys.
Here is my review after watching 2 Smackdowns, a Superstars and part of Bragging Rights ( still working on watching it all with the kids ).
First off my almost 7 year old hates Cody Rhodes and told me, "If I hear the word 'dashing' one more time I'm going to go crazy." Of course, as a heel myself this gave me great respect for Cody and his "Dashing" gimmick. It's nothing new but he does it well.
I'm so glad to see Santino Marella is over with the crowds and still being a goofball. The few times I did turn on wrestling over the past few years he's been extremely entertaining. I loves me a good goofball and had some great comedic matches with a few myself.
The Nexus storyline with John Cena has my interest peaked. What direction are they going to go? Admittedly, I haven't finished Bragging Rights and they may have culminated some of my suspicions there with the Heavyweight title match. Though my kids and I got a kick out of the tag team match where Cena won all by himself.
All in all there is some really great new talent in the WWE right now that I haven't really seen much of. Its nice to see the burden is no longer on the shoulders of attitude era wrestlers - though they still seem to be given it from time to time. Here's looking forward to more wrestling adventures with the kids.
Testing if an object is in a set
One useful operator I've found when writing MySQL queries is the "IN" operator. The elegance of the simple statement to see if a value is equal to any item in a set is something I've alway wanted to have at my fingertip while writing much of the code I do in AS3. At some point I got tired of using something akin to as3corelib's ArrayUtils.arrayContainsValue function as I wanted to see if I could find a better solution for more readable code.
AS3's "in" operator
My first stop was AS3's "in" operator. At first it seemed like it might work and the code would look like the following:
value in [apple,banana,kiwi,orange]
Unfortunately, the previous line would only resolve to true if value was equal to 0,1,2 or 3. The in
operator only checks against the indexes of an array ( or the fields in an object ). So unfortunately it wouldn't work for my needs. It looks like I was going to have to roll my own and I wanted to see if I could create something that read like the following:
anyObject.isIn( ... args )
Actionscript is [still] a prototype language
Back in the days of AS1 and AS2 you could easily add functionality by adding to a class's prototype chain. If you wanted to add functionality to everything, all you would have to do is add to the Object
class prototype. The good news, is that this is still possible in AS3. The [not quite] bad news is that due to strong type checking you can't have a line like I wrote above without disabling strict type checking in the compiler. That's not something I'm willing to give up so I came up with something that could look like the line above but with strict type checking enabled it would look like the following:
anyObject[IS_IN]( ... args )
A little less readable than I would like but using the IS_IN
constant has a benefit of making it easy to import and use with Flex/Flash Builder. It also has the benefit of working with anything that extends objects which has some cool benefits. For instance you can write the following:
4[IS_IN]( 1, 2, 3, 4 ); // returns true
true[IS_IN]( true ); // returns true
true[IS_IN]( 1 ); // returns false
"foo"[IS_IN]( "foo", "bar" ); // returns true
If this sounds like something you might like to use feel free to download the file. I've also included my flexUnit4 test class which will show you more of how this can be used.
EDIT: There are some problems with this file as it was originally created as a proof of concept. For educational purposes I am keeping the original file up here and you can learn about the changes and why I made them at: http://ducharme.cc/flash-friday-is-in-refactored/
Caution: Example Code Ahead
Today's post veers from anything flash specific and goes to the more generic area of example code. For everything you want learn about in the world of programming there is some example code. Example code is a great way to see what book authors and blog posters are trying to explain in their posts. I'm a better programmer than a writer so I know how difficult it is to explain some of these concepts without showing code. However, example code has some issues that it is important to be aware of when you use it.
Comments aren't part of the example
Unless you are reading a book about writitng good code ( I recommend Code Complete by Steve McConnell ) the comments in the code are not there to show you good commenting practice. I could rant on and on how code should be self documenting and be able to be read like a good book but my main complaint with comments in most example code is stuff like this:
// define variable a as an integer and set it to 5 var a:int = 5
Now when you are learning about defining and setting variables this comment is important and that is why this comment is in example code. Unfortunately, I see this all too often in code I've had to debug. Code that is straight forward doesn't need to be commented. In case you don't know, comments like that in real world code scream amateur and/or I just copied this from the internet somewhere. Moving forward, you might want to make your code as straight forward as possible so you don't need to comment it.
Best Practices are rarely in example code
Recently I was reading a book on AJAX programming that was trying to show how to use a simple service written in PHP. To do this they had two input fields in a form where you entered numbers. The javascript would then send the values of those two fields to a simple PHP webservice that divided the numbers then returned the results. After that the results were parsed to show the answer on the screen. For the purpose of the book, which was to show how you could use a webservice without being overloaded with other code, this is okay. In real life, you should just divide the numbers using javascript and leave the webservice out of it.
Also, if you read books and blog posts word for word the authors know that what they are doing isn't meant for prime time so they will leave a caution warning ( possibly with a cartoony icon ) letting you know this. Please heed their advice if it is there, but since it usually isn't just realize that example code probably isn't the best way to handle the problem domain it seems to be solving.
My oh my!
This next section is about a pet peeve of mine, the use of the word "my" in example method and variable names. For instance, I sometimes run across code like the following:
var myName:String function myClickHandler( event:Event ):void{ ... }
Unlike the previous examples, I don't think the reasoning behind this convention in example code is strong enough to even use it there. The reason I don't like this convention is the readability of code that has to use it . Using the myName
variable as an example, which code appears cleaner and easier to read?
if( employee.myName == 'Jeff' )
or
if( employee.name == 'Jeff' )
I think you'll agree that the second example, without the redundant prefix is cleaner and easier to read.
The code doesn't always work
Anyone who has ever tried to copy or [GASP!] cuts and pastes example code has probably figured out that there is a high probability that it won't work. There are several possibilities for this from editors who think they know better to code that was only written in a text editor but not tested or even an errant copy and post from the author's IDE that forgot a semi-colon.
This isn't a problem in the way that the previous items are a problem with example code. Though it would probably be better if it didn't occur, its better just to know that your chances of perfectly working code are 50/50. In fact, non-working example code can be a good thing to debug. Especially when you consider a majority of your programming career ( or hobby for that matter ) will probably be taken up with debugging code that you swear should work.
What else?
While the heading for this section might make you think I'm going to discuss the overuse of if-else statements I'm really asking for your opinions on example code. Am I off base? Do you have your own issues with example code? Perhaps you want to discuss the overuse of if-else statements in example code or maybe you'd like to see more of them. Please, comment below and let me know.
[ad#Adobe Banner] If you liked this post please subscribe to my RSS feed and/or follow me on Twitter. If you only want to see my Flash Friday posts you can follow the subscribe to the Flash Friday feed. How's that for alliteration :) Until next time keep on coding.
What would it take to get to normal?
The other day I was listening to NPR talk about BMI or body mass index with regards to healthiness. I have always poo-pooed BMI because as a former personal trainer I know that it doesn't take into account actual body fat percentage. For instance, a well conditioned athlete might have enough muscle to be considered obese using BMI while somebody in the 'normal' range might actually be skinny-fat and thus too weak to really function on a day to day basis. And, as I looked for a link to the story I was listening to at NPR.org it looks like there were many follow-ups or alternate stories that feel the same way.
BMI is a bogus measurement
However, despite the reality that BMI is a bogus measurement I decided to get real on my personal situation. While I used to be a professional wrestler and a personal trainer, I have been 5 years retired from both and my fitness level is that of a social media game developer( my current profession ) but my eating habits have not changed enough to compensate. So right now I am sitting at 240 pounds which is considered obese by the BMI measurement for a 6 foot tall person.
On the flip side, 220 pounds is the top end of the overweight label for my height and 180 is the top end for the normal range. Its interesting to note that 180 pounds was my weight in High School, probably when I was most active without trying to add muscle. I know that 220 is realistic as I was about 225 when I wrestled. However, is 180 realistic? [ad#Google Adsense]
Getting real about the numbers
Let's go through the numbers, keeping in mind I don't actually know my bodyfat percentage right now. If I'm at 30% body fat ( which is high for a man but definitely believable ) than I have 168 pounds of lean body mass and if I could somehow lose the weight without losing muscle mass ( a very difficult task - though attainable ) then I would be at 7% body fat. 7% body fat is pretty low, especially for a social media game developer. Am I willing to lose muscle mass, is it still that important to me?
The truth be told, I could have a higher or lower body fat than 30%. If it is higher, 180 could be attainable without losing muscle. If it is lower then I can just kiss some of that muscle goodbye if I want to hit 180.
Do I even want to try?
Do I want to try for 180? That's a big goal. If I get to 180, will I have done it in a healthy way that I can continue for the rest of my life?
The answer is yes, I do want to make the journey toward 180 pounds and I'm going to use this blog to take you all along the journey with me. I say journey because I know that is more important than the destination. I might find a fork in the path along the way that is better for me and I will share that if I get there. For now, I have a destination and I just have to look through my old maps ( old personal training books ) and possibly get some new ones ( apps for my phone have helped in the past ). I guess one of those forks will come when I have to decide if losing muscle mass is worth it to me. [ad#Google Adsense] If you liked this post please subscribe to myRSS Feed and/or follow me on Twitter. If you only want to read my Wednesday Warrior posts subscribe to the Wednesday Warrior feed. Until next time, thanks for reading.
EMC 2010 Report - Just Another Magic Monday (Day 1)
The 15th through the 17th of July held a very special magical event. This event was the Essential Magic Conference. The first ever international online magic conference ( at least that's what I got from the marketing ). At a price of just 55 euros, it was worth every penny before the end of the first day. One participant even mentioned in chat that it was worth the price after the first session. Speaking of the first day, so far that's all I have gotten through. Sure, I listened and watch parts of the sessions from days 2 and 3 as they were happening live but its taken until now for me to have the time to actually study the first 3 sessions from day 1. As of last Friday, all 9 sessions are available online as video on demand for people who signed up for the conference. So, if you missed this conference in real time you can still get more than your registration fee out of these videos.
As someone who still considers himself a novice magician, I gained loads from the first day( and even the first session) with speeches, performances and presentations form the likes of Lennart Greene, Barry & Stuart, Ponta the smith, Apollo Robbins, Gaetan Bloom, Max Maven and many more.
While I gained a lot from everybody, I gained the most from a magical duo I hadn't heard of before - Barry & Stuart. They had a first day speech entitled, "Everything We've Learned So Far" [Registration Required]. What drew me in the most was an idea that their presentation kept dancing around and they summed up in one of their final bullet points as:
If you want to subvert your art, you need to first learn your craft.
While I have never come across as much of a rebel who would want to subvert much of anything, I do have this constant need to make things my own and I latched on to many of their ideas. Barry and Stuart are 2 young guys who have worked hard and created a niche and name for themselves in magic. And while there are many performances from day 1 I'd like to show my readership ( Ponta the smith's performance in session 1 comes to mind ) - I don't have access and permission to do that. So, I've looked up an entertaining video of Barry and Stuart for my magical and muggle readership alike. Enjoy. [youtube=http://www.youtube.com/watch?v=nFSkpwLEi-A&w=500&h=405]
[ad#Ellusionist] If you liked this post please follow me on twitter and/or subscribe to my RSS feed. If you only want to see my JAMM posts you can subscribe to the Just Another Magic Monday Feed.