Skip to Content
C# and .NET Core Test-Driven Development
book

C# and .NET Core Test-Driven Development

by Ayobami Adewole
May 2018
Intermediate to advanced content levelIntermediate to advanced
300 pages
7h 35m
English
Packt Publishing
Content preview from C# and .NET Core Test-Driven Development

Train Wreck

Another anti-pattern that violates LoD is what is called Train Wreck or Chain Calls. This is a chain of functions and occurs when you have a series of C# methods that are appended to each other all in a single line of code. You will know you have written a code with Train Wreck when you are spending time trying to figure out what the line of code does:

loanCalculator.    CalculateHouseLoan(loanDTO).        GetPaymentRate().            GetMaximumYearsToPay();

You might be wondering how this phenomenon violates LoD. First, the code lacks readability and it is not maintainable. Also, the line of code is not reusable as there are three method calls in only a single line of code.

This line of code can be refactored by minimizing the interactions and eliminating ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Design Patterns with C# and .NET Core

Hands-On Design Patterns with C# and .NET Core

Gaurav Aroraa, Jeffrey Chilberto
.NET Core in Action

.NET Core in Action

Dustin Metzgar

Publisher Resources

ISBN: 9781788292481Supplemental Content