public void Worst() { var sampleDataA = LookupA.LoadSome(); var sampleDataB = LookupB.LoadSome(sampleDataA); Console.Write(sampleDataB); }
public void Good() { var sampleData = LookupA.LoadSomeMaybe(); sampleData.ApplyNone(() => Logger.Log("No data")); sampleData.ApplySome(RepositoryA.Persist); }
public void Good() { var sampleData = LookupA.LoadSomeKmsMaybe(); var content = sampleData .Map(e => e.SomeContent); content.ApplyNone(() => Logger.Log("No data")); content.ApplySome(e => Logger.Log(!string.IsNullOrEmpty(e) ? e : "No content")); }
public void Meh2() { var maybeSampleData = LookupA.LoadSomeKmsMaybe(); foreach (var sampleData in maybeSampleData) { Logger.Log(string.IsNullOrEmpty(sampleData.SomeContent) ? "No content" : sampleData.SomeContent); } //Empty-case? }
public void Great() { var sampleData = LookupA.LoadSomeKmsMaybe(); sampleData.ApplyNone(() => Logger.Log("No data")); var content = sampleData.FlatMap(e => string.IsNullOrEmpty(e.SomeContent) ? new Maybe <string>() : new Maybe <string>(e.SomeContent)); content.ApplyNone(() => Logger.Log("No content")); content.ApplySome(Logger.Log); }
public void Bad() { var sampleData = LookupA.LoadSome(); if (sampleData != null) { RepositoryA.Persist(sampleData); } else { Logger.Log("No data"); } }
public void Bad() { var sampleData = LookupA.LoadSome(); if (sampleData == null) { Logger.Log("No data"); } else { Logger.Log(string.IsNullOrEmpty(sampleData.SomeContent) ? "No content" : sampleData.SomeContent); } }
public void Bad() { var sampleDataA = LookupA.LoadSome(); if (sampleDataA != null) { var sampleDataB = LookupB.LoadSome(sampleDataA); if (sampleDataB != null) { Console.Write(sampleDataB); } } }
public void Meh() { var maybeSampleData = LookupA.LoadSomeKmsMaybe(); if (!maybeSampleData.Any()) { Logger.Log("No data"); } else { Logger.Log(string.IsNullOrEmpty(maybeSampleData.First().SomeContent) ? "No content" : maybeSampleData.First().SomeContent); } }
public void GlobalSetup() { var r = new Random(); for (var x = 0; x < 4096; x++) { for (var y = 0; y < 4096; y++) { HashSetA.Add(new CoordinateA(x, y, 0)); HashSetB.Add(new CoordinateB(x, y, 0)); DictionaryA[new CoordinateA(x, y, 0)] = true; DictionaryB[new CoordinateB(x, y, 0)] = true; } } for (var i = 0; i < 10000; i++) { var x = r.Next(0, 4096); var y = r.Next(0, 4096); LookupA.Add(new CoordinateA(x, y, 0)); LookupB.Add(new CoordinateB(x, y, 0)); } }
public void Worst() { var sampleData = LookupA.LoadSome(); RepositoryA.Persist(sampleData); }
public void Worst() { var sampleData = LookupA.LoadSome(); Logger.Log(sampleData.SomeContent); }
public void Good() { LookupA.LoadSomeMaybe() .FlatMap(LookupB.LoadSomeMaybe) .ApplySome(Console.WriteLine); }