Phil Trelford, @ptrelford
DDD Cambridge Nights, 2014
 Statically Typed
 Functional First
 Object Orientated
 Open Source

 .Net language
 In Visual Studio

& Xamarin Stu...
Kaggle
The fact that F# targets the
CLR was also critical
we have a large existing code
base in C#,
getting started with F...
The F# code is
consistently shorter,
easier to read,
easier to refactor and
contains far fewer bugs.
…we’ve become
more pr...
Phil Trelford, @ptrelford

DDD Cambridge, 2014
F#

C#

type Person(name:string,age:int) =
/// Full name
member person.Name = name
/// Age in years
member person.Age = ag...
F#
type VerySimpleStockTrader

(analysisService:IStockAnalysisService,
brokerageService:IOnlineBrokerageService) =
member ...
F# NUnit

C# NUnit

module MathTest =

using NUnit.Framework;

open NUnit.Framework

[TestFixture]
public class MathTest
{...
F# Foq

C# Moq

let ``order sends mail if unfilled``() =
// setup data
let order = Order("TALISKER", 51)
let mailer = mock...
type formula =
| Neg of formula
| Exp of formula * formula
| ArithmeticOp of
formula * arithmetic * formula
| LogicalOp of...
open FSharp.Data
type Simple = JsonProvider<""" { "name":"John", "age":94 } """>
let simple = Simple.Parse(""" { "name":"T...
Phil Trelford, @ptrelford

DDD Cambridge, 2014
software stacks

trainings teaching F# user groups
mac and linux

snippets

cross-platform books and tutorials

F# Softwar...
//--------------------------------------------------------------// About Let
//
// The let keyword is one of the most fund...
Phil Trelford, @ptrelford

DDD Cambridge, 2014
F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014
F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014
F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014
F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014
F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014
F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014
F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014
F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014
F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014
F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014
F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014
Upcoming SlideShare
Loading in...5
×

F# Eye 4 the C# Guy - DDD Cambridge Nights 2014

418

Published on

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

  • Be the first to like this

No Downloads
Views
Total Views
418
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • MonoDevelop,Emacs &amp; VIM
  • http://fsharp.org/testimonials/#kaggle-1Don’t throw out the baby with the bath water
  • F# Eye 4 the C# Guy - DDD Cambridge Nights 2014

    1. 1. Phil Trelford, @ptrelford DDD Cambridge Nights, 2014
    2. 2.  Statically Typed  Functional First  Object Orientated  Open Source  .Net language  In Visual Studio & Xamarin Studio
    3. 3. Kaggle The fact that F# targets the CLR was also critical we have a large existing code base in C#, getting started with F# was an easy decision.
    4. 4. The F# code is consistently shorter, easier to read, easier to refactor and contains far fewer bugs. …we’ve become more productive.
    5. 5. Phil Trelford, @ptrelford DDD Cambridge, 2014
    6. 6. F# C# type Person(name:string,age:int) = /// Full name member person.Name = name /// Age in years member person.Age = age 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
    7. 7. F# type VerySimpleStockTrader (analysisService:IStockAnalysisService, brokerageService:IOnlineBrokerageService) = member this.ExecuteTrades() = C# public class VerySimpleStockTrader { private readonly IStockAnalysisService analysisService; private readonly IOnlineBrokerageService brokerageService; public VerySimpleStockTrader( IStockAnalysisService analysisService, IOnlineBrokerageService brokerageService) { this.analysisService = analysisService; this.brokerageService = brokerageService; } () // ... public void ExecuteTrades() { // ... } }
    8. 8. F# NUnit C# NUnit module MathTest = using NUnit.Framework; open NUnit.Framework [TestFixture] public class MathTest { [Test] public void TwoPlusTwoShouldEqualFour() { Assert.AreEqual(2 + 2, 4); } } let [<Test>] ``2 + 2 should equal 4``() = Assert.AreEqual(2 + 2, 4)
    9. 9. F# Foq C# Moq let ``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 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()); }
    10. 10. type formula = | Neg of formula | Exp of formula * formula | ArithmeticOp of formula * arithmetic * formula | LogicalOp of formula * logical * formula | Num of UnitValue | Ref of int * int | Range of int * int * int * int | Fun of string * formula list
    11. 11. open FSharp.Data type Simple = JsonProvider<""" { "name":"John", "age":94 } """> let simple = Simple.Parse(""" { "name":"Tomas", "age":4 } """) Simple.Age
    12. 12. Phil Trelford, @ptrelford DDD Cambridge, 2014
    13. 13. software stacks trainings teaching F# user groups mac and linux snippets cross-platform books and tutorials F# Software Foundation F# community open-source MonoDevelop http://www.fsharp.org contributions research support consultancy mailing list
    14. 14. //--------------------------------------------------------------// About Let // // The let keyword is one of the most fundamental parts of F#. // You'll use it in almost every line of F# code you write, so // let's get to know it well! (no pun intended) //--------------------------------------------------------------[<Koan(Sort = 2)>] module ``about let`` = [<Koan>] let LetBindsANameToAValue() = let x = 50 AssertEquality x __
    15. 15. Phil Trelford, @ptrelford DDD Cambridge, 2014
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×