The day I read about Flex Code Generator (FCG) with PureMVC support it seemed as though all the hassle of setting up a new project would be taken care of with the click of a button. Turns out it might not be as great as I'd hoped.
Upon opening FCG, you're given the choice of what type of project to create: Flex, Flex + Cairngorm, Flex + PureMVC, or PHP. I have only tested for PureMVC since that's our framework of choice. It generates 4 files to start: ApplicationFacade.as, MainView.mxml, MainProxy.as, and StartUpCommand.as in a package structure with model, view, and control folders. My main gripe with these pre-generated files is that they are not editable. When they are generated you can preview the text in them; however, you cannot change any of it. Plus I would like to be able to choose the name of my view component instead of defaulting to MainView.mxml, not to mention it extends Canvas instead of Application. Also, while these are mostly necessary files, I'd like to choose whether I need a MainProxy or not. You can delete unnecessary files but the package structure for it remains. And where is the ApplicationMediator?
Along with these auto-generated files are a series of options to create an Event, Singleton, Mediator, Proxy, or to import a Value Object or Service. Somewhere along the line creating a command got left out.
Creating an Event:
When creating an event you can choose from a CairngormEvent, Event, or a custom type. FCG allows you one variable to add to the event, which you get to choose only the type. For example, if you want to make a var that is a String you get a variable called string:String, no fancy names here. This is mainly ok, variables are easily renamed. The only potential problem I see with the generation of the Event class is that FCG puts the variable in the constructor.
Creating a Singleton:
This couldn't be more straightforward. You name the class and it gives you a perfect Singleton class. You add the rest. This is probably the best and easiest part of FCG.
Creating a Mediator:
You choose the class name, FCG adds 'Mediator' to it. Also it names the viewComponent the same as the class name.
The nice part about the pre-generated mediator is that it takes care of the listNotificationInterests and handleNotification methods for you. By default all mediators are static with a static name, though this is easily fixed through manual editing.
Creating a Proxy:
Pretty straightforward, again you choose the class name and FCG adds 'Proxy' to it. That's about it other than making the class bindable and static, which again is easily fixable through manual editing.
Importing a Service:
Select a Java, PHP, or C# file to import and input your endPoint and destination and FCG will generate RemoteObject and Responder objects, then include a service call for each method in your service that you choose to import. Fairly useful if you're into RemoteObjects.
Importing a Value Object:
This is a bit touchy, it only works occasionally for me. FCG asks you to import a Java, PHP, or C# file but more often than not it doesn't register anything in the file. Once you find a file that works, get ready for a load of new files. FCG generates the VO with optional getters/setters for each var, and a Proxy in which it includes an arrayCollection and a reference to the VO. Optionally you can generate an Event class that will include GET, GET_ALL, CREATE, UPDATE, DELETE, and SELECT events, as well as two view components, a form and a list, and their corresponding Mediators.
This is where it gets a bit confusing. For the list view it generates a list with a create and a delete button, and a mediator that listens for an item added, deleted, or selected from the list. For the form it is a textInput with a save button that will rename the selected item in the list. Although I can see the use of creating a view and its corresponding Mediator, the addition of ui components to the view class is a bit unnecessary.
The biggest change that would make me more likely to use FCG would be the ability to edit the text in the generated classes before publishing. Overall, I would recommend FCG for creating instances of certain files that are annoying to create over and over, but not an entire setup. FCG's most convenient feature is that it allows you to publish only selected files from the generated project as opposed to the entire set. Any one out there saving time with FCG?
4 Comments