The document summarizes the mvcExpress framework, which is described as the fastest and simplest AS3 MVC framework. It discusses the evolution of AS3 MVC frameworks in general and how mvcExpress aims for maximum simplicity and minimal performance impact. Code examples are provided to illustrate how mvcExpress achieves simplicity by removing boilerplate code compared to other frameworks like PureMVC. Benchmarks also show that mvcExpress has significantly better performance than alternatives for tasks like command execution, mediator registration/removal, and communication between components. Additional benefits mentioned are its modularity and features to help avoid errors.
3. AS3 MVC Framework evolution
Pros:
Cons:
• divide your code is small units • Slightly hurts performance
• Good unit communication • Lot of boilerplate code.
• Standardize your code
• focus on app instead of architecture
+ Enforce TTD development - Hurts performance a lot
+ Removed most boilerplate code
+ Hurts performance the least
+ Enforce modular development
+ Simplifies code to the maximum - Young framework
3
4. AS3 MVC Framework evolution
Pros:
Cons:
• divide your code is small units • Slightly hurts performance
• Good unit communication • Lot of boilerplate code.
• Standardize your code
• focus on app instead of architecture
+ Enforce TTD development - Hurts performance a lot
+ Removed most boilerplate code
+ Hurts performance the least
+ Enforce modular development
+ Simplifies code to the maximum - Young framework
4
6. mvcExpress is simple! – set up
• Set up PureMVC
registerCommand((“startUp”, StartupCommand);
registerProxy(new DataProxy());
registerMediator(new GameMediator(new GameSprite()));
• Set up mvcExpress – MORE OPTIONS!
commandMap.map(“startUp”, StartupCommand);
commandMap.execute(AnotherCommand, new CommandParams());
proxyMap.mapObject(new DataProxy());
proxyMap.mapClass(DataProxy);
mediatorMap.map(GameSprite, GameMediator);
mediatorMap.mediate(new GameSprite());
6
7. mvcExpress is simple! – commands
• PureMVC:
sendNotification(“new_message”);
override public function execute(notice:INotification):void {
// geting command parameters
var params:ParamsVO = notice.getBody() as ParamsVO;
// do stuff...
}
• mvcExpress
sendMessage(“new_message”);
// geting command parameters
public function execute(params:ParamsVO):void {
// do stuff...
}
7
8. mvcExpress is simple! – getting stuff in commands
• PureMVC:
// get data
var dataProxy:DataProxy =
facade.retrieveProxy(DataProxy.NAME) as DataProxy;
// get mediator
var testMediator:ViewMediator =
facade.retrieveMediator(ViewMediator.NAME) as ViewMediator;
• mvcExpress
// get data
[Inject]
public var dataProxy:DataProxy;
// get mediator
NOT POSSIBLE!!!
It is bad practice to use mediators from commands.
8
9. mvcExpress is simple! – Proxies
• PureMVC:
public class PureMvcProxy extends Proxy implements IProxy {
public static const NAME:String = "PureMvcProxy";
public function PureMvcProxy() {
var proxyData:DataVO = new DataVO();
super(NAME, proxyData);
}
// get and cast data object for convenience..
public function get dataVo():DataVO {
return super.getData() as DataVO;
}
}
• mvcExpress
public class MvcExpressProxy extends Proxy {
private var dataVO:DataVO = new DataVO();
public function MvcExpressProxy() {
}
}
9
10. mvcExpress is simple! – Mediator+View:
• PureMVC:
public class PureMvcMediator extends Mediator implements IMediator {
public static const NAME:String = "PureMvcMediator";
public function PureMvcMediator(initViewComponent:ViewComponent) {
super(NAME, initViewComponent);
}
// cast view for convenient local use.
public function get view():ViewComponent {
return super.getViewComponent() as ViewComponent;
}
// listen for framework notices
override public function listNotificationInterests():Array {
return [ //
DataNote.STUFF_DONE //
];
}
// handle framework events
override public function handleNotification(notice:INotification):void {
switch (notice.getName()) {
case DataNote.STUFF_DONE:
// do stuff…
break;
} } } 10
11. mvcExpress is simple! – Mediator+View:
• PureMVC:
public class PureMvcMediator extends Mediator implements IMediator {
public static const NAME:String = "PureMvcMediator";
public function PureMvcMediator(initViewComponent:ViewComponent) {
super(NAME, initViewComponent);
}
// cast view for convenient local use.
public function get view():ViewComponent {
return super.getViewComponent() as ViewComponent;
}
// listen for framework notices
override public function listNotificationInterests():Array {
return [ //
DataNote.STUFF_DONE //
];
}
// handle framework events
override public function handleNotification(notice:INotification):void {
switch (notice.getName()) {
case DataNote.STUFF_DONE:
// do stuff…
break;
} } } 11
12. mvcExpress is simple! – Mediator+View:
• mvcExpress:
public class MvcExpressMediator extends Mediator {
[Inject]
public var view:ViewComponent;
override public function onRegister():void {
// listen for framework events
addHandler(DataNote.STUFF_DONE, handleStuffDone);
}
// handle framework events
private function handleStuffDone(params:DataChangeParamsVO):void {
view.showStuff(params.dataParam1);
}
}
12
14. mvcExpress is fast! - Command execution
1600
1400
1200
Executions per 1 ms
1000
800 RobotLegs
PureMVC
600
mvcExpress
400
200
0
with nothing: with with Model: Model and
parameter: View call:
14
15. mvcExpress is fast! - Command execution
1600
1400
1200
Executions per 1 ms
1000
800 RobotLegs
PureMVC
600
mvcExpress
400
200
0
with nothing: with with Model: Model and
parameter: View call:
15
18. mvcExpress is fast! – communication speed
25000
20000
Executions per 1 ms
15000
RobotLegs
10000
PureMVC
mvcExpress
5000
0
1 receiving 100 200 500 1000
mediators: receiving receiving receiving receiving
mediators: mediators: mediators: mediators:
18
19. mvcExpress is fast! – communication speed
25000
20000
Executions per 1 ms
15000
RobotLegs
10000
PureMVC
mvcExpress
5000
0
1 receiving 100 200 500 1000
mediators: receiving receiving receiving receiving
mediators: mediators: mediators: mediators:
19
20. Extra perks
• Hard to misuse:
In mvcExpress you will have - what you need, where you need it.
No more no less.
• Modular:
Want it or not – you will be creating reusable modules by extending
ModuleCore.as class.
• Helps avoid errors:
mvcExpress uses conditional compilation very extensively!
Add ”-define+=CONFIG::DEBUG,true” to benefit from better error checking and
warnings.
20
21. Check it out!
• Code on gitHub:
https://github.com/MindScriptAct/mvcExpress-framework
• mvcExpress homePage:
http://mvcexpress.org/
• My blog:
http://www.mindscriptact.com/
21