Tim's Blog

Category: Software Development (page 2 of 2)

Unable to resolve resource bundle “styles” for locale “en_US”.

Okay so I am hot on the trail of a bug in my AS3 application.  I save my application only to notice the following error message:

Unable to resolve resource bundle “styles” for locale “en_US”.

I say to myself “WTF” and just assume that my workspace is hosed.  I the rebuild my workspace only to be greeted by the same error message!

After about 4 hours of headbanging I am ready to reinstall Flexbuilder when I figure out what went wrong.  It turns out that I accidentally tried to include a class in the mx namespace in to an ActionScript project.

Here is the moral of the story.  If ever you find yourself with the above error message and you are working in a pure ActionScript project make sure your code does not have an import statement that references mx.

There are 10 types of people…

It is often said, “There are 10 types of people; those who know how to count in binary and those who don’t.”  Well depending on which type you are the game I created will either be a fun way to learn or an addictive way to pass the time.  I wrote a game using Flex 2 that gives players a chance to see how many numbers they can convert from base 10 to base 2 in 60 seconds.  Note the cool binary timer in the upper left hand corner.  It is a stand alone component that extends mx.controls.Label.  As always I have included the source with this post.

Source

Play

Happy Gaming

Timothy Huertas

Digital Ink Using Flex 2

My friend John and I were pounding some beers at our local pub when the topic of Digital Ink arose.  He thought it would be cool to capture a signature via the web using JavaScript.  Of course I then decided to implement the thing in Flex 2.  I got the digital ink working in less than an hour (which is a testament to how bad ass Adobe Flex 2 is).  But I soon realized that I was only half way to capturing signatures via the web.  A screen with a vector graphic signature is cool, but damn near useless.  To complete this task I needed to send the signature somewhere to be archived.  I started searching Google for code to convert a canvas to a bitmap and came across James Ward’s blog.  Rats!!  He had already done what I was trying to do.  I downloaded his source and noticed that my implementation of the digital ink is slightly different.  So I decided to publish my implementation after all.  I totally ripped off his “doSave” method which leverages Tinic Uro’s AS3 PNG Encoder.  That being said I highly recommend visiting his blog.  He goes in to detail on how to use remoting to send the image to the server.  Thanks to the both of them for their help! 

Source

Run Example
Enjoy

Timothy Huertas

PS For once this code is pretty handsome!

Random pearls of wisdom mixed with some whining!

Disclaimer
I am on a mission to compile a list of random thoughts on computer programming.  Below is the start of that list.  Most if not all of these thoughts have been expressed before, but I had to put my twist on them.  I welcome your feed back.  And if you want to add a random thought then that is even better.

Don’t be a poser.  If you don’t love computer programming then do something else for a living.
If you have never been compelled to work on a computer program for 16 hours straight then chances are you do not love programming.  I have gone on coding marathons that have rendered me brain dead.  There are times when I leave the office at night and can barely remember where I live!  Remember the kid who loved writing text based games on the Apple IIe in middle school; that was me.  Hell, I traded Mortal Kombat and StreetFighter 2 Turbo Edition for a commodore 64 just so I could program at home.  That’s love!  If you do not love programming then do the rest of us a favor and quit.  The last thing we need is for you to stick around and become a manager.

Don’t over engineer.
This is going to piss a lot of people off, but here it goes.  Just because you read the Gang of four book does not mean you have to try and bastardize their teachings to make them fit every project you work on.  Think about how a problem should be solved not how you can ho out a design pattern to solve a problem.  If you feel the need to show off to your fellow engineers then display the book in your cube for all to see.  But please, refrain from feeding your ego by suffixing every class you create with the word “Factory”. 

Do not use your powers for evil.
While working for a major company I was asked to screen scrape a 3rd party site to solve a problem.  At the time I was an inexperienced grasshopper and went to work on a solution right away.  In the middle of implementing the thing I had a moment of clarity and thought to my self “What the F am I doing!”  Screen scraping is dangerous.  What if the 3rd party decides to change the site in the middle of the day?  I can write this code, but I shouldn’t.  I mean a good surgeon could probably give me horns, but it would be really irresponsible.  That day I learned a very important lesson.  Sometimes certain solutions are just too risky for prime time. 

Know when to walk away (Diminishing returns).
I can’t tell you how many times I have left the office at midnight after trying to solve a problem only to have the answer pop in to my head on my drive home.  Don’t get me wrong I still go nuts every once in a while.  But I have learned that sometimes it pays to walk away for a while. 

Don’t write it if you can byte it.
If I see one more from scratch implementation of StringUtil I think I may go nuts.  And I am not talking Britney Spears “shave my head” nuts.  I will go Whitney Houston “Crack is wack” nuts!   If you honestly believe that you are pioneering something by creating a StringUtil then you must also believe that you are the first person to beat Super Mario Bros with one life.  The point is before you create something, ask yourself the following questions:  Is this a common problem?  Has it been solved before?  Will the existing solution suffice?  Can I maintain or is there a community to maintain the existing solution?  If you can answer yes to all of those questions then you have just saved yourself a lot of time. 

Don’t make crap harder than it has to be AKA KISS.
Which would you rather read? 

if( str.equals(“a”) )

{

      nextLetter = “b”;

}

