Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Starting on a PureMVC multicore Fabrication generator gem  (Read 5086 times)
Steffen Egelund Jensen
Newbie
*
Posts: 7


View Profile Email
« on: February 18, 2009, 05:02:21 »

Hi everybody, especially Darshan.

I have been using puremvc for a while and got a little tired by the boilerplate startupcode needed for a new application. But still thinks that the whole idea ROCKS!!!! I know that copy paste helps a lot but found fabrication and saw that as the solution to my problems.

Still I would love to be able to only write the essential code of an app and at the company I work for, we could really benefit from a tool that could create app skeleton, moduleskeleton etc. etc.

Therefore I looked in to Dr. Nics Rubigen gem and has started on creating a gem that can do the above. I haven't really created an app based on fabrication yet, but wants the gem to create fabrication code. I have used the simple routing example as inspiration and for now it works quite okay. Have completed the first app skeleton with a single shell, mediator etc.

My question is whether someone has requests, ideas, template-code etc for such a gem?

I have convinced my management that it is okay for me to use workhours on this gem. So if anyone can help with ideas, code etc, that would be great and of course the gem will be publicly available if it results in anything useful.

Looking forward to hear from You.

Thank you in advance
Steffen Egelund Jensen
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #1 on: February 18, 2009, 07:13:13 »

It would be great if you could alter what classes things extended from. In my Fab app I use a custom base Mediator, Command, Proxy and ApplicationFacade which extend from the Fabrication bases. I do this to add certain custom functionality to my applications, and all of its modules, without having to constantly add the code to all the child classes. One thing that has always bothered me with code generation applications is that they never give a means to deviate from the traditional class hierarchy. Even a simple xml config which lets you select bases classes for each type (mediator, command etc.) would be a huge help. Otherwise, apps like this become useless to anyone that uses custom base classes for added functionality.

I actually use FlashDevlops built in template system right now. I just create broiler templates for each class and it allows me to edit them to fit my needs. Whenever I need to create a new Proxy, for instances, I just generate the class using the proxy template.

Still, it sounds like a very useful tool for most. Good luck!
Logged
Steffen Egelund Jensen
Newbie
*
Posts: 7


View Profile Email
« Reply #2 on: February 19, 2009, 01:20:47 »

It would be great if you could alter what classes things extended from. In my Fab app I use a custom base Mediator, Command, Proxy and ApplicationFacade which extend from the Fabrication bases.

Hi Jason

Thank You for your comments. It is of course possible to be able to configure the extending classes. But could You provide an example where this would be a feature users would need in general, just a proxy or something.

The reason I ask is  that gems has the inconvenience as far as I know that it gets its arguments from command line. This will make it a bit complex if I would include all the mentioned arguments. Another soloution would be to add component generators for this, such as a "generate proxy name parant_class ...".

What do you think?

/Steffen
Logged
Darshan Sawardekar
Sr. Member
****
Posts: 85


View Profile Email
« Reply #3 on: February 19, 2009, 07:55:23 »

Hey Steffen,

Thanks for trying Fabrication. The generator idea sounds really great. I have been meaning to do something like that but have been a little busy at work. I have used Rails a few times recently and it is always a lot of fun to work with.

I think the nicest thing to have would be Component generators. For instance most of my Proxies cast the data to the concrete data type for a little strong typing.

:
public function get list():ArrayCollection {
   return data as ArrayCollection;
}

The generator for this could be something like,
:
script/generate Proxy Name Parent DataType

Another generator I would love to see is the Mediator generator. I have added support for Reactions recently. Now if I have a flex component like an AlbumList.xml,

:
<mx:List id="list" />
<mx:Button id="refreshButton" />

And if I need a mediator for this like, AlbumListMediator. I could generate it using a component generate like,

:
script/generate Mediator AlbumListMediator AlbumList.mxml listChange refreshButtonClick

This generates the get componentName from the component and the reactTo method handler like
:
public function get albumList():AlbumList {
   return viewComponent as AlbumList;
}

public function get list():List {
   return albumList.list as List;
}

public function get refreshButton():Button {
   return albumList.refreshButton as Button;
}

public function reactToListChange(note:INotification):void {

}

public function reactToRefreshButtonClick(note:INotification):void {

}

Thats a lot of code to generate. But if you can get the ids from the mxml you can write the get componentName getters. Then the reactions come naturally. Also some bootstrap tasks would make sense. Like a plain old,

:
fabrication ProjectName ProjectType

Which generates the Main mxml or class and a startup command and possible a constants class. Another thing that can be scaffolded is any kind of undo that extends SimpleUndoableCommand. Some of this is crossing over into scaffolding type stuff rather than just generation. Looking forward to your thoughts.

peace,
darshan
Logged
Steffen Egelund Jensen
Newbie
*
Posts: 7


View Profile Email
« Reply #4 on: February 20, 2009, 04:45:21 »

Hey Steffen,

Thanks for trying Fabrication. The generator idea sounds really great. I have been meaning to do something like that but have been a little busy at work. I have used Rails a few times recently and it is always a lot of fun to work with.

I think the nicest thing to have would be Component generators. For instance most of my Proxies cast the data to the concrete data type for a little strong typing.
...

peace,
darshan

Hi Darshan

Thank you very much for your comments and ideas, I will look into how these can be implemented with rubigen. One obvious problem is that I would like to support custom packages for all application and component code, that means that I have to parse generated code to obtain the correct package etc for the new code or require it as a parameter which can be a bit cumbersome. Rubigen is based on ruby code, but due to Rails's convention over configuration they avoid this problem for their component generators. A controller goes into controller and model into model etc.

Would it be usefull if the component generators could generate a complete module with startupcommand, proxy, mediator etc with the correct namespace etc and perhaps optional parameters like datatype for the proxy. And the same idea for just a proxy or mediator generator?

Does this makes sense? The idea is that all the skeleton code gets generated, and perhaps som default usage code, which easily can be removed / modified?

Thank you in advance!
/Steffen
Logged
Darshan Sawardekar
Sr. Member
****
Posts: 85


View Profile Email
« Reply #5 on: February 21, 2009, 08:08:46 »

...One obvious problem is that I would like to support custom packages for all application and component code, that means that I have to parse generated code to obtain the correct package etc for the new code or require it as a parameter which can be a bit cumbersome.

You are right about the need to parse some code. You could get away with some of it if the parent classes are Fabrication only.

Would it be usefull if the component generators could generate a complete module with startupcommand, proxy, mediator etc with the correct namespace etc and perhaps optional parameters like datatype for the proxy. And the same idea for just a proxy or mediator generator?

I think the main project/module level fabrication command should at least generate,
  • MainApplication/Module.as/mxml
  • MainApplicationStartupCommand
  • MainApplicationConstants
  • MainApplicationMediator

The rest are a little project specific. Like there may be multiple proxies, mediators which would be hard to scaffold out. I have had projects where there wasn't any Proxy, and/or only one Mediator, but thats probably an exception than a rule.

Does this makes sense? The idea is that all the skeleton code gets generated, and perhaps som default usage code, which easily can be removed / modified?
I think it makes a lot of sense. The exact granularity is something that will come only after a little bit of experimentation. I remember the earlier version Rails scaffolds were not very clean. But the newer ones are pretty usable especially with some of the REST support.

For the custom base classes that Jason mentioned you could read something like a .extensions file in the project directory like,

:
command:foo.controller.MyBaseCommand
mediator:foo.view.MyBaseMediator
proxy:foo.view.MyBaseProxy

When not specified, the defaults are the Fabrication base classes.

peace,
darshan
Logged
Pages: [1]
Print