Skip to content

Instantly share code, notes, and snippets.

View gpltaylor's full-sized avatar
💭
I may be slow to respond.

Garry Taylor gpltaylor

💭
I may be slow to respond.
  • RedBear
  • Lancashire
View GitHub Profile
@gpltaylor
gpltaylor / Dotnet Records.md
Created December 11, 2024 13:38
C# Records

Dotnet Records was introduced in 2020 with C#9 and highlighted a shift to Functional Programming within the language. However, in my experience, they have been under utilised and demoted to the league of DTO's, primitive obsession and anaemic classes. However, when we extending Records, the similarities to classes can mask the reasons for choosing Records.

What is a Record?

But first, lets identify what a Record is and why I think we are miss-using them.

Let's create an example, when building a Model to represent a Person, there are a number of Properties required. If the Model is rich, there may also be a number of relationships and navigational properties. Consider a Person, with a collection of Address items. Each Address has a Electric Meter owned by an Energy Provider.

Person
   FirstName: string
@gpltaylor
gpltaylor / big-o-notation.ipynb
Created February 8, 2024 17:19 — forked from jonkrohn/big-o-notation.ipynb
big-O-notation.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import java.util.ArrayList;
class Person {
private String name;
public Person(String name) {
setName(name);
}
public String getName() {
import React, { PropTypes } from 'react'
const BEFOREUNLOAD = "beforeunload"; // see: http://stackoverflow.com/questions/39094138/reactjs-event-listener-beforeunload-added-but-not-removed
class NavigationPrompt extends React.Component {
static contextTypes = {
router: PropTypes.object.isRequired
}
static defaultProps = {
when: true
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[Todo App]">
<script src="//fb.me/react-0.14.3.js"></script>
<script src="//fb.me/react-dom-0.14.3.js"></script>
<script src="https://wzrd.in/standalone/expect@latest"></script>
<script src="https://wzrd.in/standalone/deep-freeze@latest"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.0.5/redux.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-redux/4.0.6/react-redux.js"></script>
import React from 'react'
import { Debounce } from 'react-throttle'
var XPos = (props) => {
return <div>
x: {props.x}
</div>
}
var YPos = (props) => {
@gpltaylor
gpltaylor / FormidableLabs spectacle
Last active October 3, 2016 18:43
How to separate Slides into module files
import React from "react";
import {
Link,
Slide,
Text,
Heading
} from "spectacle";
var MainBody = () => {
return <div>
@gpltaylor
gpltaylor / ShouldSerializeContractResolver.cs
Created September 26, 2015 17:03
Sample ContractResolver that conditionally removes properties from JSON. This can be plumbed into ASP.NET/API
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Linq
{
using AutoMapper;
using Newtonsoft.Json;