else if( str.equals(“b”) )

{

    nextLetter = “c”;

}

else

{

    nextLetter = “z”;

}

Or this…

nextLetter = str.equals(“a”)?“b”:(str.equals(“b”)?“c”:“z”);

Look we all know that you can sling some wickedly dense code.  But other than showing off your kung fu skills complex one liners do nothing but piss off the poor sap that has to maintain it.  Enough said.

Switch jobs at least every 2 years when you are first starting out.
I have been called a job whore.  Okay maybe I am.  But let me remind you that most whores are good at what they do!  I usually learn a ton the first 6 months at a new job.  After that things start to become routine.  If you are just starting out then the best way to learn is to job hop.  The fact is most companies do not change/adopt new technologies often.  So if you want exposure to a variety of technologies you are going to have to change jobs often.  I, like most, do research on my own; but nothing is sweeter than getting paid to learn new things.  In addition with a new job comes a new circle of programmers to learn from. 

Don’t lie on your resume or during a job interview! 
I hate it when people lie during an interview.  So much so that my team and I subtract points from candidates who lie to us.  If I ask someone a question and they say “I don’t know” then I respect their honesty.  I don’t expect anyone to know everything!  What I do expect is honesty.  No matter how gangster of a tap dancer/BS artist you think you are you can not get away with pretending to know the difference between an abstract class and an interface.  And if you want to really rack up some bonus points say “I don’t know can you give me a short explanation?”  (If the interviewer says “no” then he/she is a big tool bag and you do not want to work with him/her anyway.)

Language does not matter.
For the most part, if you can code in one managed OO language you can code in any of them.  What really matters is that you understand object oriented principles.  After all, all you are really doing is creating instances of objects and sending methods to them.  Once you understand the basics, all you need is a syntax primer and an API and you should be ready to start slinging code. 
On a side note I just have to say…  I loath it when I get asked by recruiters, “how many years of experience do you have with XYZ language.”  I want to fire back with “how many years of experience do you have recruiting for programmers!”  Recruiters should focus on finding well rounded developers who write clean maintainable code.  Not some dense programmer that is content with using the same language for years on end.  Bottom line, spaghetti is spaghetti in any language!

Do not list your current employer on your resume.
I learned this the hard way.  One of my friends was a manager at a company I was working for.  One day he called me to his desk and showed me an email that went out to all of the managers.  It was a copy of my resume along with a note attached that read something like the following:  “this guy is looking for a new job.  As a recruiter I can help you retain him for a fee.”  It turns out that some ass hole recruiter was scouring the internet for résumés and contacting the listed current employer to offer “retention services”  That is bar none the shadiest thing a recruiter has ever done to me.  As a result of that experience I always list “Company Confidential” as my current employer. 

Find a mentor.  Be a mentor.
Find a Yoda!  Be a Yoda!  This is pretty self explanatory.  Trust me on this one.  No matter how much experience I gain I will always seek out someone who can teach me stuff.  In turn I pay it forward by teaching people stuff.

You don’t need some overpriced 3 million page programming book to learn something new.
Most programming books are longer than the bible and expensive as hell!  In addition I find them to be highly repetitive and often boring.  When I want to learn a new technology I use that technology to implement something cool.  For example, say you want to learn how to use Adobe Flex.  Don’t go out and buy some monstrous overpriced book; instead, bust out a Google search for a short primer and read it.  Afterwards, find someone who knows Adobe Flex and pick their brain.  Then set out on creating your master piece.  And I do mean master piece.  You want to keep things interesting.  The last thing this world needs is another address book!

Understand the following concepts. 
• Separation of concerns.
• Encapsulation.
• Inheritance/Polymorphism.

Wield the following tools.
• Debugger.
• IDE.
• Source Control.
• Unit Testing.
• API.
• User Groups.

Flex + Webcam + Motion Detection Code = Locomotion

I was bored so I decided it would be cool to mess with Flex and a webcam.  After a bit of research I came across 2 articles that inspired me.  Many thanks to the following awesome coders!!

Guy Watson
Toby Tremayne

With the help of their articles, I wrote a Flex app that will increment a counter when it detects movement over a specific area of the screen.  Click here to see the demo video.  It stars me in my first ever action movie.  Watch the counter increment as I wreak havoc on a 50×50 white square in the upper left corner of the screen.

Okay so the white square is kind of boring.  The point is the collision detection.  The square could easily be a speed bag or a slab of meat (Rocky Balboa style).

Click here for the source.

Click here to open the app.  If you don’t have a web cam hooked up all you will get is a black screen.

Enjoy

Timothy Huertas

NOTE:  The app is not perfect.  In particular it has memory issues.  All suggestions for improvement are welcome.

Enjoy yourself Charlie Murphy!

Okay so I decided that I am too lazy to make the code handsome.  It is ugly and borderline unmaintainable.  That being said, “Enjoy yourself Charlie Murphy!”

Click here to download the code.

Click here to browse the code.

Mac OS X dock using Flex 2

I thought it would be fun to try and create a Mac OS X dock using Adobe Flex 2.  Here is the result of a 2 night MXML and ActionScript slinging marathon.  I will post the code as soon as I tidy it up.

DISCLAIMER:

For those out there who love to hate. I know it is not perfect 🙂

Newerposts