Learning Flex development the 2.0 way (part 1)

When I decided to take a look at Flex, I quickly realized that learning a new language today is completely different than it was when I learned C or C++ (more than 15 years ago!). Yes, since that time, the Internet grew a lot and makes the learning process much easier today since so many information is just a click away from you nowadays.

So, I’d like to share and discuss with you some ideas or comments on what can be found on the web that can help learning Flex. If you’re interested, follow me on my Flex learning journey (part 1).

There are so many different resources available on the Web that I tried to classify them in different categories. I’m not sure that my classification is the best, I think I changed it already two or three times while writing this post ;-) So, don’t hesitate to leave a comment if you think there is a better way to classify these resources or if I missed any.

For each category, I tried identifying the “providers” and the “consumers” as well as the easiest ways to find them (i.e. who publishes, who reads, how to search for them). Again, please consider these as inputs for discussion and leave a comment if you disagree or want to complement any of my choices.

Here are the six major categories that I identified so far:

Code samples

Code samples are (usually short) code extracts showing how to do something (usually very) specific. They are very common on blogs, forums, web sites or mailing lists.

I consider that code samples can be classified in the following four sub-categories:

“How-To” answers

Code samples belonging to this category are an answer to an “How to” question such as: How to display icons in my DataGrid? How to style my button? How to format a date? How to apply strike through in a TextArea? How to change itemRenderer at runtime?

They are often provided by people that were searching for answers to the related How-To question and either didn’t find any, or considered that what they found wasn’t the best possible answer.

In many cases, this kind of code sample doesn’t provide much information apart from a direct answer to the How-To question. There are usually tens of different ways to address a particular point, and “How-To” samples provide one of them and “ignore the others” (if they don’t, then they’re probably more part of the Tutorial category).

Comments associated to such “How-To” answers often provide very interesting additional information (sometimes even more valuable than the initial raw answer). People interested by the topic but that weren’t able to apply the answer the answer to their specific case can bring very useful information through their questions and the author (or other commenters) answers.

Anyway, the most common profile for people searching for such samples is a developer wanting to do something very quickly, without necessarily wanting to understand how to do it or why others are doing it this or that way.

“Problem” answers

Code samples belonging to this category are explanations of a particular (usually unexpected) behavior. They aren’t very common (as far as I know at least) despite the fact that there are plenty of people searching for them1.

People looking for them have usually already implemented something and just want to understand why it doesn’t behave as they expect. Examples of such queries are: Component initialized twice, stage.width problem, custom style doesn’t appear in properties, problem with auto-resizing datagrid, …

The reason why they aren’t common is that they’re supposed to provide an answer to many many many different unformulated questions. What I mean is that answering to the question: “Why is my component initialized twice?” is far from being easy without considering the particular context in which the issue is faced. So, even after someone finally found an answer to his problem and decides sharing it on his blog, he will usually reformulate it such that it becomes a “How-To” answer instead.

People searching for such answers are seeking help to fix their particular problem, they will often be disappointed (not finding answers) until they either reach a “How-To” corresponding to their need or a Tutorial making them understand their mistake or misunderstanding of the Flex framework behavior.

Anyway, there are cases for which the misunderstanding or mistake is so “common” that a specific code sample addressing it is easy to find (stage.width problem is a good example).

Tutorials

Code samples belonging to this category don’t necessarily provide ready-to-use code. They are usually examples illustrating the general concepts covered by the tutorial.

Tutorials aren’t providing solutions but step by step explanations and clarifications for a particular area. Instead of providing an answer (to your particular and specific question), a tutorial is providing enough explanations (at least, for good tutorials ;-) ) such that, after going through it, you can answer to your initial question on your own.

For example, my tutorial on Styling Flex Custom Components doesn’t directly answer to your “How can I change the font size using CSS” question; but, after reading it, you should be able to understand where was your mistake and how to fix it2.

“How-To” or “Problem” answers categories are often (at least should be) linked to Tutorials to bring the best of both worlds to us. When reaching a “How-To”, you may be fully satisfied with the immediate answer but you may also want to “learn more” by looking at the related tutorial.

Snippets and Templates

Code snippets can be considered as “macros” allowing to “generate” a piece of code with “one keystroke” only. They can be managed using Eclipse plug-ins such as CFEclipse or Web Standard Tools.

Once a snippet is defined, you associate a shortcut that, when triggered, will copy the snippet code in your editor. You then just have to change a few parts of the generated code to complete the implementation. Common snippets are: getter/setter, AS Doc comment blocks, event handlers, etc.

The best here is that you can easily find snippets made by others event if there are less for Flex than for other languages as PHP or Java for example.

The difference I make between snippets and templates is that I consider the templates as a global canvas for a file (or a class) while the snippet is more of method level. I was planning3 to provide a Custom Component template file at end of my Flex Component Life Cycle tutorial. Again, this is clearly an arbitrary decision ;-)

I also heard of “Code Templates” in Eclipse but I didn’t have time yet to check what exactly is available for Flex. As far as I understood, the “Code Template” concept of Eclipse is very similar to snippets but it adds the ability of defining template variables that can be filled in a form when inserting the template4.

Coming Next

The next categories will be covered in part 3 and part 4 as soon as possible, stay tuned and excuse me for not publishing everything in one shot.

List of footnotes:
  1. Search for “<anything> problem” in the keywords leading to your blog and you’ll see what I mean []
  2. If it’s not the case, please let me know! []
  3. Uh, did I say that I was planning to provide a template for Custom Components? I should say: I plan to!! []
  4. Displaying a form asking the user to provide inputs used to generate the snippet is possible with the Snippet feature of CFEclipse. []
VN:F [1.9.8_1114]
Rating: 5.0/5 (10 votes cast)
Learning Flex development the 2.0 way (part 1), 5.0 out of 5 based on 10 ratings
Categories: Blogging, Flex Tags: discussion, Flex Email This Post
  1. No comments yet: be the first commenter!
  1. No trackbacks yet.
Put ActionScript or MXML code snippets between tags: [as3][/as3]
You can also resize the comment area by dragging the bottom right corner.