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
var sw = new Stopwatch(); | |
sw.Start(); | |
Foo(); | |
sw.Stop(); | |
// now just log the results somewhere |
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
var builder = new Builder(); | |
builder.WithSomeProperty(42); | |
// ...throw some business logic here... | |
builder.WithSomeOtherProperty(computedValue); | |
// ...some other logic here too... |
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 Vehicle { | |
private Vehicle(string model, int wheelsCount){ | |
this.Model = model; | |
this.WheelsCount = wheelsCount; | |
} | |
public string Model { get; } | |
public int WheelsCount { get; } | |
public VehicleBuilder { |
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
export class Foo implements IFoo{ | |
constructor(private readonly barStrategy:()=>void){} | |
public bar(){ | |
this.barStrategy(); | |
} | |
}; | |
// composition root | |
const featureService:IFeatureService = new FeatureService(), | |
strategy1 = ():void =>{ /*...strategy 1...*/ }, |
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
interface IFeatureService{ | |
isEnabled(featureName:string):boolean; | |
} | |
export class Foo implements IFoo{ | |
constructor(private readonly featureService:IFeatureService){} | |
public bar(){ | |
if(this.featureService.isEnabled("feature-x")){ | |
/*.......*/ |
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
interface IFoo{ | |
bar():void; | |
} | |
interface FlagsConfig{ | |
featureX:boolean; | |
} | |
export class Foo implements IFoo{ | |
constructor(private readonly flagsConfig:FlagsConfig){} |
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 compute_stuff(){ | |
/*...*/ | |
if(checkFeatureIsOn("foo_feature")){ | |
new_amazing_shiny_never_used_function(); | |
}else{ | |
old_tested_reliable_and_lovely_function(); | |
} | |
/*...*/ | |
} |
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 compute_stuff(){ | |
/*...*/ | |
old_tested_reliable_and_lovely_function(); | |
/*...*/ | |
} |
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 DbContextExtensions | |
{ | |
public static void Reset(this DbContext context) | |
{ | |
var entries = context.ChangeTracker | |
.Entries() | |
.Where(e => e.State != EntityState.Unchanged) | |
.ToArray(); | |
foreach (var entry in entries) |
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 MyAwesomeClass{ | |
private static readonly NLog.Logger _logger; | |
static MyAwesomeClass(){ | |
_logger = NLog.LogManager.GetCurrentClassLogger(); | |
} | |
} |