http://www.codinghelmet.com/
Wear a helmet. Even when coding.
Follow Zoran Horvat @zoranh75
How To
What Makes while Loop a Poor Choice in Programming
Wrap System.Random into an Infinite IEnumerable<int>
Substituting Builder with Factory Methods
Option/Maybe Type in C#
Pros and Cons of Multiple Constructors
Defensive Design: An Experiment
Understanding Closures
Delegates and Higher-Order Functions
Derive a Class and Not Invite Bugs Doing So
Making Published Content Editable
Write Unit Tests for Generic Classes
Case against Throwing ArgumentException
Unit Tests for Temporal Coupling between Method Calls
Organize Repository Interfaces to Support CQRS Architecture
How to Test that Collection was Loaded Eagerly?
How to Avoid the Need to Implement ICloneable Interface
What’s so Wrong about If-Then-Else?
Advances in Applying the Builder Design Pattern
Best Practices Implementing IEnumerable
What Makes Design Patterns Fail?
Implement Lazy Default-If-Empty Functionality on Collections
Interface Segregation Principle and Calling Protocols
Understanding the Option (Maybe) Functional Type
Why do We Need Guard Clauses?
Using Module Coupling and Instability Metrics to Guide Refactoring
Measure Module Coupling and Instability Using NDepend
Measure Abstractness of Modules Using NDepend and CQLinq
Reduce Cyclomatic Complexity 1: Null Object
Reduce Cyclomatic Complexity 2: Special Case
Reduce Cyclomatic Complexity 3: Avoiding Optional Parameters
Reduce Cyclomatic Complexity 4: Avoiding Null Parameters
Reduce Cyclomatic Complexity 5: Option<T> Functional Type
Reduce Cyclomatic Complexity 6: Functional Domain Logic
Reduce Cyclomatic Complexity 7: Extension Methods
Reduce Cyclomatic Complexity 8: Map-Reduce Queries
Reduce Cyclomatic Complexity 9: Switchable Factory Methods
Reduce Cyclomatic Complexity 10: Domain Logic in Factories
Reduce Cyclomatic Complexity 11: Working With Collections
Reduce Cyclomatic Complexity 12: Composite Design Pattern
Reduce Cyclomatic Complexity 13: Service Locator Pros and Cons
Reduce Cyclomatic Complexity 14: Service Locator Applied
Reduce Cyclomatic Complexity 15: Guard Clause
Reduce Number of Generic Parameters
Functional Code in C#
Avoid Returning Null from a Method
Cascading Abstract Factories to Eliminate Dependencies
Object Composition Using Chain of Responsibility
Test Validation Logic in Constructors in C#
Visitor Pattern Without Breaking Encapsulation
Ensure Internal Consistency of Mutable and Immutable Objects
Unit Testing Equals and GetHashCode
Best Practices Using Enums
Validate Enumeration Values in Property Setters
Implement IComparable<T> Interface
Should a Class Implement ICloneable or Not?
Validate String Properties in Business Objects
Override Equals and GetHashCode
Bulk Insert into SQL Server Database
Implementing Collection Property for Unique Objects
MS SQL Schema Versioning
Handling Exceptions from Other Threads
Display Row Numbers in WPF ListView Control
ObjectDataProvider Progress and Cancel in XAML
Implement ICloneable Interface
.NET Hints
LINQ Query for Blacklist-Based Spam Filter
LINQ to Find All Modes of an Array
LINQ to Find Mode of an Array
Split Text into Words
LINQ Prime Test
LINQ Expression to Find All Prime Numbers
Get Property Values using LINQ
Set Properties with Reflection on Value Types
Set Property Values using LINQ and Reflection
Lists
Reading List
Programming Exercises
Expression from Numbers
Sudoku Solver
Card Shuffling
Two Smallest Numbers in an Array
Finding a Value in an Unsorted Array
Finding Kth Smallest Element
Finding a Number That Appears Once in an Array
Finding a Value in a Sorted Array
Finding a Majority Element
Paginating an Unsorted Array
Arithmetic Expression Evaluator
Finding Mode of an Array
Converting Number Bases
Reversing an Array
Reducing Fractions
Maximum Sum Subarray
Sum of First N Numbers
Sum of Squares of First N Numbers
Testing If Two Strings are Anagrams
Intersection of Two Unsorted Arrays
Testing if Number is Prime
Finding All Prime Numbers Smaller Than Value
Removing Multiple Spaces from String
Finding Two Numbers That Appear Once in an Array
Number Appearing Once in Array where All Other Numbers Appear Three Times
Prime Factorization
Finding Numbers Which Appear Once in an Unsorted Array
Rotating an Array
Minimum Weight Path Through Matrix
Moving Zero Values to End of Array
Counting Intersection of Two Unsorted Arrays
Lessons on OOP
Lesson 1 - From Structure to Class
Lesson 2 - Class Inheritance
Lesson 3 - Encapsulation
Lesson 4 - Polymorphism
Lesson 5 - Abstract Methods
Lesson 6 - Multiple Inheritance
.NET Code Base
SysExpand Namespace
How To
1
What Makes while Loop a Poor Choice in Programming
2
How to Wrap System.Random Into an Infinite IEnumerable<int> Sequence
3
Substituting the Builder with the Sequence of Factory Methods
4
Custom Implementation of the Option/Maybe Type in C#
5
Pros and Cons of Multiple Constructors
6
Defensive Design: An Experiment
7
Understanding Closures in C#
8
Understanding Delegates and Higher-Order Functions in C#
9
How to Derive a Class and Not Invite Bugs Doing So
10
Simple Design by Example: Making Published Content Editable
11
How to Write Unit Tests for Generic Classes
12
The Case against Throwing ArgumentException and the Like
13
How to Write Unit Tests for Temporal Coupling between Method Calls
14
How to Organize Repository Interfaces to Support CQRS Architecture
15
How to Write a Test to Prove that Collection was Loaded Eagerly?
16
How to Avoid the Need to Implement ICloneable Interface and What to Do Instead
17
Poor Man’s Polymorphism or What’s so Wrong about If-Then-Else?
18
Advances in Applying the Builder Design Pattern
19
Best Practices Implementing the IEnumerable Interface
20
What Makes Design Patterns Fail So Many Times?
21
How to Implement Lazy Default-If-Empty Functionality on Collections
22
Interface Segregation Principle and Calling Protocols
23
Understanding the Option (Maybe) Functional Type
24
Why do We Need Guard Clauses?
25
How to Use Module Coupling and Instability Metrics to Guide Refactoring
26
How to Measure Module Coupling and Instability Using NDepend
27
How to Measure Abstractness of Modules Using NDepend and CQLinq
28
How to Reduce Cyclomatic Complexity Part 1: Null Object Pattern
29
How to Reduce Cyclomatic Complexity Part 2: Special Case Pattern
30
How to Reduce Cyclomatic Complexity Part 3: Avoiding Optional Parameters
31
How to Reduce Cyclomatic Complexity Part 4: Avoiding Null Parameters
32
How to Reduce Cyclomatic Complexity Part 5: Option<T> Functional Type
33
How to Reduce Cyclomatic Complexity Part 6: Functional Domain Logic
34
How to Reduce Cyclomatic Complexity Part 7: Extension Methods
35
How to Reduce Cyclomatic Complexity Part 8: Map-Reduce Queries
36
How to Reduce Cyclomatic Complexity Part 9: Switchable Factory Methods
37
How to Reduce Cyclomatic Complexity Part 10: Domain Logic in Factories
38
How to Reduce Cyclomatic Complexity Part 11: Working With Collections
39
How to Reduce Cyclomatic Complexity Part 12: Composite Design Pattern
40
How to Reduce Cyclomatic Complexity Part 13: Service Locator Pros and Cons
41
How to Reduce Cyclomatic Complexity Part 14: Service Locator Applied
42
How to Reduce Cyclomatic Complexity Part 15: Guard Clause
43
Design Technique to Reduce Number of Generic Parameters
44
How to Write Functional Code in C#: An Example
45
How to Avoid Returning Null from a Method
46
Cascading Abstract Factories to Eliminate Dependencies
47
Object Composition Using Chain of Responsibility Design Pattern
48
How to Easily Test Validation Logic in Constructors in C#
49
How to Apply Visitor Pattern Without Breaking Encapsulation of Concrete Elements
50
How to Ensure Internal Consistency of Mutable and Immutable Objects
51
How to Implement Unit Tests for Equals and GetHashCode Methods
52
Best Practices Using Enums in .NET
53
How to Validate Enumeration Values in Property Setters
54
How to Implement IComparable<T> Interface in Base and Derived Classes
55
The ICloneable Controversy: Should a Class Implement ICloneable or Not?
56
How to Validate String Properties in Business Objects
57
How to Override Equals and GetHashCode Methods in Base and Derived Classes
58
How to Bulk Insert Complex Objects into SQL Server Database
59
How to Implement Collection Property to Contain Unique Objects
60
How to Version SQL Server Database Schema
61
How to Handle Exceptions from Background Worker Thread in .NET
62
How to Display Row Numbers in WPF ListView Control with Static Content
63
How to Show Progress and to Cancel Asynchronous Operation Using WPF ObjectDataProvider and XAML
64
How to Implement ICloneable Interface in Derivable Classes in .NET
.NET Hints
1
LINQ Query for Blacklist-Based Spam Filter
2
LINQ Expression to Find All Modes of an Array
3
LINQ Expression to Find Mode of an Array
4
Regex and LINQ Query to Split Text into Distinct Words
5
LINQ Expression to Test If a Number is Prime
6
LINQ Expression to Find All Prime Numbers
7
How to Get Property Values using LINQ to Objects
8
How to Set Property Value using Reflection on a Value Type
9
How to Set Property Values using LINQ to Objects and Reflection
Lists
1
The Reading List
Programming Exercises
1
Finding Arithmetic Expression to Construct a Value from Given Numbers
2
Sudoku Solver
3
Card Shuffling Problem
4
Finding Two Smallest Numbers in an Array
5
Finding a Value in an Unsorted Array
6
Finding Kth Smallest Element in an Unsorted Array
7
Finding a Number That Appears Once in Array of Duplicated Numbers
8
Finding a Value in a Sorted Array
9
Finding a Majority Element in an Array
10
Paginating an Unsorted Array
11
Simple Arithmetic Expression Evaluator
12
Finding Mode of an Array
13
Converting Number Bases
14
Reversing an Array
15
Reducing Fractions
16
Maximum Sum Subarray
17
Sum of First N Numbers
18
Sum of Squares of First N Numbers
19
Testing If Two Strings are Anagrams
20
Intersection of Two Unsorted Arrays
21
Testing if Number is Prime
22
Finding All Prime Numbers Smaller Than Specified Value
23
Removing Multiple Consecutive Spaces from a String
24
Finding Two Numbers That Appear Once in Array of Duplicated Numbers
25
Finding a Number which Appears Once in Array where All Other Numbers Appear Three Times
26
Prime Factorization
27
Finding Numbers Which Appear Once in an Unsorted Array
28
Rotating an Array
29
Finding Minimum Weight Path Through Matrix
30
Moving Zero Values to the End of the Array
31
Counting Intersection of Two Unsorted Arrays
Object-Oriented Programming Ground Up
1
Lesson 1 - From Structure to Class
2
Lesson 2 - Class Inheritance
3
Lesson 3 - Encapsulation
4
Lesson 4 - Polymorphism
5
Lesson 5 - Abstract Methods
6
Lesson 6 - Multiple Inheritance
webmasters