Defensive Programming in C#

Course Outline Outline
Reading Material
PowerPoint Slides Intro.pptx
DayModulesSharing
1
  • What is Defensive Programming?
  • Clean Code
  • Testable Code and Unit Tests
  • Predictable Code
  • Clean, Testable, and Predictable Methods
  • Example Clean, Testable, and Predictable Methods
  • Demo Creating a Class Library Component
  • Demo Clean, Testable, and Predictable Methods
  • Demo Named Arguments
  • Validating Method Parameters
  • Demo Validating Method Parameters
  • Demo Method Overloading
2
  • Why automated testing?
  • Code First vs. Test First
  • Defining Unit Test Cases
  • Creating Unit Tests
  • Using Test Explorer
  • Generating Unit Tests
  • Unit Tests and Exceptions
  • Dependencies
  • Method Results
  • Demo Returning a Value
  • Demo Returning Exceptions
  • Demo Returning Multiple Values
  • Returning Null
  • Local Variable Declarations
  • If Statements
  • Switch Statements
  • Enums
  • Casting
3
  • Demo Preparing the Sample Code
  • Asserts
  • Anticipated Errors
  • Unexpected Exceptions and a Global Exception Handler
  • Exception Handling
  • Introduction
  • Tolerant Vs Demanding coding styles
  • Pre-Conditions
  • Post-Conditions
  • Class Invariant
  • Loop Invariant
  • 8-Puzzle