Collection: Real-World Refactoring
As you advance through your career, you experience a lot and learn different ways to code. Today, I show you my collection of real-world refactoring posts.
If you've been a programmer for a long time (10+ years), you start to see some interesting code moving from company to company. This "interesting code" becomes refactored and turns into patterns. Finally, the patterns turn into repeatable segments of code to use throughout your career.
Once you've seen a familiar piece of code, your years of experience tell you that this is a type of Observable pattern or it's a Strategy pattern.
After learning multiple design patterns and as years continue, you become adept at creating combinations of designs patterns like integrating a Builder pattern with a Strategy pattern.
Are you one of these developers?
Every time, you get into one of those coding frenzies, you go into a "code-mode." A "zoning out" where you can't hear anything but your mind telling you how the code is supposed to work.
Everything around you becomes irrelevant and the subconscious stream moving from your mind to your hands cannot move fast enough.
Now, while "Swordfish" was not my favorite movie, it definitely portrayed some of the actions a developer experiences while coding.
When you find out how to do something with code, make it efficient, and make it easy to use, you want to shout from the highest mountain top that you did it. Even do a happy dance like Mr. Jackman, there!
These real-world refactoring techniques aren't mind-blowing, but these techniques use design patterns in their approach.
This post, of course, will be an evolving document of additional real-world refactorings as my career continues.
- Real-World Refactoring: Switch Twitch Itch
After my previous post about turning a switch statement to a class hierarchy, I feel today would be a great day to discuss turning enums into a classes.
- Real-World Refactoring: Replacing ASP.NET MVC Conditional Dispatcher With Command
When posting back from a grid to an MVC POST action, you could encounter a number of conditions that grows into an if..else from hell. Here's how to take it from a Conditional Dispatcher into a Command pattern.
- Real-World Refactoring: Filtering products using a Builder Pattern
Everyone searches for products at their favorite store on the Internet. Today, I show you how to build a simple product search filter using a builder/fluent pattern.
- Real-World Refactoring: Switch Statement to a Class Hierarchy
When I see a switch statement in C#, I kind of cringe. In this post, I'll demonstrate how to refactor a switch statement to a better, more maintainable class.
- Real-World Refactoring: Avoiding the "Reese's Cup" Problem
When you need to send data to the browser, sometimes it's easier to use existing HTML instead of coding a web page using JSON. Here is a technique on how to use your existing MVC code to perform the heavy lifting.
- Real-World Refactoring: .Sort() vs. .OrderBy()
In this post, I discuss the most flexible way to perform sorts and the answer may surprise you.
- Real-World Refactoring: Master/Detail Screens
During a recent process of building a master/detail screen, there had to be an easier way to update dynamic grids. This post explains an easier way to build and maintain a master/detail with grids.
Most of these techniques I've learned over time and I hope they help you in your development as well.
If you are interested in learning more about refactoring and learning new patterns, I would recommend viewing the Top 10 Books Every .NET Developer Should Own.
If you have any refactoring techniques that you'd like to share with others, post your comments below.
- Collection: Real-world Refactoring
- Collection: How to be a Great Developer
- Collection: Architect References
- Collection: Inspiration/Motivation
- Collection: Blockchain
- Collection: SQL Server Sample Databases
- Collection: Beginner Tutorials for ASP.NET MVC
- Collection: GitHub Resources for Beginners
- Collection: Cloud Design Patterns and Practices
- Collection: CSS Resources
- Collection: Web API Best Practices