I am going to talk today about the importance of the coding standards and conventions.

I cannot stress enough on the impact that a nice, clean looking code does in contrast with a chaotic coding style that looks ugly and unprofessional. Maybe a person that is not a developer won’t understand the fact that the code can be nice or ugly, but I assure you that the developers do. If you are new to ‘the game’ this won’t be so obvious but experienced developers will instantly notice that something is wrong with the code, even though it might be fully functional.

Of course, an end user won’t see the differences but you will, after you’ll get back to that project that you did a couple of months ago. Working in a team is almost impossible without a coding standards document. Tensions will appear, arguements will arise and the team spirit will fall.  Imagine this scenario: You’ve always coded with braces on the next line. Your coulleague is using braces on the same line. One day, you will need to fix one of his classes. You can’t help yourself and you’ll move all of his braces on the next line in order to see the code better. When he will notice your changes, I assure you that he won’t be happy. This is just a small example of what might happen, and it’s not even that dramatic. Imagine you found a bug that is causing the company to loose money. The bug is flash based and the teammate that created the problematic class is missing. You need to kick in and fix the bug. His code is a total chaos. You get angry and anxious because it takes forever to track down the bug. You will loose the faith in the guy and the teamwork will suffer.

There is no standard in the industry, no standard is better than the other. The main idea is to be consistent with your coding style. There can be moments in your life when you need to change your coding style. These moments are when you are joining a new company that is working differently than what you were used to. Of course, the transition won’t be easy, but hopefully the guys will help.

Actionscript is not that special so you can’t complain about not finding standards to follow. Because there are not many out there. You can use any coding standards document available out there, because the differences between AS and JAVA for example are not that big.

The coding standards are also mentioned in the Adobe Edge. Some documents I found on Actionscript coding standards can be found here, here and here(AS2.0).

Soon, I will post a page with the most common standards that I use, which can be used as a quick reference.

So, now we have chosen our favourite coding standards and we have it all in our head. We’ll need to start applying. It won’t be perfect from the start, but you know that practice makes it perfect. But of course, some extra help won’t hurt. That’s where Flash develop comes into place. Flash develop is ‘the tool’ for coding actionscript. If you’re still using the Flash IDE for coding(and you you don’t own a Mac), please stop now. Forget the F9 shortcut. More about Flash develop will follow in another post. For now, we’ll just take a quick look at Flash develop Templates and Snippets.

The code snippets are a block of code that is used over and over again. In order to avoid writing this every time, you can just insert the snippet in your code. To access the code snippets from Flash Develop, you will need to open the Code Snippets Editor found at Tools->Code Snippets or by simply clicking on the icon from the toolbar. You can define as many code snippets as you want and you can format according to your coding style. Make sure that the language selected in the editor is AS3 and start customizing the snippets. You can add new ones that you find helpful. After closing the window, you can go to any AS3 document and press Ctrl+B. A list with all of the available snippets will appear and you’ll be able to select one, and by magic, you’re saved of a couple of seconds of coding and you can focus on the important issues. While editing the snippets you can use some Arguments that are parsed by Flash Develop in order to give you the flexibility you need. You can find a list with all of the available Arguments used by Flash Develop at this page of their wiki.

The templates are another cool feature of Flash Develop that I really miss in Flex Builder. Apparently Flash Builder will support templates, so these are good news. The templates allow you to quickly create the new file you want to add to your Flash project. Events, interfaces, classes are all different. You can define a template for each one, and this will save you other seconds or even minutes each time. You can define a template for anything you have in mind. In order to add or edit the templates, you need to go to Tools->Application files. This action will open an explorer window opened in the Flash Develop configuration folder. From there you need to navigate to Templates\ProjectFiles\AS3Project and simply add or edit the .fdt files found in that directory. You can edit with any basic text editor and even with Flash Develop. If you add for example, the Error.fdt file in that folder, the next time you open Flash Develop and right click on a folder, you’ll have the option to create your very own custom Error class.

The developers that are going to work after you on a project and your teammates will surely appreciate the new more organized you.

Happy coding!

Share this post:
  • Digg
  • Technorati
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • StumbleUpon
  • Twitter
  • email