• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Functional Alchemy
 

Functional Alchemy

on

  • 2,413 views

Slides from my presentation on Functional Alchemy at DDD SouthWest (and other places)

Slides from my presentation on Functional Alchemy at DDD SouthWest (and other places)

Statistics

Views

Total Views
2,413
Views on SlideShare
2,405
Embed Views
8

Actions

Likes
0
Downloads
0
Comments
0

2 Embeds 8

http://www.slideshare.net 7
http://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

Functional Alchemy Functional Alchemy Presentation Transcript

  • Functional Alchemy 10 Some tricks to keep your C# DRY E: mark@dotnetsolutions.co.uk T: @markrendle B: blog.markrendle.net
  • Get all the code: bit.ly/functionalalchemy (goes to bitbucket.org)
  • Functional?
  • First-class functions
  • Action<T> Func<T, TResult>
  • Higher-order functions
  • Lazy evaluation
  • Immutability
  • Immutability Purity
  • Immutability Purity Tail-call optimisation
  • Immutability Purity Tail-call optimisation
  • Immutability Purity Tail-call optimisation (irrelevant bobbins)
  • Functions as objects
  • IComparer<T> Demo
  • Tuples
  • Tuple<T1,T2>
  • F# success, i = int.TryParse(“42”)
  • C# int i; bool success = int.TryParse(“42”, out i);
  • Tupleize Demo
  • C# var tuple = IntTryParse(“42”); if (tuple.Item1) { ... }
  • Tuple extensions Demo
  • Fixing C# and the .NET BCL
  • var handler = MyEvent; if (handler != null) { handler(this, EventArgs.Empty); }
  • EventHandler.Raise Demo
  • Higher-order functions
  • EventHandler.Raise (Again)
  • Better Exception handling
  • try { File.OpenRead(“foo.txt”); } catch (FileNotFoundException) { Error(“Cannot open file”); } catch (DirectoryNotFoundException) { Error(“Cannot open file”); } catch (UnauthorizedAccessException) { //etc, etc }
  • Multi-exception catch Demo
  • Augmenting functions
  • Cached (deterministic) methods Demo
  • Event-based Async Pattern Demo
  • Composition
  • Event-based Async Pattern + Cached methods Demo
  • Get all the code: bit.ly/functionalalchemy (goes to bitbucket.org) E: mark@dotnetsolutions.co.uk T: @markrendle B: blog.markrendle.net