SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Is Your C# Optimized? Woody Pewitt @woodyp woody@pewitt.org
What the heck is optimized C#?
Optimized For Speed Maintainability Flexibility etc…
You Want Speed? Visual Studio Profiler Third-party profilers System.Diagnostics
You Want Maintainability? Get a coding standard! Use A code metric Refactor RefactorRefactor!
Coding Standards Where do you get them?
Cyclomaticcomplexity The complexity M is then defined as: M = E - N + 2P Where E = the number of edges of the graph N = the number of nodes of the graph P = the number of connected components
Code refactoring Code refactoring is "disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior"
DXCore DevExpress http://www.devexpress.com/Products/Visual_Studio_Add-in/DXCore/ CodeRush and DXCore Community Plugins http://code.google.com/p/dxcorecommunityplugins/
Exceptions Are they good? Try { conn.Close(); } catch (InvalidOperationException ex) { Console.WriteLine(ex.GetType().FullName); Console.WriteLine(ex.Message); } if (conn.State != ConnectionState.Closed) { conn.Close(); }
Guidelines: Exceptions Don’t Write unnecessary try-catch code Behavior is correct by default Rethrow using “throw e”  Loses stack frame information Wrap in larger exception Unless you’re sure nobody would ever want to “look inside” Require an exception in a common path
What’s Wrong? public void TransmitResponse(ArrayList responses,  StreamWriterstreamWriter) { foreach (DataResponse response in responses)    { NetworkResponsenetworkResponse = response.GetNetwork(); networkResponse.Send(streamWriter);    } GC.Collect();      // clean up temporary objects } 10
GC.Collect public void TransmitResponse(ArrayList responses,  StreamWriterstreamWriter) { foreach (DataResponse response in responses)    { NetworkResponsenetworkResponse = response.GetNetwork(); networkResponse.Send(streamWriter);    } GC.Collect();      // clean up temporary objects }
Calling GC.Collect Bad because... Each collection has overhead Overhead not really related to # of “dead objects” Collecting one object is as expensive (roughly) as collecting one thousand Especially bad because... GC.Collect() does the most expensive collection
What’s Wrong? public override string ToString() {    string fullString = "";    foreach (string s in strings)    {       fullString += s + " : ";    }    return fullString; } 10
Allocation in Loop public override string ToString() {    string fullString = "";    foreach (string s in strings)    { fullString += s + " : ";    }    return fullString; }
A better way public string ToString() {    StringBuilder fullString = new StringBuilder();    foreach (string s in strings) { fullString.Append(s); fullString.Append(“:”);    }    return fullString.ToString(); }
What’s Wrong? enum ResponseType { ReturnValues, InvalidInput } string CreateWebText(string userInput, ResponseType operation) {    switch (operation) {       case ResponseType.ReturnValues:          userInput = "<h1>Values</h1>" + FilterOutBadStuff(userInput);          break;       case ResponseType.InvalidInput:          userInput = "<h1>Invalid</h1>" + FilterOutBadStuff(userInput);          break;    }    return userInput; } s = CreateWebText(s, (ResponseType) 133);  10
Checking – Method #1 string CreateWebText(string userInput, ResponseType operation) {    if (!Enum.IsDefined(typeof(ResponseType), operation)       throw new InvalidArgumentException(...);    switch (operation) {       case ResponseType.ReturnValues: userInput = "<h1>Values</h1>" + FilterOutBadStuff(userInput);          break;       case ResponseType.InvalidInput: userInput = "<h1>Invalid</h1>" + FilterOutBadStuff(userInput);          break;    }    return userInput; } enumResponseType {  ReturnValues,  InvalidInput, DumpValues, }
Checking – preferred string CreateWebText(string userInput, ResponseType operation) {    switch (operation) {       case ResponseType.ReturnValues: userInput = "<h1>Values</h1>" + FilterOutBadStuff(userInput);          break;       case ResponseType.InvalidInput: userInput = "<h1>Invalid</h1>" + FilterOutBadStuff(userInput);          break;       default:          throw new InvalidArgumentException(...);    }    return userInput; }
Guidelines: enums Don’t Assume that enums can only have defined values Assume that the set of defined values will never change
Questions? Woody Pewitt @woodyp woody@pewitt.org

Weitere ähnliche Inhalte

Was ist angesagt?

c++ Lecture 2
c++ Lecture 2c++ Lecture 2
c++ Lecture 2
sajidpk92
 
LinkedIn TBC JavaScript 100: Functions
 LinkedIn TBC JavaScript 100: Functions LinkedIn TBC JavaScript 100: Functions
LinkedIn TBC JavaScript 100: Functions
Adam Crabtree
 

Was ist angesagt? (20)

Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
 
Advanced functional programing in Swift
Advanced functional programing in SwiftAdvanced functional programing in Swift
Advanced functional programing in Swift
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Introduction to JQ
Introduction to JQIntroduction to JQ
Introduction to JQ
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
c++ Lecture 2
c++ Lecture 2c++ Lecture 2
c++ Lecture 2
 
What\'s New in C# 4.0
What\'s New in C# 4.0What\'s New in C# 4.0
What\'s New in C# 4.0
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
 
Summary of C++17 features
Summary of C++17 featuresSummary of C++17 features
Summary of C++17 features
 
Operator Overloading
Operator Overloading  Operator Overloading
Operator Overloading
 
Extend GraphQL with directives
Extend GraphQL with directivesExtend GraphQL with directives
Extend GraphQL with directives
 
jq: JSON - Like a Boss
jq: JSON - Like a Bossjq: JSON - Like a Boss
jq: JSON - Like a Boss
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
 
Mca 2nd sem u-4 operator overloading
Mca 2nd  sem u-4 operator overloadingMca 2nd  sem u-4 operator overloading
Mca 2nd sem u-4 operator overloading
 
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
 
c++ pointers by Amir Hamza Khan (SZABISTIAN)
c++ pointers by Amir Hamza Khan (SZABISTIAN)c++ pointers by Amir Hamza Khan (SZABISTIAN)
c++ pointers by Amir Hamza Khan (SZABISTIAN)
 
LinkedIn TBC JavaScript 100: Functions
 LinkedIn TBC JavaScript 100: Functions LinkedIn TBC JavaScript 100: Functions
LinkedIn TBC JavaScript 100: Functions
 
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
Egor Bogatov - .NET Core intrinsics and other micro-optimizationsEgor Bogatov - .NET Core intrinsics and other micro-optimizations
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
 
operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++
 
High performance web programming with C++14
High performance web programming with C++14High performance web programming with C++14
High performance web programming with C++14
 

Ähnlich wie Is your C# optimized

Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
Abed Bukhari
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for Java
Jevgeni Kabanov
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 
Whats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPontoWhats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPonto
Paulo Morgado
 
C++ Function
C++ FunctionC++ Function
C++ Function
Hajar
 

Ähnlich wie Is your C# optimized (20)

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#
 
devLink - What's New in C# 4?
devLink - What's New in C# 4?devLink - What's New in C# 4?
devLink - What's New in C# 4?
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
 
Developer Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duoDeveloper Experience i TypeScript. Najbardziej ikoniczne duo
Developer Experience i TypeScript. Najbardziej ikoniczne duo
 
Extreme Swift
Extreme SwiftExtreme Swift
Extreme Swift
 
PostThis
PostThisPostThis
PostThis
 
Rx workshop
Rx workshopRx workshop
Rx workshop
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 
Ensure code quality with vs2012
Ensure code quality with vs2012Ensure code quality with vs2012
Ensure code quality with vs2012
 
Effective Object Oriented Design in Cpp
Effective Object Oriented Design in CppEffective Object Oriented Design in Cpp
Effective Object Oriented Design in Cpp
 
Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for Java
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
 
Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++
 
Whats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPontoWhats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPonto
 
C++ Function
C++ FunctionC++ Function
C++ Function
 

Mehr von Woody Pewitt

San Diego Clound Computing Sep 9th
San Diego Clound Computing Sep 9thSan Diego Clound Computing Sep 9th
San Diego Clound Computing Sep 9th
Woody Pewitt
 

Mehr von Woody Pewitt (13)

Developing serverless applications with .NET on AWS
Developing serverless applications with .NET on AWSDeveloping serverless applications with .NET on AWS
Developing serverless applications with .NET on AWS
 
Qcon sf - html5 cross-platform mobile solutions
Qcon sf - html5 cross-platform mobile solutionsQcon sf - html5 cross-platform mobile solutions
Qcon sf - html5 cross-platform mobile solutions
 
Using html5 to build offline applications
Using html5 to build offline applicationsUsing html5 to build offline applications
Using html5 to build offline applications
 
Super quick introduction to html5
Super quick introduction to html5Super quick introduction to html5
Super quick introduction to html5
 
Technical debt
Technical debtTechnical debt
Technical debt
 
From port 80 to applications
From port 80 to applicationsFrom port 80 to applications
From port 80 to applications
 
Technical Debt
Technical DebtTechnical Debt
Technical Debt
 
Mobile Web Best Practices
Mobile Web Best PracticesMobile Web Best Practices
Mobile Web Best Practices
 
Internet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAMInternet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAM
 
How To Create Web Sites For Mobile Clients
How To Create Web Sites For Mobile ClientsHow To Create Web Sites For Mobile Clients
How To Create Web Sites For Mobile Clients
 
.Net Garbage Collector 101
.Net Garbage Collector 101.Net Garbage Collector 101
.Net Garbage Collector 101
 
San Diego ASP.NET Meeting Oct 21st
San  Diego  ASP.NET Meeting Oct 21stSan  Diego  ASP.NET Meeting Oct 21st
San Diego ASP.NET Meeting Oct 21st
 
San Diego Clound Computing Sep 9th
San Diego Clound Computing Sep 9thSan Diego Clound Computing Sep 9th
San Diego Clound Computing Sep 9th
 

Kürzlich hochgeladen

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
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
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
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
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
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
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
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 

Is your C# optimized

  • 1. Is Your C# Optimized? Woody Pewitt @woodyp woody@pewitt.org
  • 2.
  • 3. What the heck is optimized C#?
  • 4. Optimized For Speed Maintainability Flexibility etc…
  • 5. You Want Speed? Visual Studio Profiler Third-party profilers System.Diagnostics
  • 6. You Want Maintainability? Get a coding standard! Use A code metric Refactor RefactorRefactor!
  • 7. Coding Standards Where do you get them?
  • 8. Cyclomaticcomplexity The complexity M is then defined as: M = E - N + 2P Where E = the number of edges of the graph N = the number of nodes of the graph P = the number of connected components
  • 9. Code refactoring Code refactoring is "disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior"
  • 10. DXCore DevExpress http://www.devexpress.com/Products/Visual_Studio_Add-in/DXCore/ CodeRush and DXCore Community Plugins http://code.google.com/p/dxcorecommunityplugins/
  • 11. Exceptions Are they good? Try { conn.Close(); } catch (InvalidOperationException ex) { Console.WriteLine(ex.GetType().FullName); Console.WriteLine(ex.Message); } if (conn.State != ConnectionState.Closed) { conn.Close(); }
  • 12. Guidelines: Exceptions Don’t Write unnecessary try-catch code Behavior is correct by default Rethrow using “throw e” Loses stack frame information Wrap in larger exception Unless you’re sure nobody would ever want to “look inside” Require an exception in a common path
  • 13. What’s Wrong? public void TransmitResponse(ArrayList responses, StreamWriterstreamWriter) { foreach (DataResponse response in responses) { NetworkResponsenetworkResponse = response.GetNetwork(); networkResponse.Send(streamWriter); } GC.Collect(); // clean up temporary objects } 10
  • 14. GC.Collect public void TransmitResponse(ArrayList responses, StreamWriterstreamWriter) { foreach (DataResponse response in responses) { NetworkResponsenetworkResponse = response.GetNetwork(); networkResponse.Send(streamWriter); } GC.Collect(); // clean up temporary objects }
  • 15. Calling GC.Collect Bad because... Each collection has overhead Overhead not really related to # of “dead objects” Collecting one object is as expensive (roughly) as collecting one thousand Especially bad because... GC.Collect() does the most expensive collection
  • 16. What’s Wrong? public override string ToString() { string fullString = ""; foreach (string s in strings) { fullString += s + " : "; } return fullString; } 10
  • 17. Allocation in Loop public override string ToString() { string fullString = ""; foreach (string s in strings) { fullString += s + " : "; } return fullString; }
  • 18. A better way public string ToString() { StringBuilder fullString = new StringBuilder(); foreach (string s in strings) { fullString.Append(s); fullString.Append(“:”); } return fullString.ToString(); }
  • 19. What’s Wrong? enum ResponseType { ReturnValues, InvalidInput } string CreateWebText(string userInput, ResponseType operation) { switch (operation) { case ResponseType.ReturnValues: userInput = "<h1>Values</h1>" + FilterOutBadStuff(userInput); break; case ResponseType.InvalidInput: userInput = "<h1>Invalid</h1>" + FilterOutBadStuff(userInput); break; } return userInput; } s = CreateWebText(s, (ResponseType) 133); 10
  • 20. Checking – Method #1 string CreateWebText(string userInput, ResponseType operation) { if (!Enum.IsDefined(typeof(ResponseType), operation) throw new InvalidArgumentException(...); switch (operation) { case ResponseType.ReturnValues: userInput = "<h1>Values</h1>" + FilterOutBadStuff(userInput); break; case ResponseType.InvalidInput: userInput = "<h1>Invalid</h1>" + FilterOutBadStuff(userInput); break; } return userInput; } enumResponseType { ReturnValues, InvalidInput, DumpValues, }
  • 21. Checking – preferred string CreateWebText(string userInput, ResponseType operation) { switch (operation) { case ResponseType.ReturnValues: userInput = "<h1>Values</h1>" + FilterOutBadStuff(userInput); break; case ResponseType.InvalidInput: userInput = "<h1>Invalid</h1>" + FilterOutBadStuff(userInput); break; default: throw new InvalidArgumentException(...); } return userInput; }
  • 22. Guidelines: enums Don’t Assume that enums can only have defined values Assume that the set of defined values will never change
  • 23. Questions? Woody Pewitt @woodyp woody@pewitt.org

Hinweis der Redaktion

  1. Demo VS 2010 Profiler…
  2. http://duckduckgo.com/?q=.net%20coding%20standards&amp;kp=-1&amp;kn=1http://msdn.microsoft.com/en-us/library/czefa0ke(v=VS.71).aspx
  3. http://en.wikipedia.org/wiki/Code_refactoringhttp://c2.com/cgi/fullSearch - Ward Cunningham