f101 - behaviors, configuration, and runtime

Post on 12-Apr-2017

1.117 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

F101 - Behaviors, Configuration, and Runtime

About the Author

Joshua ArnoldChief Software Architect, Perioperative Logistics

http://www.linkedin.com/in/joshuaarnold

http://twitter.com/jmarnold

http://josharnold.lostechies.com

Josh leads the development efforts for the Logistics team and is a principal developer on the Fubu-family of frameworks.

He is a husband, expectant father, passionate software craftsman, coach, closet musician, and perpetual learner.

Goals

Understand the underlying model that makes FubuMVC

What’s in an Action?

users/jmarnold

What’s in an Action?

users/jmarnoldo {controller}/{action}

What’s in an Action?

users/jmarnoldo {controller}/{action}

• UsersController.Show(string username)

What’s in an Action?

Routing

Web Framework

Method Invocation

users/jmarnold

{controller}/{action}

UsersController.Show(string username)

What’s in an Action?

Web Framework

Given some {route}: 1. Locate the Method for that route 2. Invoke that Method

What’s in an Action?

Method Invocation

Type

MethodInfo

What’s in an Action?

ActionCall

Type

MethodInfo

Action Calls

Analogous to “Controller Actions” Can come from anywhere – it’s just a glorified delegate

descriptor

Key Term: ActionCall

Request/Response

Given some {route}: 1. Locate the Method for that route 2. Invoke that Method 3. Render the respective view

Request/Response

Given some {route}:

1. Locate the Method for that route

Routing

Web Framework

Method Invocation

View Rendering

2. Invoke that Method

3. Render the respective view

The Pipeline

Method Invocation View Rendering

The Pipeline

ActionCall Output

The Pipeline

ActionCall Output

BehaviorNode

Key Term: BehaviorNode

The Pipeline

ActionCall Output

“Invoke this method” “Render the output”

The Pipeline

ActionCall Output

“Invoke this method” “Render the output”

IFubuRequest

“…and put the return value in here” “Get the data from here and…”

BehaviorChain

Configuration Model

Node 1 Node 2 Node 3

Behavior Chains

Essentially a linked list of Behavior Nodes Describes the order in which behavior nodes will execute

for a given request Can be identified by:

o Guido Input Model Type

Key Term: BehaviorChain

Request/Response

Given some {route}:

1. Locate the Method for that route

Routing

Web Framework

Method Invocation

View Rendering

2. Invoke that Method

3. Render the respective view

Request/Response

Given some {route}:

1. Find the BehaviorChain for that route

Routing

FubuMVC

Resolve Chain

Execute Chain

2. Invoke that BehaviorChain

*

*Not exactly how we do it, but we’ll clarify later

users/jmarnold

Chain Execution - Configuration

UsersController.Show(“jmarnold”) WebFormOutputNode

Chain Execution - Runtime

UsersController.Show(“jmarnold”)

Render WebForms View

Runtime: Russian Dolls

Full control over execution of next behavioro Transactionso Using statementso Etc.

You can decide not to execute the nexto You can even decide to do something else instead

Models/Terminology

Configuration:o BehaviorChaino BehaviorNode

Runtime:o IActionBehavior

One More Time

Configuration:

Node 1 Node 2 Node 3

One More Time

Runtime: Node 1

Node 2

Node 3

Intermission

Grab some coffee Ask some questions Make sure we’re all on the same page here

Behavior Chain Construction

ActionCalls are registered through either of the following:

o Conventional discovery (as stated in your FubuRegistry)o IActionSource implementations registered in your FubuRegistry

Behavior Chain Construction

FubuRegistry BehaviorGraph

BehaviorChain 1

BehaviorChain 2

Assembly Scanning

IActionSources

Key Term: BehaviorGraph

Routing Integration

BehaviorChain

ActionCall Output

Routing Integration

BehaviorChain

ActionCall Output

IUrlPolicy

Route

Request/Response

Given some {route}:

1. Find the BehaviorChain for that route

Routing

FubuMVC

Resolve Chain

Execute Chain

2. Invoke that BehaviorChain

*

*Not exactly how we do it, but we’ll clarify later

Request/Response

Given some {route}:

1. Find the BehaviorChain for the route, via the BehaviorGraph, using the configured Guid

Routing

FubuMVC

Resolve Chain

Execute Chain2. Invoke that BehaviorChain

Who Cares?

Behaviors seem cool…o What’s the point?

How about an example?

…And Again…

What if we could…

What if we could…

ActionCall(CreateEntityAction<TEntity>)

What if we could…

ActionCall(CreateEntityAction<TEntity>)

IUrlPolicy

{entity}/create

Reusable Actions

Why repeat yourself when you don’t have to?

Reusable Behaviors

Why invoke an ActionCall if the input isn’t valid? o Use a “Validation Behavior”

Question Time

Where to go from here…

…you tell me:

View Engines & Html Conventions? Custom Behaviors? FubuRegistry DSL?

top related