SlideShare ist ein Scribd-Unternehmen logo
1 von 62
Downloaden Sie, um offline zu lesen
System.Activator
public class C {
  public C() { … }
}




public class C {
  public static C NewC() {
    return new C();
  }
}
private



          base()   this()
class PersonFactory {
  public Person MakePerson(
    int age)
  {
    if (age < 18)
      return new Minor();
    else
      return new Adult();
  }
}
string.Format(
  “<person name=”{0}”,
  name)




XElement(“person”,
  XAttribute(“name”, name))
  .ToString();
StringBuilder        AppendFormat()
AppendLine()

  Util.AppendFormatLine(stringBuilder, format, params)

  stringBuilder.AppendFormatLine(format, params)


stringBuilder.AppendFormat(“… {0}”, params,
Environment.NewLine)
MemberwizeClone


ICloneable
              Clone()




ToString() GetHashCode()
[Serializable]
public abstract class IPrototype<T>
{
  public T DeepCopy()
  {
    MemoryStream stream = new MemoryStream();
    BinaryFormatter formatter = new BinaryFormatter();
    formatter.Serialize(stream, this);
    stream.Seek(0, SeekOrigin.Begin);
    T copy = (T)formatter.Deserialize(stream);
    stream.Close();
    return copy;
  }
}
DeepCopy
                 IPrototype<T>



 
 
 WeakReference
new
public class C
{
  private C() { /* nothing here */ }

    class CMaker {
      static CMaker () { }
      internal static readonly C instance = new C();
    }

    public static C Instance {
      get { return CMaker.instance; }
    }
}
x:Static
Random
class RandomGenerator {
  public Random GetRandom() {
    return new Random(); // not what I want
  }
}

interface IRandom {
  int RandomNumber();
}
RandomGenerator
          IRandom


class RandomAdapter:
  RandomGenerator, IRandom
{
  int RandomNumber() {
    return GetRandom().Next();
  }
}
– RandomGenerator rg = new RandomGenerator();
  Random r = rg.GetRandom();


– IRandom rand = new Adapter();
  int n = rand.RandomNumber();
– class C { … }
– class CCollection : Collection<C> { … }

 class CContainer {
   private Collection<C> items;
 }
class Neuron
{ … }

class Layer :
Collection<Neuron>
{ … }

neuron.ConnectTo(otherNeuron);
neuron.ConnectTo(layer);
layer.ConnectTo(neuron);
layer.ConnectTo(otherLayer);
– IEnumerable<T>
            yield return this;

     ICollection<T>
Card   CardInPlay

♣ ♠ ♥ ♦

                    Rank
                    Suit
          Rank
          Suit
                 Orientation
IA   IB
 A   B
→
→
new
               Bitmap
      byte[]
Reflection.Emit
XElement.Parse
      →
IEnumerable<T>
   yield return
GetEnumerator()

  AsyncEnumerator
→

→
interface ICarState
{
  void Go(Context ctx); // Drive?
}
class Context {
  ICarState state;
  public void GoGoGo() {
    state.Go(this);
    state.Go(this); // yeah, right :)
    state.Go(this);
  }
}
class CrashedState :            class MovingState :
ICarState                       ICarState
{                               {
  void Go(Context ctx)            void Go(Context ctx)
  {                               {
    MessageBox.Show(                // driving
      “Are you crazy?”);            // is that a rock?
  }
}                                       // CRASH!
                    The state           ctx.state =
                       just               new CrashedState();
                     changed!       }
                                }
interface IStrategy
{
  void Evaluate(Context ctx);
}

SingleEvaluator, ParralelEvaluator,
GpuEvaluator
class Context {
  IStrategy strategy;
  Matrix m1, m2;
  static void Multiply(Matrix m1, Matrix m2)
  { this.m1 = m1; this.m2 = m2;
    if (strategy == null) { // on-demand
      if (gpu.pixelShader >= 2.0)
        strategy = new GpuStrategy();
      else if (Environment.ProcessorCount > 1)
        strategy = new ParallelStrategy();
      else strategy = new SingleStrategy();
    }
    strategy.Evaluate(this);
  }
}
→
    →
StringBuilder


Weitere ähnliche Inhalte

Was ist angesagt?

Fisica ii codigo
Fisica ii codigoFisica ii codigo
Fisica ii codigoeaceved5
 
