Mvc express presentation

22
mvcExpress - fastest and simplest AS3 MVC frameworks Raimundas Banevicius Feb 14, 2012 Flash developer

description

Presentation of simplest and fastest ActionScript 3 MVC framework. Short history why it was born, and why it is simplest and fastest framework.

Transcript of Mvc express presentation

Page 1: Mvc express presentation

mvcExpress -fastest and simplest AS3 MVC frameworks

Raimundas BaneviciusFeb 14, 2012Flash developer

Page 2: Mvc express presentation

2

1. AS3 framework evolution2. simplicity3. performance4. extra perks

Page 3: Mvc express presentation

???

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

Page 4: Mvc express presentation

???

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!!!

Page 5: Mvc express presentation

5

mvcExpress is simple!

Page 6: Mvc express presentation

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!

Page 7: Mvc express presentation

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... }

Page 8: Mvc express presentation

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.

Page 9: Mvc express presentation

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

Page 10: Mvc express presentation

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;} } }

Page 11: Mvc express presentation

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;} } }

Page 12: Mvc express presentation

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); }}

Page 13: Mvc express presentation

13

mvcExpress is fast!

Page 14: Mvc express presentation

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

Page 15: Mvc express presentation

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!

Page 16: Mvc express presentation

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

Page 17: Mvc express presentation

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!

Page 18: Mvc express presentation

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

Page 19: Mvc express presentation

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!

Page 20: Mvc express presentation

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.

Page 21: Mvc express presentation

Check it out!

21

• Code on gitHub:

https://github.com/MindScriptAct/mvcExpress-framework

• mvcExpress homePage:

http://mvcexpress.org/

• My blog:

http://www.mindscriptact.com/

Page 22: Mvc express presentation

22

Thank you for your time!

Questions?