Considering other architectural principles
Before we close out the chapter, let me share three brief principles that have helped me in my own journey toward good software.
Learning the DRY principle
Don’t Repeat Yourself (DRY) is an important tenant in software development. The DRY principle is oriented around making sure you don’t repeat the same patterns in code throughout your application. Code takes a while to write, read, and maintain, and bugs inevitably do occur at a certain rate per line of code. As a result, you want to strive to solve problems once in a centralized place and then reuse that solution.
Let’s look at some sample code that violates the DRY principle. This code takes in a comma-separated value (CSV) string such as "CSA1234,CMH,ORD"
and translates it into a FlightInfo
object:
public FlightInfo ReadFlightFromCsv(string csvLine) { string[] parts = csvLine.Split(','); const string fallback...