SlideShare a Scribd company logo
1 of 127
Mixing Functional and Object Oriented approaches to programming in C# Mike Wagg & Mark Needham
C# 1.0
http://www.impawards.com/2003/posters/back_in_the_day.jpg
int[] ints = new int[] {1, 2, 3, 4, 5}  
int[] Filter(int[] ints) {     ArrayList results = new ArrayList();     foreach (int i in ints)     { if (i % 2 == 0) { results.Add(i); }     }     return results.ToArray(typeof(int)); }
int[] ints = new int[] {1, 2, 3, 4, 5}  
int[] Filter(int[] ints) {     ArrayList results = new ArrayList();     foreach (int i in ints)     { if (i >3) { results.Add(i); }     }     return results.ToArray(typeof(int)); }
int[] Filter(int[] ints) {     ArrayList results = new ArrayList();     foreach (int i in ints)     { if ( i % 2 == 0 ) { results.Add(i); }     }     return results.ToArray(typeof(int)); }
int[] Filter(int[] ints) {     ArrayList results = new ArrayList();     foreach (int i in ints)     { if ( i > 3 ) { results.Add(i); }     }     return results.ToArray(typeof(int)); }
interface IIntegerPredicate { bool Matches(int value); }
class EvenPredicate : IIntegerPredicate { bool Matches(int value) { return value % 2 == 0; } }
class GreaterThanThreePredicate : IIntegerPredicate { bool Matches(int value) { return value > 3; } }
int[] Filter(int[] ints, IIntegerPredicate predicate) {     ArrayList results = new ArrayList();     foreach (int i in ints)     { if (predicate.Matches(i)) { results.Add(i); }     }     return results.ToArray(typeof(int)); }
int[] ints = new int[] {1, 2, 3, 4, 5 }; int[] even = Filter(ints, new EvenPredicate()); int[] greaterThanThree = Filter(ints, new  GreaterThanThreePredicate());
interface IIntegerPredicate { bool Matches(int value); }
bool delegate IntegerPredicate(int value);
bool Even(int value) { return value % 2 == 0; }
bool GreaterThanThree(int value) { return value > 3; }
int[] Filter(int[] ints, IntegerPredicate predicate) {     ArrayList results = new ArrayList();     foreach (int i in ints)     {                 if (predicate(i)) { results.Add(i); }     }     return results.ToArray(typeof(int)); }
int[] ints = new int[] {1, 2, 3, 4, 5 }; int[] even = Filter(ints,  new IntegerPredicate(Even)); Int[] greaterThanThree = Filter(ints,  new IntegerPredicate(GreaterThanThree));
C# 2.0  
Inference int[] ints = new int[] {1, 2, 3, 4, 5 }; int[] even = Filter(ints,  new IntegerPredicate(Even)); Int[] greaterThanThree = Filter(ints,  new IntegerPredicate(GreaterThanThree));
Inference int[] ints = new int[] {1, 2, 3, 4, 5 }; int[] even = Filter(ints, Even); Int[] greaterThanThree = Filter(ints, GreaterThanThree); The compiler can infer what the type of the delegate is so we don’t have to write it.
Generics delegate bool IntegerPredicate(int value);
Generics delegate bool Predicate<T> (T value);
Generics int[] Filter(int[] ints, IntegerPredicate predicate) { ArrayList results = new ArrayList(); foreach (int i in ints) { if (predicate(i)) { results.Add(i); } } return results.ToArray(typeof(int)); }
Generics T[] Filter<T>(T[] values, Predicate<T> predicate) { List<T> results = new List<T>(); foreach (T i in value) { if (predicate(i)) { results.Add(i); } } return results.ToArray(); }
Generics IEnumerable<T> Filter<T>(IEnumerable<T> values,  Predicate<T> predicate) { List<T> results = new List<T>(); foreach (T i in value) { if (predicate(i)) { results.Add(i); } } return results; }
Iterators IEnumerable<T> Filter<T>(IEnumerable<T> values,  Predicate<T> predicate) { List<T> results = new List<T>(); foreach (T i in value) { if (predicate(i)) { results.Add(i); } } return results; }
Iterators IEnumerable<T> Filter<T>(IEnumerable<T> values,  Predicate<T> predicate) { foreach (T i in value) { if (predicate(i)) { yield return i; } } }
Anonymous Methods IEnumerable<int> greaterThanThree = Filter(ints, GreaterThanThree);
Anonymous Methods IEnumerable<int> greaterThanThree = Filter(ints,  delegate(int value) { return value > 3; });
Anonymous Methods int minimumValue = 3; IEnumerable<int> greaterThanThree = Filter(ints,  delegate(int value) { return value > minimumValue; }); Anonymous methods add support for closures. The delegate captures the scope it was defined in.
C# 3.0  
Lambdas int minimumValue = 3; IEnumerable<int> greaterThanThree = Filter(ints,  delegate(int value) { return value > minimumValue; });
Lambdas int minimumValue = 3; IEnumerable<int> greaterThanThree = Filter(ints,  value => value > minimumValue);
More Type Inference int minimumValue = 3; IEnumerable<int> greaterThanThree = Filter(ints,  value => value > minimumValue);
More Type Inference int minimumValue = 3; var greaterThanThree = Filter(ints, value => value > minimumValue);
Extension Methods int minimumValue = 3; var greaterThanThree = Filter(ints, value => value > minimumValue);
Extension Methods int minimumValue = 3; var greaterThanThree = ints.Filter(value => value > minimumValue);
Anonymous Types var anonymous = new { Foo = 1, Bar = “Bar” }
LINQ
LINQ New delegates in System namespace Action<T>, Action<T1, T2>, Func<TResult>, Func<T1, TResult> etc.
LINQ New delegates in System namespace Action<T>, Action<T1, T2>, Func<TResult>, Func<T1, TResult> etc. System.Linq Extension methods Where, Select, OrderBy etc.
LINQ New delegates in System namespace Action<T>, Action<T1, T2>, Func<TResult>, Func<T1, TResult> etc. System.Linq Extension methods Where, Select, OrderBy etc.   Some compiler magic to translate sql style code to method calls
LINQ var even = ints.Where(value => value % 2 == 0)   var greaterThanThree = ints.Where(value => value > minimumValue)   or var even = from value in ints                    where value % 2 == 0                    select value    var greaterThanThree = from value in ints                                         where value > minimumValue                                                     select value                                       
A (little) bit of theory
http://www.flickr.com/photos/stuartpilbrow/2938100285/sizes/l/
Higher order functions
Immutability
Lazy evaluation
Recursion & Pattern Matching
Transformational Mindset We can just pass functions around instead in most cases - find an example where it still makes sense to use the GOF approach though.
Input  -> ??? -> ??? -> ??? ->  Output
http://www.emt-india.net/process/petrochemical/img/pp4.jpg
So why should you care?
Functional can fill in the gaps in OO code  
Abstractions over common operations means less code and less chances to make mistakes
So what do we get out of the box?
Projection
  ,[object Object],[object Object],[object Object],[object Object],[object Object]
  ,[object Object],[object Object],[object Object]
