This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Learning a new paradigm is one of the more difficult things to do in software development. | |
So why would an object oriented developer of 10 years suddenly decide to make the drastic switch to functional programming? | |
In this talk I'll show you why I started looking for other ways of writing software and why the switch wasn't as sudden or as drastic as it may seem. | |
We'll start our journey with C#, discussing SOLID principals and the use of IoC containers. | |
Then we'll move to JavaScript to see first class functions and closures. | |
Next we'll visit the exciting distributed world of Elixir on the Erlang VM. | |
We'll finish up with F#, seeing type providers, discriminated unions, and maybe even a certain 5 letter M word. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MasterPageUtils | |
{ | |
public static T Get<T>(MasterPage page) where T : class | |
{ | |
if (page == null) return null; | |
if (page is T) return page as T; | |
return Get<T>(page.Master); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function performSearch(query, items) { | |
if (query === '') return []; | |
var q = query.toLowerCase(); | |
return items.map(function(x) { | |
var lower = x.toLowerCase(); | |
return { | |
value: x, | |
matches: strategies.map(function(strategy) { | |
return strategy(q, lower); | |
}).filter(function(strategy) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select * from [entity] e | |
OUTER APPLY | |
(SELECT TOP 1 [status], [date] | |
from [entitystatus] es (nolock) | |
where es.lookupid = e.Id | |
ORDER BY es.[Date] desc) as es |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the two-track type | |
type Result<'TSuccess,'TFailure> = | |
| Success of 'TSuccess | |
| Failure of 'TFailure | |
type ResultInterop<'TSuccess, 'TFailure> = { | |
IsSuccess : bool | |
Success : 'TSuccess | |
Failure : 'TFailure | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let (|RegexMatch|_|) pattern input = | |
let m = Regex.Match(input,pattern) | |
if (m.Success) then Some m else None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type FlatStructure = { | |
Id : int | |
Description : string | |
TagId : int | |
} | |
type Post = { | |
Id : int | |
Description : string | |
Tags : seq<int> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DataAccess.fs | |
module DataAccess | |
open FSharp.Data | |
type Create = | |
SqlCommandProvider< | |
"INSERT INTO Locations(City, State) values(@city, @state)", | |
"name=local"> | |
let createLocation city state = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class WebApiConfig | |
{ | |
public static void Register(HttpConfiguration config) | |
{ | |
config.Routes.MapHttpRoute( | |
name: "DefaultApi", | |
routeTemplate: "api/{controller}/{id}", | |
defaults: new { id = RouteParameter.Optional } | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IPasswordHasher | |
{ | |
string GetSalt(); | |
string GetHash(string password, string salt); | |
} | |
public class PasswordHasher : IPasswordHasher | |
{ | |
public string GetSalt() | |
{ |