Skip to content

Instantly share code, notes, and snippets.

@nbxx
nbxx / System Design.md
Created Mar 28, 2019 — forked from vasanthk/System Design.md
System Design Cheatsheet
View System Design.md

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@nbxx
nbxx / System Design.md
Created Mar 28, 2019 — forked from mylamour/System Design.md
System Design Cheatsheet
View System Design.md

系统设计备忘录

挑选正确的架构约等于选择正确的战斗并做好权衡

基本步骤

  1. 明确系统边界
  • 用户案列 (描述哪些业务,事件,组合在一起会产生什么样的效果)
    • 谁使用这个系统?
    • 他们怎么使用这个系统?
View CrazyVote1.Program.cs
using System;
using System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace CrazyVote1
{
class Program
{
static void Main(string[] args)
View ExtensionAttribute.cs
using System;
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]
public sealed class ExtensionAttribute : Attribute
{
}
}
View ConvertToIcon.cs
/// <summary>
/// Convert Image to Icon.
/// </summary>
/// <param name="image">The source image.</param>
public static Icon ConvertToIcon(Image image, bool nullTonull = false)
{
if (image == null)
{
if (nullTonull)
{
View Program.cs
using System;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
// Want to detect which build is used
Console.WriteLine(BuildConfiguration.IsDebug ? "Debug" : "Release");
View Program.cs
using System.Threading;
using DevLib.Diagnostics;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Benchmark.Run(i =>
View Benchmark.cs
//-----------------------------------------------------------------------
// <copyright file="Benchmark.cs" company="YuGuan Corporation">
// Copyright (c) YuGuan Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DevLib.Diagnostics
{
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
View RunStopwatch.cs
static void Main(string[] args)
{
RunStopwatch(() =>
{
foreach (var item in collection)
{
DoSomething(item);
}
});
}
View Stopwatchforeach.cs
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
foreach (var item in collection)
{
DoSomething(item);
}
stopWatch.Stop();