Uncategorized

Why I don’t read books

I’ve never read a programming book. I realized this when I got sent a promo copy of the Flex 2 with Actionscript 3 book from Friends of ED. [Side note: start blogging and you get sent free shit.] I was flipping through the book and I realized, wow, I’ve never read one of these before. So it got me thinking about why that is. Clearly people learn programming stuff through books, there’s got to be a market or else they wouldn’t make the books. Am I the norm or the exception?

Timeliness
First I figured this was because this was a Flex book. I’ve been following Flex for a while now, and the newest information has always been online (like any emerging technology these days). So in a sense everything contained in this book has already been written one way or another. The newest information will never be in print, that’s just the nature of the web. If I want the newest info on Apollo I’m going to read the alpha release docs on Adobe Labs, or Mike Chambers’ blog posts, or watch the apollocoders mailing list. The Apollo books are coming, but they’ll always be a big step behind what’s available online.

But then I realized I’ve learned bunches of other stuff that wasn’t brand new. When I was first learning PHP and MySQL there were tons of great books available. But for some reason I never bought a book. Maybe I’m just too cheap (discussed below). Or maybe I’m just too lazy. My bookshelf doesn’t have any programming books (at home or at work). The only books I’ve ever partially read were for some CS classes at school, but that was more to make sure I got the info that was going to be on an exam.

The copy/paste factor and learning by doing
Whenever I’m learning anything computer-related I’m doing it as I’m learning it. That’s the only way I can learn, and I’d be surprised if you find anyone who’s all that different (when it comes to computer programming). You’re not going to learn how to program Actionscript or use Photoshop by reading a book without having one hand on the mouse the entire time. So that means you read at your computer, with the book next to you? Or you read a chapter, then go and try it out on a computer? As I was flipping through the Flex book, I saw lots of Actionscript code. There’s an entire example app that gets created in that book. Cool, but that’s pretty much useless to me without being able to run the code myself, and tweak it a bit and see the results. You’ve got to be able to copy and paste the code and run it yourself. Book publishers know this, so they include downloads or CDs with the code. But now I only need the book for the non-code pieces, which brings me to my next point.

Learning from code versus learning from written paragraphs
I’d be interested in getting other developers’ perspectives on this, but I was thinking about how I learn and whether I learn more from example code or from written text describing the code and the method of programming. If I were to rate learning through code or learning through text, each on a scale of 0-5, I’d give learning through code a 5 and learning through text a 1. If a tutorial doesn’t have code I don’t read it. I think Google code search is the best learning resource ever.

So if we look at the ratio of text to code in this book, I’d say it’s at least 50-50 text-to-code. I’d be interested in seeing the ratio of comments-to-code included in the Flex framework source files. In terms of learning Flex, the framework source is the single most valuable resource I’ve had. They commented the hell out of it, but the code is the focus. You want to learn how the ComboBox component animates the drop-down menu when it gets selected? Go and read the source of ComboBox.

On-demand learning
I don’t know what I want to learn tomorrow. I might play with some custom components I’m working on, or play with Flex mapping components, or explore how to deploy my apps as Apollo apps. Or I might not ever learn any of that stuff and I might go off on some other tangent instead. So am I going to get a book about any of that? No. Am I going to read tutorials and comprehensive guides before I start playing? No. I’m going to start a project, try to do what I want to do, and when I can’t figure it out I’m going to look up what I need to know. Which brings me to my next point.

Learning in tiny bits
Books are too long. There’s just too much information in them. I learn in tiny nuggets, and I only learn the stuff that gets me to the next step in a project. If I’m working on a project and I need to figure out how to pull in an RSS feed into a flex app then that’s exactly what I want to learn, and only that. Once I get stuck at another point then I’ll go and figure out what I need to get past that point. But I don’t want to read a book that tells me in generic terms how to use a technology. I might never use half the information in a book, so why would I waste my time learning it?

The web gives me tiny bits of info that I need. And if you’re searching for programming information on Google, you can pretty easily figure out how to search and get directly to the result you need. It’s rare that I try to look something up on Google that I can’t find the answer to (obviously it happens, at which point I post questions to mailing lists). And the number of tiny bits of information is amazing. Whether it was a question someone answered on a mailing list, or a blog post, or an example in official documentation, somewhere someone has shown you how to do almost everything you want to know. And often you can find an answer to a specific question without wading through irrelevant content. Google is like learning surgery as you’re cutting, books are like medical school.

I’m a cheapskate
And I don’t like paying for something I can get for free (wow, that statement applies to so many other things). Everything you need to learn ANY programming language is available for free online. That said, book publishers can feel free to send me free shit, I like getting stuff for free, even if I don’t really want it.

