F# Eye for the C# Guy - DDD North 2013

4,140 views
3,950 views

Published on

Published in: Technology, Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,140
On SlideShare
0
From Embeds
0
Number of Embeds
2,053
Actions
Shares
0
Downloads
11
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • MonoDevelop,Emacs & VIM
  • F# Eye for the C# Guy - DDD North 2013

    1. 1. F# Eye 4 the C# Guy Phil Trelford, @ptrelford #dddnorth, Sunderland 2013
    2. 2. Visual F#
    3. 3. The F in F# stands for FUN!
    4. 4. Halo 3 with F# Skills
    5. 5. XBLA: Path to Go – F# AI
    6. 6. Facebook: Monopoly
    7. 7. F# • Statically Typed • Functional First • Object Orientated • Open Source • .Net language • In Visual Studio & Xamarin Studio
    8. 8. 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.
    9. 9. LIVE DEMOS Phil Trelford, @ptrelford DDD North, Sunderland 2013
    10. 10. 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; } } }
    11. 11. 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() { // ... } }
    12. 12. Unit Testing F# NUnit module MathTest = open NUnit.Framework let [<Test>] ``2 + 2 should equal 4``() = Assert.AreEqual(2 + 2, 4) C# NUnit using NUnit.Framework; [TestFixture] public class MathTest { [Test] public void TwoPlusTwoShouldEqualFour() { Assert.AreEqual(2 + 2, 4); } }
    13. 13. Mocking F# Foq let [<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# Moq public 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()); }
    14. 14. Tickspec: Debugging
    15. 15. Mario Tutorial
    16. 16. Pacman with FunScript
    17. 17. RESOURCES Phil Trelford, @ptrelford DDD North, Sunderland 2013
    18. 18. Try F#: http://tryfsharp.org
    19. 19. Buy the Book
    20. 20. Get the T-Shirt
    21. 21. Show me the money!
    22. 22. Questions? Twitter: @ptrelford Blog: http://trelford.com/blog F# Foundation: http://fsharp.org

    ×