3 How bad is this code?

 

This chapter covers

  • HTTP routes, resources, and endpoints
  • Auto-properties and init-only setters
  • Configuring an ASP.NET service

In this chapter, we’ll meet Flying Dutchman Airlines, who have hired us to refactor their legacy codebase. Flying Dutchman has told us their business needs and given us their requirements for the refactor. Their legacy application, which we’ll examine in this (and the next) chapter, is a backend web service developed on the .NET Framework following the Model-View-Controller (MVC) pattern. The code has many readability and security issues, so don’t be surprised if there are pieces of code in this chapter that you don’t like. The point of this chapter is for us to determine where we can change the existing codebase. We’ll look in-depth at the models, views, and configuration of the (messy) codebase in this chapter to prepare for refactoring the code in later chapters. Figure 3.1 shows where we are in the scheme of the book.

Figure 3.1 In this chapter, we’ll start part 2: The existing codebase. We’ll look at what requirements are laid out for us to address in the rest of the book and what models and views the existing codebase contains.

3.1 Introducing Flying Dutchman Airlines

3.2 Pieces of the puzzle: Taking a look at our requirements

3.2.1 Object-relational mapping

3.2.2 The GET /flight endpoint: Retrieving information on all flights

3.2.3 The GET /flight/{flightNumber} endpoint: Getting specific flight information

3.2.4 The POST /booking/{flightNumber} endpoint: Booking a flight

3.3 Coming to terms with the existing codebase

3.3.1 Assessing the existing database schema and its tables

3.3.2 The existing codebase: Web service configuration files

3.3.3 Considering models and views in the existing codebase

Summary

sitemap