Node.js and angular js
Node.js and angular jsNode.js and angular js
Node.js and angular jsHyungKuIm
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in DepthC4Media
 
Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax BasicsRichard Paul
 
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в JavaDEVTYPE
 
What is row level isolation on cassandra
What is row level isolation on cassandraWhat is row level isolation on cassandra
What is row level isolation on cassandraKazutaka Tomita
 
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsTypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsAlfonso Peletier
 
Низкоуровневые оптимизации .NET-приложений
Низкоуровневые оптимизации .NET-приложенийНизкоуровневые оптимизации .NET-приложений
Низкоуровневые оптимизации .NET-приложенийAndrey Akinshin
 
Boxing & unboxing
Boxing & unboxingBoxing & unboxing
Boxing & unboxingLarry Nung
 
iOS Development with Blocks
iOS Development with BlocksiOS Development with Blocks
iOS Development with BlocksJeff Kelley
 
Functional JavaScript for everyone
Functional JavaScript for everyoneFunctional JavaScript for everyone
Functional JavaScript for everyoneBartek Witczak
 
LOFAR - finding transients in the radio spectrum
LOFAR - finding transients in the radio spectrumLOFAR - finding transients in the radio spectrum
LOFAR - finding transients in the radio spectrumGijs Molenaar
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simplerAlexander Mostovenko
 
vbscript-reference book
vbscript-reference bookvbscript-reference book
vbscript-reference bookAnand Dhana
 
Brief intro to clojure
Brief intro to clojureBrief intro to clojure
Brief intro to clojureRoy Rutto
 
Using Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data VisualisationUsing Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data VisualisationAlex Hardman
 
オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)Takayuki Goto
 

Was ist angesagt? (20)

Fisica ii codigo
Fisica ii codigoFisica ii codigo
Fisica ii codigo
 
Node.js and angular js
Node.js and angular jsNode.js and angular js
Node.js and angular js
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in Depth
 
Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax Basics
 
Litebox
LiteboxLitebox
Litebox
 
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java
 
What is row level isolation on cassandra
What is row level isolation on cassandraWhat is row level isolation on cassandra
What is row level isolation on cassandra
 
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsTypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
 
Низкоуровневые оптимизации .NET-приложений
Низкоуровневые оптимизации .NET-приложенийНизкоуровневые оптимизации .NET-приложений
Низкоуровневые оптимизации .NET-приложений
 
Boxing & unboxing
Boxing & unboxingBoxing & unboxing
Boxing & unboxing
 
iOS Development with Blocks
iOS Development with BlocksiOS Development with Blocks
iOS Development with Blocks
 
Functional JavaScript for everyone
Functional JavaScript for everyoneFunctional JavaScript for everyone
Functional JavaScript for everyone
 
LOFAR - finding transients in the radio spectrum
LOFAR - finding transients in the radio spectrumLOFAR - finding transients in the radio spectrum
LOFAR - finding transients in the radio spectrum
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simpler
 
The jsdom
The jsdomThe jsdom
The jsdom
 
vbscript-reference book
vbscript-reference bookvbscript-reference book
vbscript-reference book
 
Brief intro to clojure
Brief intro to clojureBrief intro to clojure
Brief intro to clojure
 
Using Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data VisualisationUsing Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data Visualisation
 
NS2 Object Construction
NS2 Object ConstructionNS2 Object Construction
NS2 Object Construction
 
オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)
 

Andere mochten auch

Some Design Pattern in .NET C#
Some Design Pattern in .NET C#Some Design Pattern in .NET C#
Some Design Pattern in .NET C#Gilang Aziz
 
Interviewing Skills - Lesson 1
Interviewing Skills - Lesson 1Interviewing Skills - Lesson 1
Interviewing Skills - Lesson 1SkimaTalk
 
LESSON PLAN Basic sentence pattern
LESSON PLAN Basic sentence patternLESSON PLAN Basic sentence pattern
LESSON PLAN Basic sentence patternPristine Estorque
 
Design patterns through refactoring
Design patterns through refactoringDesign patterns through refactoring
Design patterns through refactoringGanesh Samarthyam
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorialClaude Tech
 
Patterns number and geometric
Patterns  number and geometricPatterns  number and geometric
Patterns number and geometricamdzubinski
 