Restriction  
  ,[object Object],[object Object],[object Object],[object Object]
Partitioning  
  ,[object Object],[object Object],[object Object]
  ,[object Object],[object Object],[object Object]
  ,[object Object],[object Object],[object Object],[object Object]
  ,[object Object],[object Object],[object Object],[object Object]
Set  
  ,[object Object],[object Object]
  ,[object Object],[object Object]
  ,[object Object],[object Object],[object Object]
  ,[object Object],[object Object],[object Object]
Ordering and Grouping  
  ,[object Object],[object Object],[object Object],[object Object],[object Object]
  ,[object Object],[object Object],[object Object]
Aggregation  
  ,[object Object],[object Object],[object Object]
  ,[object Object],[object Object],[object Object],[object Object]
  ,[object Object],[object Object],[object Object],[object Object]
  ,[object Object],[object Object],[object Object],[object Object]
  ,[object Object],[object Object],[object Object],[object Object]
  ,[object Object]
  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
We can just pass functions around instead in most cases - find an example where it still makes sense to use the GOF approach though.
 
  ,[object Object],public class SomeObject {  private readonly IStrategy strategy; public SomeObject(IStrategy strategy) { this.strategy = strategy; } public void DoSomething(string value) { strategy.DoSomething(value); } }
  ,[object Object],public class Strategy : IStrategy {  public void DoSomething(string value) { // do something with string } }
  ,[object Object],public class SomeObject {  private readonly Action<string> strategy; public SomeObject(Action<string> strategy) { this.strategy = strategy; } public void DoSomething(string value) { strategy(value); } }
  ,[object Object]
  ,[object Object],public class ServiceCache<Service> {  protected Res FromCacheOrService            <Req, Res>(Func<Res> serviceCall, Req request) {      var cachedRes = cache.RetrieveIfExists( typeof(Service), typeof(Res), request);   if(cachedRes == null)   { cachedRes = serviceCall(); cache.Add(typeof(Service), request,  cachedRes); }      return (Res) cachedRes; } }
  ,[object Object],public class CachedService : ServiceCache<IService> {  public MyResult GetMyResult(MyRequest request) {            return FromCacheOrService(()                   => service.GetMyResult(request), request); } }
  ,[object Object]
[object Object],private void AddErrorIf<T>(Expression<Func<T>> fn,    ModelStateDictionary modelState,    Func<ModelStateDictionary,    Func<T,string, string, bool>> checkFn) { var fieldName = ((MemberExpression)fn.Body).Member.Name; var value = fn.Compile().Invoke(); var validationMessage = validationMessages[fieldName]); checkFn.Invoke(modelState)(value, fieldName, validationMessage); } AddErrorIf(() =>  person.HasPets, modelState,  m => (value, field, error) => m.AddErrorIfNotEqualTo(value,true, field, error)); AddErrorIf(() =>  person.HasChildren, modelState,  m => (value, field, error) => m.AddErrorIfNull(value, field, error));
  ,[object Object]
[object Object],static void Identity<T>(T value, Action<T> k)  {  k(value);  }
[object Object],Identity(&quot;foo&quot;, s => Console.WriteLine(s));
[object Object],Identity(&quot;foo&quot;, s => Console.WriteLine(s));  as compared to var foo = Identity(“foo”); Console.WriteLine(foo);
[object Object],public ActionResult Submit(string id, FormCollection form) {     var shoppingBasket = CreateShoppingBasketFrom(id, form);      return IsValid(shoppingBasket, ModelState,          () => RedirectToAction(&quot;index&quot;, &quot;ShoppingBasket&quot;, new { shoppingBasket.Id} ),      () => LoginUser(shoppingBasket,                  () =>                    {                     ModelState.AddModelError(&quot;Password&quot;, &quot;User name/email address was      incorrect - please re-enter&quot;);                      return RedirectToAction(&quot;index&quot;, &quot;&quot;ShoppingBasket&quot;,    new { Id = new Guid(id) });                   },  user =>                    {                     shoppingBasket.User = user;                      UpdateShoppingBasket(shoppingBasket);                      return RedirectToAction(&quot;index&quot;, &quot;Purchase&quot;,      new { Id = shoppingBasket.Id });  }         ));  }
[object Object],private RedirectToRouteResult IsValid(ShoppingBasket shoppingBasket,                                         ModelStateDictionary modelState,                                          Func<RedirectToRouteResult> failureFn,                        Func<RedirectToRouteResult> successFn)  {    return validator.IsValid(shoppingBasket, modelState) ? successFn() : failureFn();  }    private RedirectToRouteResult LoginUser(ShoppingBasket shoppingBasket,                                                                      Func<RedirectToRouteResult> failureFn,                                                                   Func<User,RedirectToRouteResult> successFn)  {  User user = null;  try  {  user = userService.CreateAccountOrLogIn(shoppingBasket);  }    catch (NoAccountException)  {  return failureFn();  }    return successFn(user);  }
[object Object],http://www.thegeekshowpodcast.com/home/mastashake/thegeekshowpodcast.com/wp-content/uploads/2009/07/wtf-cat.jpg
So what could possibly go wrong?   http://icanhascheezburger.files.wordpress.com/2009/06/funny-pictures-cat-does-not-think-plan-will-fail.jpg
Hard to diagnose errors  
var people = new []  {  new Person { Id=1, Address = new Address { Road = &quot;Ewloe Road&quot; }},   new Person { Id=2}, new Person { Id=3, Address = new Address { Road = &quot;London Road&quot;}}  }; people.Select(p => p.Address.Road); 
Null Reference Exception on line 23
http://www.flickr.com/photos/29599641@N04/3147972713/
public T Tap(T t, Action action)  {     action();     return t; }
people     .Select(p => Tap(p, logger.debug(p.Id))     .Select(p => p.Address.Road); 
Readability  
Lazy evaluation can have unexpected consequences  
  ,[object Object],[object Object]
  ,[object Object],[object Object]
  ,[object Object],[object Object],[object Object]
Encapsulation is still important  
  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Linq isn't the problem here, it's where we have put it  
Company naturally has the responsibility so encapsulate the logic here
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sometimes we need to go further  
If both Company and Division have employees do we duplicate the logic for total salary?
IEnumerable<T> and List<T> make collections easy but sometimes it is still better to create a class to represent a collection
  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
In conclusion…  
 
Mike Wagg mikewagg.blogspot.com [email_address] Mark Needham markhneedham.com [email_address]

More Related Content

What's hot

Pj01 4-operators and control flow
Pj01 4-operators and control flowPj01 4-operators and control flow
Pj01 4-operators and control flowSasidharaRaoMarrapu
 
Arrays searching-sorting
Arrays searching-sortingArrays searching-sorting
Arrays searching-sortingAjharul Abedeen
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mark Needham
 
Linq Sanjay Vyas
Linq   Sanjay VyasLinq   Sanjay Vyas
Linq Sanjay Vyasrsnarayanan
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to ErlangGabriele Lana
 
awesome groovy
awesome groovyawesome groovy
awesome groovyPaul King
 
functional groovy
functional groovyfunctional groovy
functional groovyPaul King
 
Introduction To Groovy
Introduction To GroovyIntroduction To Groovy
Introduction To Groovymanishkp84
 
Top 20 java programming interview questions for sdet
Top 20 java programming interview questions for sdetTop 20 java programming interview questions for sdet
Top 20 java programming interview questions for sdetDevLabs Alliance
 
Python dictionary : past, present, future
Python dictionary: past, present, futurePython dictionary: past, present, future
Python dictionary : past, present, futuredelimitry
 
MCE^3 - Hannes Verlinde - Let The Symbols Do The Work
MCE^3 - Hannes Verlinde - Let The Symbols Do The WorkMCE^3 - Hannes Verlinde - Let The Symbols Do The Work
MCE^3 - Hannes Verlinde - Let The Symbols Do The WorkPROIDEA
 

What's hot (20)

Groovy
GroovyGroovy
Groovy
 
Pj01 4-operators and control flow
Pj01 4-operators and control flowPj01 4-operators and control flow
Pj01 4-operators and control flow
 
Arrays searching-sorting
Arrays searching-sortingArrays searching-sorting
Arrays searching-sorting
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#
 
Linq Sanjay Vyas
Linq   Sanjay VyasLinq   Sanjay Vyas
Linq Sanjay Vyas
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to Erlang
 
07slide
07slide07slide
07slide
 
Sorting
SortingSorting
Sorting
 
awesome groovy
awesome groovyawesome groovy
awesome groovy
 
Chapter 2 Method in Java OOP
Chapter 2   Method in Java OOPChapter 2   Method in Java OOP
Chapter 2 Method in Java OOP
 
functional groovy
functional groovyfunctional groovy
functional groovy
 
Refactoring
RefactoringRefactoring
Refactoring
 
Introduction To Groovy
Introduction To GroovyIntroduction To Groovy
Introduction To Groovy
 
Chapter 4 - Classes in Java
Chapter 4 - Classes in JavaChapter 4 - Classes in Java
Chapter 4 - Classes in Java
 
Chapter 3 Arrays in Java
Chapter 3 Arrays in JavaChapter 3 Arrays in Java
Chapter 3 Arrays in Java
 
Top 20 java programming interview questions for sdet
Top 20 java programming interview questions for sdetTop 20 java programming interview questions for sdet
Top 20 java programming interview questions for sdet
 
Python dictionary : past, present, future
Python dictionary: past, present, futurePython dictionary: past, present, future
Python dictionary : past, present, future
 
MCE^3 - Hannes Verlinde - Let The Symbols Do The Work
MCE^3 - Hannes Verlinde - Let The Symbols Do The WorkMCE^3 - Hannes Verlinde - Let The Symbols Do The Work
MCE^3 - Hannes Verlinde - Let The Symbols Do The Work
 
Python lecture 05
Python lecture 05Python lecture 05
Python lecture 05
 
Oop lecture7
Oop lecture7Oop lecture7
Oop lecture7
 

Similar to Mixing Functional and Object Oriented approaches to programming in C

Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy codeShriKant Vashishtha
 
Monadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query ExpressionsMonadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query ExpressionsChris Eargle
 
JBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java ProgrammersJBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java ProgrammersTikal Knowledge
 
Evolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and EffectiveEvolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and EffectiveNaresha K
 
Lec 1 Ds
Lec 1 DsLec 1 Ds
Lec 1 DsQundeel
 
Data Structure
Data StructureData Structure
Data Structuresheraz1
 
Lec 1 Ds
Lec 1 DsLec 1 Ds
Lec 1 DsQundeel
 
Effective Java - Still Effective After All These Years
Effective Java - Still Effective After All These YearsEffective Java - Still Effective After All These Years
Effective Java - Still Effective After All These YearsMarakana Inc.
 
Java căn bản - Chapter10
Java căn bản - Chapter10Java căn bản - Chapter10
Java căn bản - Chapter10Vince Vo
 
Refer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdfRefer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdfarishmarketing21
 
Practices For Becoming A Better Programmer
Practices For Becoming A Better ProgrammerPractices For Becoming A Better Programmer
Practices For Becoming A Better ProgrammerSrikanth Shreenivas
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#Shahzad
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Rubyerockendude
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Rubyerockendude
 
Evolving with Java - How to Remain Effective
Evolving with Java - How to Remain EffectiveEvolving with Java - How to Remain Effective
Evolving with Java - How to Remain EffectiveNaresha K
 

Similar to Mixing Functional and Object Oriented approaches to programming in C (20)

Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
Monadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query ExpressionsMonadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query Expressions
 
JBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java ProgrammersJBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java Programmers
 
Evolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and EffectiveEvolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and Effective
 
Lec 1 Ds
Lec 1 DsLec 1 Ds
Lec 1 Ds
 
Data Structure
Data StructureData Structure
Data Structure
 
Lec 1 Ds
Lec 1 DsLec 1 Ds
Lec 1 Ds
 
Effective Java - Still Effective After All These Years
Effective Java - Still Effective After All These YearsEffective Java - Still Effective After All These Years
Effective Java - Still Effective After All These Years
 
Java căn bản - Chapter10
Java căn bản - Chapter10Java căn bản - Chapter10
Java căn bản - Chapter10
 
New C# features
New C# featuresNew C# features
New C# features
 
Refer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdfRefer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdf
 
Practices For Becoming A Better Programmer
Practices For Becoming A Better ProgrammerPractices For Becoming A Better Programmer
Practices For Becoming A Better Programmer
 
07+08slide.pptx
07+08slide.pptx07+08slide.pptx
07+08slide.pptx
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Ruby
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Ruby
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Evolving with Java - How to Remain Effective
Evolving with Java - How to Remain EffectiveEvolving with Java - How to Remain Effective
Evolving with Java - How to Remain Effective
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 

More from Mark Needham

Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and OperationsNeo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and OperationsMark Needham
 
This week in Neo4j - 3rd February 2018
This week in Neo4j - 3rd February 2018This week in Neo4j - 3rd February 2018
This week in Neo4j - 3rd February 2018Mark Needham
 
Building a recommendation engine with python and neo4j
Building a recommendation engine with python and neo4jBuilding a recommendation engine with python and neo4j
Building a recommendation engine with python and neo4jMark Needham
 
Graph Connect: Tuning Cypher
Graph Connect: Tuning CypherGraph Connect: Tuning Cypher
Graph Connect: Tuning CypherMark Needham
 
Graph Connect: Importing data quickly and easily
Graph Connect: Importing data quickly and easilyGraph Connect: Importing data quickly and easily
Graph Connect: Importing data quickly and easilyMark Needham
 
Graph Connect Europe: From Zero To Import
Graph Connect Europe: From Zero To ImportGraph Connect Europe: From Zero To Import
Graph Connect Europe: From Zero To ImportMark Needham
 
Optimizing cypher queries in neo4j
Optimizing cypher queries in neo4jOptimizing cypher queries in neo4j
Optimizing cypher queries in neo4jMark Needham
 
Football graph - Neo4j and the Premier League
Football graph - Neo4j and the Premier LeagueFootball graph - Neo4j and the Premier League
Football graph - Neo4j and the Premier LeagueMark Needham
 
The Football Graph - Neo4j and the Premier League
The Football Graph - Neo4j and the Premier LeagueThe Football Graph - Neo4j and the Premier League
The Football Graph - Neo4j and the Premier LeagueMark Needham
 
Scala: An experience report
Scala: An experience reportScala: An experience report
Scala: An experience reportMark Needham
 
F#: What I've learnt so far
F#: What I've learnt so farF#: What I've learnt so far
F#: What I've learnt so farMark Needham
 

More from Mark Needham (12)

Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and OperationsNeo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
 
This week in Neo4j - 3rd February 2018
This week in Neo4j - 3rd February 2018This week in Neo4j - 3rd February 2018
This week in Neo4j - 3rd February 2018
 
Building a recommendation engine with python and neo4j
Building a recommendation engine with python and neo4jBuilding a recommendation engine with python and neo4j
Building a recommendation engine with python and neo4j
 
Graph Connect: Tuning Cypher
Graph Connect: Tuning CypherGraph Connect: Tuning Cypher
Graph Connect: Tuning Cypher
 
Graph Connect: Importing data quickly and easily
Graph Connect: Importing data quickly and easilyGraph Connect: Importing data quickly and easily
Graph Connect: Importing data quickly and easily
 
Graph Connect Europe: From Zero To Import
Graph Connect Europe: From Zero To ImportGraph Connect Europe: From Zero To Import
Graph Connect Europe: From Zero To Import
 
Optimizing cypher queries in neo4j
Optimizing cypher queries in neo4jOptimizing cypher queries in neo4j
Optimizing cypher queries in neo4j
 
Football graph - Neo4j and the Premier League
Football graph - Neo4j and the Premier LeagueFootball graph - Neo4j and the Premier League
Football graph - Neo4j and the Premier League
 
The Football Graph - Neo4j and the Premier League
The Football Graph - Neo4j and the Premier LeagueThe Football Graph - Neo4j and the Premier League
The Football Graph - Neo4j and the Premier League
 
Scala: An experience report
Scala: An experience reportScala: An experience report
Scala: An experience report
 
Visualisations
VisualisationsVisualisations
Visualisations
 
F#: What I've learnt so far
F#: What I've learnt so farF#: What I've learnt so far
F#: What I've learnt so far
 

Mixing Functional and Object Oriented approaches to programming in C

Editor's Notes

  1. Lazy evaluation
  2. Go faster!!!
  3. origins of functional programming are found in lambda calculation/maths
  4. functions that take in a function or return a function. Need to have first class functions in the language to do that. We have that with all the LINQ methods - select, where, and so on.
  5. the whole premise of functional programming with side effect free functions assumes that we have immutable data. We can&apos;t achieve this idiomatically in C# because the language isn&apos;t really designed for it. I want to put an example of how immutability is easy in F#, can that go in this section?
  6. iterators in C# do this with yield keyword It&apos;s not necessary to have lazy evaluation to be functional but it&apos;s a characteristic of some functional languages.
  7. seems quite obvious but the most extreme guideline to follow is that we shouldn&apos;t need to store anything in variables. Look at the data as a whole if we don&apos;t store any intermediate values then we truly do have some data that we are passing through different filters and applying some transformation
  8. it&apos;s quite like the pipes and filters architectural pattern in fact. This is the way that we can combine functions on the unix command line.
  9. what is CPS?   is where we pass in a function that represents the rest of the program which will be called with the result of another function.
  10. what is CPS?   is where we pass in a function that represents the rest of the program which will be called with the result of another function.
  11. what is CPS?   is where we pass in a function that represents the rest of the program which will be called with the result of another function.
  12. the idea is that the rest of the program is contained in the continuation so we don&apos;t need to come back to the call site.
  13. the idea is that the rest of the program is contained in the continuation so we don&apos;t need to come back to the call site.
  14. the idea is that the rest of the program is contained in the continuation so we don&apos;t need to come back to the call site.
  15. Encapsulates the state but over complicates the program flow perhaps
  16. Encapsulates the state but over complicates the program flow perhaps