Code like a Pro in C#
Jort Rodenburg
  • MEAP began April 2020
  • Publication in Fall 2020 (estimated)
  • ISBN 9781617298028
  • 425 pages (estimated)
  • printed in black & white

All developers should read a book like this.

Hilde Van Gysel
Critical business applications worldwide are written in the versatile C# language and the powerful .NET platform, running on desktops, cloud systems, and Windows or Linux servers. Code Like a Pro in C# makes it easy to turn your existing abilities in C# or another OO language (such as Java) into practical C# mastery. There’s no “Hello World” or Computer Science 101 basics—you’ll learn by refactoring an out-of-date legacy codebase, using new techniques, tools, and best practices to bring it up to modern C# standards. Each technique is reinforced through coding katas and clean code best practices, locking in the skills you’ll need to tackle any job and ace your next interview.

About the Technology

C# and the .NET framework are prized for their power, flexibility, and ease of scaling. Line-of-business applications, web systems running ASP.NET, and backend servers powering enterprise data centers all rely on C#. Growing into a C# pro requires practice in real-world systems, where you learn to refactor messy code and integrate new features into existing designs. Code Like a Pro in C# lays out a path to C# mastery, tackling common challenges such as clean coding, idiomatic C#, and .NET Core that can stump aspiring C# software engineers.

About the book

Code like a Pro in C# builds on your existing programming skills to help you seamlessly upskill your coding practice or transition to C# from Java or another OO language. You’ll learn to write the kind of idiomatic C# code that’s essential for enterprise development, honing your mastery with guided coding katas. This book discusses essential backend skills and puts them into practice with a common career challenge: refactoring a legacy codebase to be secure, clean, and readable. By the time you’re done, you’ll have a professional-level understanding of C# and be ready to start specializing with advanced-level resources.
Table of Contents detailed table of contents

Part 1: Introduction

1 This is C#

1.1 Why work in C#?

1.1.1 Reason 1: C# is scalable and economical

1.1.2 Reason 2: C# can improve stability

1.1.3 Reason 3: C# is developer-friendly and easy to use

1.1.4 Reason 4: C# goes hand-in-hand with cloud and CI/CD

1.2 Why not work in C#?

1.2.1 Operating system development in C#

1.2.2 Real-Time Operating System embedded development in C#

1.2.3 Numerical computing and C#

1.3 Switching to C#

1.4 The importance of “Clean Code”

1.5 What you will learn in this book

1.6 What you will not learn in this book

1.7 How this book is structured

1.8 Summary

2 Tour de C# and .NET

2.1 The .NET Framework compared to other platforms

2.1.1 The .NET Framework compared to other platforms: tuples

2.1.2 The .NET Framework compared to other platforms: events

2.1.3 The .NET Framework compared to other platforms: SQL

2.1.4 The .NET Framework compared to other platforms: CSV parser

2.1.5 Exercises

2.2 What is .NET Core?

2.2.1 Exercises

2.3 What is .NET Framework 5?

2.4 How C# is compiled

2.4.1 Step 1: C# code (high-level)

2.4.2 Step 2: Common Intermediate Language (assembly level)

2.4.3 Step 3: Bytecode (Processor Level)

2.4.4 Exercises

2.5 Summary

Part 2: Inheriting Code

3 Inheriting code: requirements, models, and views

3.1 Introducing “Flying Dutchman Airlines”

3.2 Pieces of the puzzle

3.2.1 The GET /flight endpoint: retrieving information on all flights

3.2.2 GET /flight/{flightNumber}

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

3.2.4 Exercises

3.3 The existing code

3.3.1 The database schema and its tables

3.3.2 The existing codebase: web service configurations files

3.3.3 Models and views

3.4 Summary

4 Inheriting code: controllers

4.1 The FlightController: GET /flight endpoint

4.1.1 The GET /flight endpoint and what it does

4.1.2 Method Signature: the ResponseType and Typeof story

4.1.3 Collecting flight information with collections

4.1.4 Connection strings; or how to give a security engineer a heart-attack

4.1.5 Garbage collection through using statements and IDisposable

4.2 The FlightController: GET /flight/{flightNumber}

4.3 The FlightController: POST /flight

4.4 The FlightController: DELETE /flight/{flightNumber}

4.5 Exercises

4.6 Summary

Part 3: The Refactor

5 The refactor: setup and the database access layer

5.1 Creating a .NET Core solution and project

5.2 Setting up and configuring a web service

5.2.1 Configuring a .NET Core web service

5.2.2 Using The Builder pattern in C#

5.2.3 Creating and using WebHostBuilder

5.2.4 Implementing te Startup class

5.2.5 Using the Repository Pattern for our web service architecture

5.3 Implementing the database access layer

5.3.1 Entity Framework Core and “Reverse-Engineering”

5.3.2 DbSet and the Entity Framework Core workflow

5.3.3 Configuration Methods and environment variables

5.3.4 Setting an environment variable on Windows

5.3.5 Setting an environment variable on OSX

5.3.6 Retrieving environment variables at runtime in your code

5.4 Exercises

5.5 Summary

6 The refactor: the repository layer (Customer)

6.1 Test-Driven Development

6.1.1 Exercises

6.2 The CreateCustomer method

6.2.1 Why you should always validate input arguments

6.2.2 Using Arrange, Act, Assert to write unit tests

6.2.3 Validating against invalid characters and LINQ

6.2.4 In-lining test data with the [DataRow] attribute

6.2.5 Object initializers and auto-generated code

6.2.6 Constructors, reflection, and asynchronous programming

6.2.7 Locks, mutexes, and semaphores

6.2.8 Synchronous to asynchronous execution… continued

6.2.9 Dependency Injection and testing Entity Framework Core

6.2.10 Exercises

6.3 Summary

7 The refactor: the repository layer (Customer) continued

7.1 The GetCustomerByName method

7.1.1 Question marks: nullable types and their applications

7.1.2 Custom exceptions, LINQ, and Extension methods

7.2 Congruence: from the middle ages to C#

7.2.1 Creating a “Comparer” class

7.2.2 Overloading the equality operator

7.3 Exercises

7.4 Summary

8 The refactor: the repository layer (Booking)

9 The refactor: the repository layer (Airport and Flight)

10 The refactor: the service layer(Customer and Booking)

11 The refactor: the service layer (Booking) continued

12 The refactor: the service layer (Airport and Flight)

13 The refactor: controllers

14 The refactor: integration testing

15 Coding katas #1

16 Coding katas #2


Appendix A: Exercise Answers

Appendix B: Clean Code checklists

Appendix C: Installation Guides

Appendix D: OpenAPI FlyTomorrow

Appendix E: Reading List

What's inside

  • Test-driven development
  • Refactoring an API to a multi-platform .NET Core service
  • Principles of clean code
  • Using Entity Framework Core and LINQ to query and manipulate databases

About the reader

For developers experienced with object-oriented programming. No C# experience required.

About the author

Jort Rodenburg is a software engineer specializing in C#. He has built software for numerous fields, from financial compliance to inkjet printing. Jort has mentored and taught courses on object-oriented programming to help developers get up to speed with C# and .NET.

placing your order...

Don't refresh or navigate away from the page.
Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
print book $35.99 $59.99 pBook + eBook + liveBook
Additional shipping charges may apply
Code like a Pro in C# (print book) added to cart
continue shopping
go to cart

eBook $33.59 $47.99 3 formats + liveBook
Code like a Pro in C# (eBook) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.

FREE domestic shipping on three or more pBooks