I guess it just boils down to how different people learn. I’m sure tons of people have had great experiences learning from books. I just don’t get it. I can’t figure out why I would want to buy a book and read it when I can learn everything I need to learn by going online. So I don’t know, am I the norm or the exception?

Standard
Flex/Flash/Actionscript

Why I LOVE Flex – Charting example

Oh man. Take a look at this example I whipped up last night. This takes the google-finance-esque charting example from Brendan Meutzner and steps it up a notch. Now we’ve got two sets of charts, overlapping each other so we can easily compare the data. Drag the selected range of either of the charts using the sliders on the bottom portion and you’ll understand what I’m talking about.

This took me literally 3 hours to whip up. Hot damn. Show me an example like this in AJAX that didn’t take months to create. Hell, just show me an AJAX example at all.

This is a real application, not just a pretty demo. My girlfriend is a clinical psychology Ph.D. student at UC Berkeley. She’s running some psych studies and needs to compare data they captured from different subjects in the study. So as I’m talking to her last night and she’s describing what she’s trying to do, I think, gee, that sounds like it would be a sweet little Flex app. (In case anyone’s wondering, the sample data I published here is not from real subjects, so don’t get all privacy-advocate uppity on me) So I get to play with fun charts in a real-world scenario, and UC Berkeley gets some free Flex work.

Anyway, click the screenshot below (or this link) to launch the example. Right click to view source, or view source here.

chartcompare_screenshot.jpg

Standard
Flex/Flash/Actionscript

Try to read this code

I often use the ?: format for conditional tests (Wikipedia tells me this is called a ternary conditional expression), it makes code short and sweet and often easily readable. But I was digging through some of the Flex framework source (mx.containers.Panel line 801) and came across this line:


vm.bottom = o.bottom + (isNaN(btb) ? 
  (controlBar && !isNaN(btt) ? btt : isNaN(btl) ? bt : btl) : 
  btb);

Honestly?

I’ve used conditional expressions a lot, and even nested conditional expressions occasionally, but adding that third level of nesting makes a line of code that I can hardly read. My head almost exploded.

Standard
Flex/Flash/Actionscript

Flex Panel component with ControlBar docked to the top instead of bottom

Today someone asked on flexcoders if you can make the Panel component dock the ControlBar component to the top of the Panel instead of the bottom of the Panel. The short answer is no, you can’t. The longer answer is you can extend Panel and make a few minor adjustments and then yes, you can.

Here’s an extension of the Panel class that allows you to specify a new property: controlBarPosition, which can either be “top” or “bottom”.

The one caveat about this class is that if you set the control bar to be placed at the top, you should set the roundedBottomCorners style of the Panel to false. Otherwise the bottom corners of the control bar will be drawn rounded as well, which looks kind of weird if they’re not at the bottom of the panel (if you’re curious why take a look at the source of mx.skins.halo.HaloBorder, around line 470).

View the source.

This movie requires Flash Player 9.

Standard
Flex/Flash/Actionscript

ImageMap component added to FlexLib

I’ve added a new Flex component to FlexLib: an ImageMap component that is an attempt to replicate client-side image maps in HTML. If you know about image maps in HTML then this component should be self-explanatory. Basically it lets you define clickable areas of an image, either rectangles, circles, or polygons. THe component dispatches various events for those hotspots, such as mouse over, mouse out, click, etc. So you can capture the mouse events and do whatever you want, like launch the link by using navigateToURL(), which is what would most closely resemble the HTML image-map functionality. But you can also do anything else you want when the event fires.

I tried to make it so you could basically just copy/paste the HTML code that you have for an existing client-side image map. So your MXML might look like this:



    
    
     WA
     OR   
    
  
  

You define the

attribute either using MXML or AS (I used MXML in the example above). Then within your map tag you have a series of

tags. Each area tag should have a shape attribute and a coord attribute. Basically you should be able to generate your image map in whatever you use already (DreamWeaver, etc) and just copy and paste it into your MXML Flex app.

View the documentation
View the source of the example MXML file.

To get the source of the ImageMap component, download the FlexLib project from Google code.

Here’s the example:

This movie requires Flash Player 9.

P.S. I stole the image map of the USA from the fine people at HotPads.com. Don’t sue me guys!

Standard
Flex/Flash/Actionscript

FlexLib demo shown at 360Flex Keynote

Just thought I’d do a quick post with a link to the demo of FlexLib components that Ted Patrick showed at the keynote on the 3rd day of 360Flex. The demo shows most of the components currently in FlexLib. Right now my brain’s a little too fried to remember if there’s stuff in the library that I didn’t include in the demo. Check the source out of the svn to actually get the source for any of these components.

