F101 - Behaviors, Configuration, and Runtime
-
Upload
josh-arnold -
Category
Technology
-
view
1.110 -
download
1
Transcript of F101 - Behaviors, Configuration, and Runtime
![Page 1: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/1.jpg)
F101 - Behaviors, Configuration, and Runtime
![Page 2: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/2.jpg)
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.
![Page 3: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/3.jpg)
Goals
Understand the underlying model that makes FubuMVC
![Page 4: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/4.jpg)
What’s in an Action?
users/jmarnold
![Page 5: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/5.jpg)
What’s in an Action?
users/jmarnoldo {controller}/{action}
![Page 6: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/6.jpg)
What’s in an Action?
users/jmarnoldo {controller}/{action}
• UsersController.Show(string username)
![Page 7: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/7.jpg)
What’s in an Action?
Routing
Web Framework
Method Invocation
users/jmarnold
{controller}/{action}
UsersController.Show(string username)
![Page 8: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/8.jpg)
What’s in an Action?
Web Framework
Given some {route}: 1. Locate the Method for that route 2. Invoke that Method
![Page 9: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/9.jpg)
What’s in an Action?
Method Invocation
Type
MethodInfo
![Page 10: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/10.jpg)
What’s in an Action?
ActionCall
Type
MethodInfo
![Page 11: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/11.jpg)
Action Calls
Analogous to “Controller Actions” Can come from anywhere – it’s just a glorified delegate
descriptor
Key Term: ActionCall
![Page 12: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/12.jpg)
Request/Response
Given some {route}: 1. Locate the Method for that route 2. Invoke that Method 3. Render the respective view
![Page 13: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/13.jpg)
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
![Page 14: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/14.jpg)
The Pipeline
Method Invocation View Rendering
![Page 15: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/15.jpg)
The Pipeline
ActionCall Output
![Page 16: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/16.jpg)
The Pipeline
ActionCall Output
BehaviorNode
Key Term: BehaviorNode
![Page 17: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/17.jpg)
The Pipeline
ActionCall Output
“Invoke this method” “Render the output”
![Page 18: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/18.jpg)
The Pipeline
ActionCall Output
“Invoke this method” “Render the output”
IFubuRequest
“…and put the return value in here” “Get the data from here and…”
![Page 19: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/19.jpg)
BehaviorChain
Configuration Model
Node 1 Node 2 Node 3
![Page 20: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/20.jpg)
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
![Page 21: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/21.jpg)
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
![Page 22: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/22.jpg)
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
![Page 23: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/23.jpg)
users/jmarnold
Chain Execution - Configuration
UsersController.Show(“jmarnold”) WebFormOutputNode
![Page 24: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/24.jpg)
Chain Execution - Runtime
UsersController.Show(“jmarnold”)
Render WebForms View
![Page 25: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/25.jpg)
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
![Page 26: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/26.jpg)
Models/Terminology
Configuration:o BehaviorChaino BehaviorNode
Runtime:o IActionBehavior
![Page 27: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/27.jpg)
One More Time
Configuration:
Node 1 Node 2 Node 3
![Page 28: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/28.jpg)
One More Time
Runtime: Node 1
Node 2
Node 3
![Page 29: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/29.jpg)
Intermission
Grab some coffee Ask some questions Make sure we’re all on the same page here
![Page 30: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/30.jpg)
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
![Page 31: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/31.jpg)
Behavior Chain Construction
FubuRegistry BehaviorGraph
BehaviorChain 1
BehaviorChain 2
Assembly Scanning
IActionSources
Key Term: BehaviorGraph
![Page 32: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/32.jpg)
Routing Integration
BehaviorChain
ActionCall Output
![Page 33: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/33.jpg)
Routing Integration
BehaviorChain
ActionCall Output
IUrlPolicy
Route
![Page 34: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/34.jpg)
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
![Page 35: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/35.jpg)
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
![Page 36: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/36.jpg)
Who Cares?
Behaviors seem cool…o What’s the point?
![Page 37: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/37.jpg)
How about an example?
![Page 38: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/38.jpg)
…And Again…
![Page 39: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/39.jpg)
What if we could…
![Page 40: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/40.jpg)
What if we could…
ActionCall(CreateEntityAction<TEntity>)
![Page 41: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/41.jpg)
What if we could…
ActionCall(CreateEntityAction<TEntity>)
IUrlPolicy
{entity}/create
![Page 42: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/42.jpg)
Reusable Actions
Why repeat yourself when you don’t have to?
![Page 43: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/43.jpg)
Reusable Behaviors
Why invoke an ActionCall if the input isn’t valid? o Use a “Validation Behavior”
![Page 44: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/44.jpg)
Question Time
![Page 45: F101 - Behaviors, Configuration, and Runtime](https://reader035.fdocuments.us/reader035/viewer/2022062223/58ed20ba1a28ab31568b461b/html5/thumbnails/45.jpg)
Where to go from here…
…you tell me:
View Engines & Html Conventions? Custom Behaviors? FubuRegistry DSL?