I was asked by a friend recently to point him in the direction of some advice on unit testing within actionscript 3. I thought it may be useful to others so here is the email with some addition descriptions: What is unit testing Unit tests are methods that run in order to verify the output of a method is what is expected when given a predefined input. This is useful as you can check if your code does what it should. There is a whole world of information on this on the internet. Check out test driven development. History ThereRead more
This is the last blog post I plan to make about the terminology around TDD. There will be real life examples from now on. I have previously discussed the terms collaborators, subject under test (SUT) and test doubles. Here, I am going to describe the three types of test doubles you can use. The Real Thing If you have a simple collaborator which only really stores and retrieves values, like a model, then is it worth replacing it for testing purposes? I personally think as long as this collaborator is unit tested then it is okay. Once there is someRead more
I have been posting about design patterns recently and I am realizing that it would be useful to post about Test Driven Development too. As a gentle introduction I am going to go through some of the vocabulary. Test Driven Development is the process; Red, Green, Refactor. That is the easy way to remember it. Below is your workflow: 1) Write a unit test. A unit test is a method that tests another method. The test calls the method that you are testing and verifies that the response is as expected. Your unit test should always use the same inputsRead more
Background Reading The creation method pattern The Problem? You want to use objects that are created else where and are of a set type but the implementations may vary. Examples? SocketManager, or any thing that needs to be replace during unit testing. How? The constructor of my complex object: public class CharacterFactory { public static var factory : NonPlayerCharacterFactory; public static function getAPlayer() : IPlayer { return factory.getAButton(); } } The using of the creation method: var player:IPlayer = CharacterFactory. getAPlayer(); Why is it good? • It is easy to understand; it is a simple pattern that needs little extraRead more
Background Reading Read about the singleton The Problem? You want to have multiple instances of a singleton and want global access to them all. This may be because the objects use groups of resources, such as different groups of sounds, or because the objects need a lot of configuration, such as currency converters, or need global access, an event dispatcher. Examples? Currency converter, sound controller, global event dispatcher How? The Multiton: public class SocketManagerMultiton { private static var _instaces : Dictionary; public static const CHAT : String = “CHAT”; public static const WEATHER : String = “WEATHER”; public static functionRead more
I recently did my first public talk! It was at LFPUG (London Flash Platform UserGroup). Here are the details I think it went really well. I had some very kind feedback via email and twitter and also on the night in person! A few people have requested that I upload the examples I used and the slides so here they are. Over the next few weeks I am going to be posting example patterns with more information, in more depth than I did on the night. If you want me to cover a pattern please post a comment with theRead more
Hey ho! I have been pretty busy getting ready for my lfpug talk next month. It is my first public talk at a user group and I am a little nervous! I am sure a few drinks will help me through it. I have my own page on their site too. Check it out! I have been reading my Refactoring to Patterns book. After reading through it, Reafactoring and Design Patterns I am longing to work on a new project! Where I can put all of this good reading into use! I have been pretty busy looking at what isRead more
Hey, I haven’t blogged for some time. I will be more active from now on (I have said that before). I have been busy planning our wedding and we are buying a house. We have been approved by the bank and we just have to sit tight and wait to do all the legal stuff. I have been busy in the actionscript world too. I have been using asaxb and am loving it! I have also put my name down to do a talk at lfpug in October (wish me luck for that). I may post a preview here beforeRead more
I have been thinking a lot recently about the value of unit testing, doing TDD and coverage. I remember ignoring advise that test coverage was not a silver bullet. I remember reading articles explaining why but I have to admit I did not listen as much as I should have. I kept remembering a difficult code base I had to use that was unit tested whishing it was tested thinking that it would solve all my problems. I now think a little differently. The problems I face most are broken windows and software rot. It the java world people seemRead more
I have recently discovered the wealth of information available at the Adobe devnet site. I have been reading about the options surrounding video. I never took an interest in video when it first starting taking off so I was a little left behind. I decided to have a google for help and found some amazing resources on the devnet site. There are articles about the recording of material, the types and options for encoding and the different mechanisms of distribution. Thank you Adobe.