f# eye for the c# guy - ddd north 2013
TRANSCRIPT
![Page 1: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/1.jpg)
F# Eye 4 the C# GuyPhil Trelford, @ptrelford
#dddnorth, Sunderland 2013
![Page 2: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/2.jpg)
Visual F#
![Page 3: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/3.jpg)
The F in F# stands for FUN!
![Page 4: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/4.jpg)
Halo 3 with F# Skills
![Page 5: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/5.jpg)
XBLA: Path to Go – F# AI
![Page 6: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/6.jpg)
Facebook: Monopoly
![Page 7: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/7.jpg)
F#
• Statically Typed• Functional First• Object Orientated• Open Source• .Net language• In Visual Studio
& Xamarin Studio
![Page 8: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/8.jpg)
F# for Profit: Kaggle
The F# code is
consistently shorter,
easier to read,
easier to refactor and contains far fewer bugs.
…we’ve become
more productive.
![Page 9: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/9.jpg)
LIVE DEMOSPhil Trelford, @ptrelford
DDD North, Sunderland 2013
![Page 10: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/10.jpg)
Light Syntax: POCOs
F#type Person(name:string,age:int) = /// Full name member person.Name = name /// Age in years member person.Age = age
C#public class Person{ public Person(string name, int age) { _name = name; _age = age; }
private readonly string _name; private readonly int _age;
/// <summary> /// Full name /// </summary> public string Name { get { return _name; } }
/// <summary> /// Age in years /// </summary> public int Age { get { return _age; } }}
![Page 11: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/11.jpg)
Light Syntax: DI
F#type VerySimpleStockTrader (analysisService:IStockAnalysisService, brokerageService:IOnlineBrokerageService) = member this.ExecuteTrades() = () // ...
C#public class VerySimpleStockTrader { private readonly IStockAnalysisService analysisService; private readonly IOnlineBrokerageService brokerageService;
public VerySimpleStockTraderImpl( IStockAnalysisService analysisService, IOnlineBrokerageService brokerageService) { this.analysisService = analysisService; this.brokerageService = brokerageService; }
public void ExecuteTrades() { // ... }}
![Page 12: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/12.jpg)
Unit Testing
F# NUnitmodule MathTest =
open NUnit.Framework
let [<Test>] ``2 + 2 should equal 4``() = Assert.AreEqual(2 + 2, 4)
C# NUnitusing NUnit.Framework;
[TestFixture]public class MathTest{ [Test] public void TwoPlusTwoShouldEqualFour() { Assert.AreEqual(2 + 2, 4); }}
![Page 13: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/13.jpg)
Mocking
F# Foqlet [<Test>] ``order sends mail if unfilled``() = // setup data let order = Order("TALISKER", 51) let mailer = mock() order.SetMailer(mailer) // exercise order.Fill(mock()) // verify verify <@ mailer.Send(any()) @> once
C# Moqpublic void OrderSendsMailIfUnfilled(){ // setup data var order = new Order("TALISKER", 51); var mailer = new Mock<MailService>(); order.SetMailer(mailer.Object); // exercise order.Fill(Mock.Of<Warehouse>()); // verify mailer.Verify(mock => mock.Send(It.IsAny<string>()), Times.Once());}
![Page 14: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/14.jpg)
Tickspec: Debugging
![Page 17: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/17.jpg)
RESOURCESPhil Trelford, @ptrelford
DDD North, Sunderland 2013
![Page 18: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/18.jpg)
Try F#: http://tryfsharp.org
![Page 19: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/19.jpg)
Buy the Book
![Page 20: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/20.jpg)
Get the T-Shirt
![Page 21: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/21.jpg)
Show me the money!
![Page 22: F# Eye for the C# Guy - DDD North 2013](https://reader036.vdocuments.mx/reader036/viewer/2022062418/5549125eb4c90553458beb7a/html5/thumbnails/22.jpg)
Questions?
Twitter:
@ptrelford
Blog: http://trelford.com/blog
F# Foundation: http://fsharp.org