Repeating and growing patterns
Repeating and growing patternsRepeating and growing patterns
Repeating and growing patternsJessica Weesies
 
Why angular js Framework
Why angular js Framework Why angular js Framework
Why angular js Framework Sakthi Bro
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JSAkshay Mathur
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node jsAkshay Mathur
 
Object-oriented design patterns in UML [Software Modeling] [Computer Science...
Object-oriented design patterns  in UML [Software Modeling] [Computer Science...Object-oriented design patterns  in UML [Software Modeling] [Computer Science...
Object-oriented design patterns in UML [Software Modeling] [Computer Science...Ivano Malavolta
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular jsAayush Shrestha
 
Design Patterns
Design PatternsDesign Patterns
Design Patternssoms_1
 

Andere mochten auch (20)

Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)
 
Some Design Pattern in .NET C#
Some Design Pattern in .NET C#Some Design Pattern in .NET C#
Some Design Pattern in .NET C#
 
Interviewing Skills - Lesson 1
Interviewing Skills - Lesson 1Interviewing Skills - Lesson 1
Interviewing Skills - Lesson 1
 
Angular js
Angular jsAngular js
Angular js
 
Angular js
Angular jsAngular js
Angular js
 
LESSON PLAN Basic sentence pattern
LESSON PLAN Basic sentence patternLESSON PLAN Basic sentence pattern
LESSON PLAN Basic sentence pattern
 
Design patterns through refactoring
Design patterns through refactoringDesign patterns through refactoring
Design patterns through refactoring
 
Creational Design Patterns
Creational Design PatternsCreational Design Patterns
Creational Design Patterns
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorial
 
Node js meetup
Node js meetupNode js meetup
Node js meetup
 
Patterns number and geometric
Patterns  number and geometricPatterns  number and geometric
Patterns number and geometric
 
Get satrted angular js
Get satrted angular jsGet satrted angular js
Get satrted angular js
 
Repeating and growing patterns
Repeating and growing patternsRepeating and growing patterns
Repeating and growing patterns
 
Angular 2
Angular 2Angular 2
Angular 2
 
Why angular js Framework
Why angular js Framework Why angular js Framework
Why angular js Framework
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
Object-oriented design patterns in UML [Software Modeling] [Computer Science...
Object-oriented design patterns  in UML [Software Modeling] [Computer Science...Object-oriented design patterns  in UML [Software Modeling] [Computer Science...
Object-oriented design patterns in UML [Software Modeling] [Computer Science...
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 

Ähnlich wie Design Patterns in .Net

Spring data access
Spring data accessSpring data access
Spring data access명철 강
 
Java and XML Schema
Java and XML SchemaJava and XML Schema
Java and XML SchemaRaji Ghawi
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeletonIram Ramrajkar
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
Design pattern - part 3
Design pattern - part 3Design pattern - part 3
Design pattern - part 3Jieyi Wu
 
Imagine a world without mocks
Imagine a world without mocksImagine a world without mocks
Imagine a world without mockskenbot
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheeltcurdt
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersBartosz Kosarzycki
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfarjuncorner565
 
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdfimport java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdfshaktisinhgandhinaga
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Juan Pablo
 
java experiments and programs
java experiments and programsjava experiments and programs
java experiments and programsKaruppaiyaa123
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good TestsTomek Kaczanowski
 
Ast transformations
Ast transformationsAst transformations
Ast transformationsHamletDRC
 
RxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниRxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниStfalcon Meetups
 

Ähnlich wie Design Patterns in .Net (20)

Spring data access
Spring data accessSpring data access
Spring data access
 
Java and XML Schema
Java and XML SchemaJava and XML Schema
Java and XML Schema
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
 
Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Design pattern - part 3
Design pattern - part 3Design pattern - part 3
Design pattern - part 3
 
Imagine a world without mocks
Imagine a world without mocksImagine a world without mocks
Imagine a world without mocks
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
 
Sneaking inside Kotlin features
Sneaking inside Kotlin featuresSneaking inside Kotlin features
Sneaking inside Kotlin features
 
Map kit light
Map kit lightMap kit light
Map kit light
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developers
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
 
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdfimport java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
 
DataTypes.ppt
DataTypes.pptDataTypes.ppt
DataTypes.ppt
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
java experiments and programs
java experiments and programsjava experiments and programs
java experiments and programs
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
Ss
SsSs
Ss
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
RxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниRxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камни
 

Mehr von Dmitri Nesteruk

Good Ideas in Programming Languages
Good Ideas in Programming LanguagesGood Ideas in Programming Languages
Good Ideas in Programming LanguagesDmitri Nesteruk
 
Design Pattern Observations
Design Pattern ObservationsDesign Pattern Observations
Design Pattern ObservationsDmitri Nesteruk
 
CallSharp: Automatic Input/Output Matching in .NET
CallSharp: Automatic Input/Output Matching in .NETCallSharp: Automatic Input/Output Matching in .NET
CallSharp: Automatic Input/Output Matching in .NETDmitri Nesteruk
 
Design Patterns in Modern C++
Design Patterns in Modern C++Design Patterns in Modern C++
Design Patterns in Modern C++Dmitri Nesteruk
 
Introduction to Programming Bots
Introduction to Programming BotsIntroduction to Programming Bots
Introduction to Programming BotsDmitri Nesteruk
 
Converting Managed Languages to C++
Converting Managed Languages to C++Converting Managed Languages to C++
Converting Managed Languages to C++Dmitri Nesteruk
 
YouTrack: Not Just an Issue Tracker
YouTrack: Not Just an Issue TrackerYouTrack: Not Just an Issue Tracker
YouTrack: Not Just an Issue TrackerDmitri Nesteruk
 
Victor CG Erofeev - Metro UI
Victor CG Erofeev - Metro UIVictor CG Erofeev - Metro UI
Victor CG Erofeev - Metro UIDmitri Nesteruk
 
Dynamics CRM Data Integration
Dynamics CRM Data IntegrationDynamics CRM Data Integration
Dynamics CRM Data IntegrationDmitri Nesteruk
 
ReSharper Presentation for NUGs
ReSharper Presentation for NUGsReSharper Presentation for NUGs
ReSharper Presentation for NUGsDmitri Nesteruk
 
ReSharper Architecture & Extensions
ReSharper Architecture & ExtensionsReSharper Architecture & Extensions
ReSharper Architecture & ExtensionsDmitri Nesteruk
 

Mehr von Dmitri Nesteruk (20)

Good Ideas in Programming Languages
Good Ideas in Programming LanguagesGood Ideas in Programming Languages
Good Ideas in Programming Languages
 
Design Pattern Observations
Design Pattern ObservationsDesign Pattern Observations
Design Pattern Observations
 
CallSharp: Automatic Input/Output Matching in .NET
CallSharp: Automatic Input/Output Matching in .NETCallSharp: Automatic Input/Output Matching in .NET
CallSharp: Automatic Input/Output Matching in .NET
 
Design Patterns in Modern C++
Design Patterns in Modern C++Design Patterns in Modern C++
Design Patterns in Modern C++
 
C# Tricks
C# TricksC# Tricks
C# Tricks
 
Introduction to Programming Bots
Introduction to Programming BotsIntroduction to Programming Bots
Introduction to Programming Bots
 
Converting Managed Languages to C++
Converting Managed Languages to C++Converting Managed Languages to C++
Converting Managed Languages to C++
 
Monte Carlo C++
Monte Carlo C++Monte Carlo C++
Monte Carlo C++
 
Tpl DataFlow
Tpl DataFlowTpl DataFlow
Tpl DataFlow
 
YouTrack: Not Just an Issue Tracker
YouTrack: Not Just an Issue TrackerYouTrack: Not Just an Issue Tracker
YouTrack: Not Just an Issue Tracker
 
Проект X2C
Проект X2CПроект X2C
Проект X2C
 
Domain Transformations
Domain TransformationsDomain Transformations
Domain Transformations
 
Victor CG Erofeev - Metro UI
Victor CG Erofeev - Metro UIVictor CG Erofeev - Metro UI
Victor CG Erofeev - Metro UI
 
Developer Efficiency
Developer EfficiencyDeveloper Efficiency
Developer Efficiency
 
Distributed Development
Distributed DevelopmentDistributed Development
Distributed Development
 
Dynamics CRM Data Integration
Dynamics CRM Data IntegrationDynamics CRM Data Integration
Dynamics CRM Data Integration
 
ReSharper Presentation for NUGs
ReSharper Presentation for NUGsReSharper Presentation for NUGs
ReSharper Presentation for NUGs
 
ReSharper Architecture & Extensions
ReSharper Architecture & ExtensionsReSharper Architecture & Extensions
ReSharper Architecture & Extensions
 
Web mining
Web miningWeb mining
Web mining
 
Data mapping tutorial
Data mapping tutorialData mapping tutorial
Data mapping tutorial
 

Kürzlich hochgeladen

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 

Kürzlich hochgeladen (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

Design Patterns in .Net

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 9. public class C { public C() { … } } public class C { public static C NewC() { return new C(); } }
  • 10. private base() this()
  • 11. class PersonFactory { public Person MakePerson( int age) { if (age < 18) return new Minor(); else return new Adult(); } }
  • 12. string.Format( “<person name=”{0}”, name) XElement(“person”, XAttribute(“name”, name)) .ToString();
  • 13.
  • 14. StringBuilder AppendFormat() AppendLine() Util.AppendFormatLine(stringBuilder, format, params) stringBuilder.AppendFormatLine(format, params) stringBuilder.AppendFormat(“… {0}”, params, Environment.NewLine)
  • 15.
  • 16. MemberwizeClone ICloneable Clone() ToString() GetHashCode()
  • 17. [Serializable] public abstract class IPrototype<T> { public T DeepCopy() { MemoryStream stream = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, this); stream.Seek(0, SeekOrigin.Begin); T copy = (T)formatter.Deserialize(stream); stream.Close(); return copy; } }
  • 18. DeepCopy IPrototype<T>   WeakReference
  • 19. new
  • 20. public class C { private C() { /* nothing here */ } class CMaker { static CMaker () { } internal static readonly C instance = new C(); } public static C Instance { get { return CMaker.instance; } } }
  • 22.
  • 23.
  • 24. Random class RandomGenerator { public Random GetRandom() { return new Random(); // not what I want } } interface IRandom { int RandomNumber(); }
  • 25. RandomGenerator IRandom class RandomAdapter: RandomGenerator, IRandom { int RandomNumber() { return GetRandom().Next(); } }
  • 26. – RandomGenerator rg = new RandomGenerator(); Random r = rg.GetRandom(); – IRandom rand = new Adapter(); int n = rand.RandomNumber();
  • 27.
  • 28. – class C { … } – class CCollection : Collection<C> { … } class CContainer { private Collection<C> items; }
  • 29. class Neuron { … } class Layer : Collection<Neuron> { … } neuron.ConnectTo(otherNeuron); neuron.ConnectTo(layer); layer.ConnectTo(neuron); layer.ConnectTo(otherLayer);
  • 30. – IEnumerable<T> yield return this; ICollection<T>
  • 31.
  • 32. Card CardInPlay ♣ ♠ ♥ ♦ Rank Suit Rank Suit Orientation
  • 33.
  • 34. IA IB A B
  • 35.
  • 37.
  • 38. new Bitmap byte[]
  • 40.
  • 41.
  • 42.
  • 43.
  • 45. IEnumerable<T> yield return GetEnumerator() AsyncEnumerator
  • 46.
  • 47.
  • 48.
  • 50.
  • 51. interface ICarState { void Go(Context ctx); // Drive? }
  • 52. class Context { ICarState state; public void GoGoGo() { state.Go(this); state.Go(this); // yeah, right :) state.Go(this); } }
  • 53. class CrashedState : class MovingState : ICarState ICarState { { void Go(Context ctx) void Go(Context ctx) { { MessageBox.Show( // driving “Are you crazy?”); // is that a rock? } } // CRASH! The state ctx.state = just new CrashedState(); changed! } }
  • 54.
  • 55.
  • 56. interface IStrategy { void Evaluate(Context ctx); } SingleEvaluator, ParralelEvaluator, GpuEvaluator
  • 57. class Context { IStrategy strategy; Matrix m1, m2; static void Multiply(Matrix m1, Matrix m2) { this.m1 = m1; this.m2 = m2; if (strategy == null) { // on-demand if (gpu.pixelShader >= 2.0) strategy = new GpuStrategy(); else if (Environment.ProcessorCount > 1) strategy = new ParallelStrategy(); else strategy = new SingleStrategy(); } strategy.Evaluate(this); } }
  • 58.
  • 60.
  • 61.
  • 62.