I work with PureMVC - very popular and flexible framework .
Another tool that lets you enhance your work is FlashDevelop, it’s free, it has amazing templates and snippets to speed your work.
Now imagine what happens then those 2 meet each other. MAGIC HAPPENS!
There are couple of things that makes writing PureMVC not fun. That is:
- Creating proxies, mediators and commands. They must be written as framework demands it.
- Getting your mediators and proxies also annoys. It’s lot of typing – all this getting and casting…
Luckily with FlashDevelop file templates and snippets you totally remove the hassle of doing those not fun things in PureMVC!
Class templates: DerilsPureMvcTemplates.zip
this has to be unzipped to : your “Application files” folder - …\Templates\ProjectFiles
I will explain couple of things. That is special to my ‘style’ of using PureMVC.
- I name ‘notice’ for notification object. I use class “Note”,”ViewNote”, “DataNote” as constant holders. I wanted to separate those for quicker typing/code hinting. Just rename it in mediators and commands if you use something else.
- There are 2 variations of mediator and 2 variations of proxy, one with data/viewComponents sent to super class, and one that just keeps it locally. I rarely set it to super class, but sometimes it’s needed.
- I don’t bother casting data or viewComponent to it’s data type, and never will, I store them locally with needed type. Cast object every time you need to use it is a total nonsense, the only danger is setting different object for custom and super classes, but that’s easily fixed ovverideng setData/setVeiwComponent functions. What I did in templates.
- Code style: brackets on the line, package is not intended.
Snippets:
Get proxy(I named it “!retrieveProxy”):
var $(EntryPoint)$(CurWord):$(CurWord) = facade.retrieveProxy($(CurWord).NAME) as $(CurWord);
Get mediator(I named it “!retrieveMediator”):
var $(EntryPoint)$(CurWord):$(CurWord) = facade.retrieveMediator($(CurWord).NAME) as $(CurWord);
Usage scenario:
- ctrl+alt+ space to get class hinting
- write and pick class (mediator or proxy)
- use one or another snippet (I use keyboard shortcuts through macros)
- press delete to delete first letter.
- write deleted letter in lower case.
I create macro to use those snippets and map them on CTRL+ALT+1 and CTRL+ALT+2;
They look like this:
InsertSnippet|!retrieveProxy
InsertSnippet|!retrieveMediator
: initialize note constant quickly.
Depricated. I was using snippet to generate constants quicker:
$(CurWord):String = “$(CurWord)”
but lates FlashDevelop 4.0.0 RC1 does it automaticaly now.
Have fun.