I’m planning on including the rippling water effect in FlexLib as well, along with the smoke/fire effects. But those aren’t in there now, I’ve got to find some time to work on them a bit more before they’re ready to go.

Anyway, here’s the demo.

If you want more info on FlexLib, read over the wiki pages on the project page. If you have questions just email me. If you want to contribute your code (and you all should!) then read the wiki page about contributing. Basically you’re going to send us your code (or a link to your source) and we’ll start integrating it into the library. Once we give your code the FlexLib stamp of approval you’ll get set up as a contributor and you can submit code to the repository yourself.

360Flex is now over, I just got home from San Jose, my head’s still spinning, bed is calling. I might try to write up my thoughts on the 360Flex conference overall and eventually do a post or two. Or not, we’ll see. Gotta say it was sweet though, good times all around.

Standard
Flex/Flash/Actionscript

My RSS Reader featured in 360Flex keynote! Here’s the newest version with smoke

This morning was the kickoff of the 360Flex conference. I got an email last night from Mark Anders from Adobe who was giving the keynote letting me know that he was going to show the RSS Flex app I made during the keynote. SWEET! I was excited to see it up on the big screen this morning.

Here’s a photo of Mark presenting the RSS reader:
360Flex Keynote

Be sure to check out the 360Flex photo stream on flickr for more pictures from the conference.

He got to show off the newest version I updated a bit. I added the colored smoke effect last night. And during the day today I made a slight change to the rotation effect. It now rotates either left or right, depending on if you click an icon to the left or right of the currently selected icon (thanks to Alex Uhlmann for this suggestion). And it defaults to load the Flex category when it first loads, because we all know that’s the most important category.

View the newest version here.

The whole day overall was awesome, thanks a million to Tom Ortega for getting this whole thing together. I enjoyed the sessions today, but even more I enjoyed meeting a lot of the people I’ve only known through blogs or email. I got to pass out a bunch of my ridiculous business cards. If you haven’t said hello, find me at the conference over the next two days. I still don’t have any challengers to show me a more ridiculous Web 2.0 business card, so I’m going to claim the title until someone steps up to the plate and hands me something utterly ridiculous.

Standard
Flex/Flash/Actionscript

New Flex Component: Convertible TreeList

Here’s a Flex component I made a few weeks ago and never got around to blogging about. It’s included in the FlexLib library. This is a component that combines the List and Tree controls that are included in the framework. This was inspired by the left nav menu of the new Flex Style Explorer. That app has a navigation menu that can be displayed either as a Tree control, if there is enough space, or a list of icons if we need to conserve space. I figured that was a great way to display the same data two ways.

So you can have one component, set the dataprovider once, and you can switch it between showing the data as a Tree, text-only List, icon-only List, or a text and icon List. You can set the mode property of the control to determine how it displays.

So what?
It came to my attention today that the reason for this component isn’t as obvious as I thought. So I’ll try to explain. This component is for the situation where you have a list of items in a Tree, but you might want that Tree to take up much less horizontal space, so you want those items to be displayed as a straight List of text or icons instead. Normally what you would do is have two controls, a List control and a Tree control, set the dataproviders separately (since a List can’t take heirarchical data) and swap one out for the other if you wanted to change them. This component makes it so you don’t have to do any of that swapping yourself, it’s done for you, and all you have to do is set the mode property of the control.

Take a look at the documentation on FlexLib. Here’s a direct link to the source code of this component in FLexLib. The best way to get it though, is to check out FlexLib from the SVN repository.

Here’s the example. The top component shows how you can dynamically set the mode. There are four options, Tree, text List, icon List, and full List. The bottom examples shows a more real-world example where you would want to change the mode depending on how much space you have available.

This movie requires Flash Player 9.

P.S. Thanks to Jeffry Houser for donating the flexlib.net domain!

Standard
Flex/Flash/Actionscript

Flex Effects: Watery Reflection with Fire and Smoke

I’ve been having fun playing with simulated fire, smoke, and now a water reflection effect in Flex. Here’s a screenshot. Click the screenshot, or this link, to view the effect live. I’m not putting the live swf directly here on the page because my blog’s already got a few fire effects playing, and this one’s particularly CPU intensive since it’s got 3 different effects running at once (and not only that, but the live reflection water component reflects the live fire and smoke effects).


water_fire.jpg

Standard
Flex/Flash/Actionscript

See you at 360Flex!

Just thought I’d do one of these “I’ll be at 360Flex” posts that everyone’s doing. Come find me and say hi. I look silly, like this. I’ll be attending the sessions all three days.

And here’s some more fun with fire and smoke effects in Flex:

This movie requires Flash Player 9.

Standard