Mvc express presentation
-
Upload
raimundas-banevicius -
Category
Technology
-
view
4.899 -
download
0
description
Transcript of Mvc express presentation
mvcExpress -fastest and simplest AS3 MVC frameworks
Raimundas BaneviciusFeb 14, 2012Flash developer
2
1. AS3 framework evolution2. simplicity3. performance4. extra perks
???
AS3 MVC Framework evolution
3
Pros:Cons:
• divide your code is small units• Good unit communication• Standardize your code• focus on app instead of architecture
• Slightly hurts performance• Lot of boilerplate code.
+ Enforce TTD development+ Removed most boilerplate code
- Hurts performance a lot
+ Enforce modular development+ Simplifies code to the maximum
+ Hurts performance the least- Young framework
???
AS3 MVC Framework evolution
4
Pros:Cons:
• divide your code is small units• Good unit communication• Standardize your code• focus on app instead of architecture
• Slightly hurts performance• Lot of boilerplate code.
+ Enforce TTD development+ Removed most boilerplate code
- Hurts performance a lot
+ Enforce modular development+ Simplifies code to the maximum
+ Hurts performance the least- Young framework
ALL frameworks do the same thing!
… only new frameworks do it better!!
… and mvcExpress does it BEST!!!
5
mvcExpress is simple!
registerProxy(new DataProxy());
registerCommand((“startUp”, StartupCommand);
mvcExpress is simple! – set up
6
• Set up PureMVC
commandMap.map(“startUp”, StartupCommand);
commandMap.execute(AnotherCommand, new CommandParams());
proxyMap.mapObject(new DataProxy());
proxyMap.mapClass(DataProxy);
registerMediator(new GameMediator(new GameSprite()));
mediatorMap.map(GameSprite, GameMediator);
mediatorMap.mediate(new GameSprite());
• Set up mvcExpress – MORE OPTIONS!
mvcExpress is simple! – commands
7
• PureMVC:
• mvcExpress
sendNotification(“new_message”);
sendMessage(“new_message”);
override public function execute(notice:INotification):void { // geting command parameters var params:ParamsVO = notice.getBody() as ParamsVO; // do stuff... }
// geting command parameters public function execute(params:ParamsVO):void {
// do stuff... }
mvcExpress is simple! – getting stuff in commands
8
• PureMVC:
• mvcExpress
// get data var dataProxy:DataProxy = facade.retrieveProxy(DataProxy.NAME) as DataProxy;
// get data [Inject] public var dataProxy:DataProxy;
// get mediator var testMediator:ViewMediator = facade.retrieveMediator(ViewMediator.NAME) as ViewMediator;
// get mediator
NOT POSSIBLE!!! It is bad practice to use mediators from commands.
mvcExpress is simple! – Proxies
9
• 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; }}
public class MvcExpressProxy extends Proxy { private var dataVO:DataVO = new DataVO(); public function MvcExpressProxy() { }}
• mvcExpress
mvcExpress is simple! – Mediator+View:
10
• 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;} } }
mvcExpress is simple! – Mediator+View:
11
• 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;} } }
mvcExpress is simple! – Mediator+View:
12
• 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); }}
13
mvcExpress is fast!
mvcExpress is fast! - Command execution
14
with noth
ing:
with para
meter:
with M
odel:
Model a
nd View call:
0
200
400
600
800
1000
1200
1400
1600
RobotLegsPureMVCmvcExpress
Exec
ution
s pe
r 1 m
s
mvcExpress is fast! - Command execution
15
with noth
ing:
with para
meter:
with M
odel:
Model a
nd View call:
0
200
400
600
800
1000
1200
1400
1600
RobotLegsPureMVCmvcExpress
Exec
ution
s pe
r 1 m
s
2 times faster then PureMVC!
7 times faster then RobotLegs!
mvcExpress is fast! - mediator registering / removal
16
Register 1000:
Register 2000:
Register 5000:
Remove 1000:
Remove 2000:
Remove 5000:
0
10
20
30
40
50
60
70
80
90
100
RobotLegsPureMVCmvcExpress
Exec
ution
s pe
r 1 m
s
mvcExpress is fast! - mediator registering / removal
17
Register 1000:
Register 2000:
Register 5000:
Remove 1000:
Remove 2000:
Remove 5000:
0
10
20
30
40
50
60
70
80
90
100
RobotLegsPureMVCmvcExpress
Exec
ution
s pe
r 1 m
s
registers mediators
2 times faster then RobotLegs!
removes mediators
6 times faster then PureMVC!
mvcExpress is fast! – communication speed
18
1 rece
iving m
ediators:
100 rece
iving m
ediators:
200 rece
iving m
ediators:
500 rece
iving m
ediators:
1000 rece
iving m
ediators:
0
5000
10000
15000
20000
25000
RobotLegsPureMVCmvcExpress
Exec
ution
s pe
r 1 m
s
mvcExpress is fast! – communication speed
19
1 rece
iving m
ediators:
100 rece
iving m
ediators:
200 rece
iving m
ediators:
500 rece
iving m
ediators:
1000 rece
iving m
ediators:
0
5000
10000
15000
20000
25000
RobotLegsPureMVCmvcExpress
Exec
ution
s pe
r 1 m
s
12 times faster then RobotLegs!
6 times faster then PureMVC!
Extra perks
20
• 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.
Check it out!
21
• Code on gitHub:
https://github.com/MindScriptAct/mvcExpress-framework
• mvcExpress homePage:
http://mvcexpress.org/
• My blog:
http://www.mindscriptact.com/
22
Thank you for your time!
Questions?