#csharp
35 articles tagged with #csharp
TypeScript for C# developers - Part 1
TypeScript for C# developers introduces types, interfaces, classes, enums, lambdas, null checks, compilation and familiar concepts from C# development for practical guidance.
How to migrate an ASP.NET MVC 5 app to ASP.NET Core 1.0?
Migrating an ASP.NET MVC 5 application to ASP.NET Core 1.0 explained through project structure, middleware, dependency injection, configuration, routing and migration risks.
How to write maintainable LINQ and Entity Framework queries?
Maintainable LINQ and Entity Framework queries explained through in-memory filtering, N+1 queries, projection, tracking and practices for readable query code.
Defensive coding - guard clauses and null checks without the noise
Defensive coding explained through guard clauses, boundary validation, specific exceptions, null checks, empty collections and clearer .NET application logic for practical guidance.
Test Driven Development (TDD) - is it worth it for our team
Test-Driven Development evaluated through its design benefits, upfront costs, defect feedback, suitable code areas and a gradual adoption approach for teams.
What is a Test Double - stub vs mock vs fake
Test doubles explained through dummy, stub, spy, mock and fake objects, with practical examples showing when stubs, mocks and fakes are appropriate.
Unit Test Best Practices - FIRST properties
FIRST properties explained through fast, independent, repeatable, self-validating and timely unit tests, with practical guidance for keeping a test suite healthy.
Async and await in C# - common mistakes
Async and await explained for web applications, including I/O-bound work, async void, blocking calls, deadlocks, ConfigureAwait, fake async, and sequential awaits.
How to do TDD (Test-Driven Development)?
Test-Driven Development explained through the Red-Green-Refactor cycle and a step-by-step fund-universe example built with tests first for practical development and design.
Exception handling best practices in .NET
Exception handling practices for .NET, ASP.NET MVC, and Web API covering swallowed exceptions, stack traces, specific catches, and global error handling.
Code review checklist for .NET teams
A practical .NET code review checklist covering design, readability, correctness, errors, security, performance, testing, operations, and constructive review comments and discussion.
How to write unit tests with NUnit and Moq?
Unit testing with NUnit and Moq explained through FIRST properties, the AAA pattern, test doubles, test cases, exceptions, and verification of interactions.
What is a God object and how to break it?
God objects explained through their warning signs, causes, and a step-by-step refactoring approach using characterization tests, extraction, interfaces, and dependency injection.
Why we must not use magic numbers and hard-coding?
Magic numbers and hard-coded values explained with their maintenance and security risks, plus practical replacements using constants, enums, configuration, and read-only values.
How to use Dependency Injection with an IoC container in ASP.NET MVC?
Dependency Injection and IoC containers explained through Unity and Autofac setup in ASP.NET MVC 5, including object lifetimes and practical container wiring.
SOLID Principles - Part 2
The remaining SOLID principles, Liskov Substitution, Interface Segregation and Dependency Inversion, explained with practical examples from a fund domain and practical guidance.
SOLID Principles - Part 1
The first two SOLID principles, Single Responsibility and Open/Closed, explained with fund report and fee calculation examples in C#, plus when not to apply them.
Why we need Clean Code?
Why clean code matters, what makes code clean (meaningful names, small functions, guard clauses, comments that explain why) and how to bring the practice into your team.
How to test the application and keep it clean? - Part 12
This article shows how to unit test services, controllers, routes, helpers and the Web API with fakes, write integration tests with a rolled back transaction, and review SOLID in the application.
How to build a Web API with ASP.NET MVC 4? - Part 11
This article builds an ASP.NET Web API for students on the same service, with routing, status codes, content negotiation, validation, dependency injection and a jQuery client.
How to add registration, login, forgot password, change password, profile and logout? - Part 10
This article adds registration, login, logout, forgot password, change password and a profile page, with salted password hashes, account lock, one-time reset tokens and a testable design.
How to use filters, model binding and validation? - Part 9
This article explains action filters and the filter pipeline, model binding sources and validation with data annotations and a custom validation attribute in ASP.NET MVC 4.
How to build the views with layouts, partial views and HTML helpers? - Part 8
This article explains layouts, sections, partial views, child actions, display templates, built-in HTML helpers and custom helpers written with TagBuilder and the Razor helper.
How to remove the repeated code with a base controller, base service and base repository? - Part 7
This article removes repeated code with a base controller, base service and base repository that handle exceptions, common responses, logs and traces using lambda expressions.
How to build CRUD with Razor views and dependency injection? - Part 6
This article builds the student list, create, edit, details and delete screens with a service layer, view models, validation, Post-Redirect-Get and dependency injection with Unity.
How lambda expressions, extension methods, delegates and events reduce the code? - Part 5
This article explains delegates, lambda expressions, extension methods and events in C#, and uses them for paging, filtering and enrollment notifications in the student application.
How to model the data with Entity Framework and LINQ? - Part 4
This article models students, courses and enrollments with Entity Framework 5 Code First and queries them with LINQ, explaining deferred execution and the path from LINQ to SQL.
How does routing work, with custom, nested and area routes? - Part 3
This article explains ASP.NET MVC routing with constraints, custom route constraints, nested routes, URL generation and areas, with screens and the real route table.
How does an ASP.NET MVC request work from .NET 4.0 to 4.5? - Part 2
This article follows one ASP.NET MVC request from routing to the Razor view, and explains what changes between .NET 4.0 and 4.5, mainly the async actions.
How to structure an ASP.NET MVC application? - Part 1
This article defines the Student Management System, explains the MVC pattern and shows how to split an ASP.NET MVC 4 solution into layers where the dependencies point towards the domain.
How to use Dependency Inversion to loosen the coupling? - Part 5
Dependency Inversion is explained with layered and multi-implementation examples, dependency injection, IoC containers, testing benefits and a summary of all the principles.
What are the Liskov Substitution and Interface Segregation principles? - Part 4
Liskov Substitution and Interface Segregation are explained with open-ended funds and fixed maturity plans, including the warning signs of a broken hierarchy and how to fix it.
What are the Single Responsibility and Open Closed principles? - Part 3
The Single Responsibility and Open Closed principles are explained with a mutual fund service and exit load rules, with the benefits, techniques and trade-offs of each.
How to keep the code simple and the objects in charge? - Part 2
KISS, DRY and YAGNI keep the code simple, while Tell Don't Ask and the Law of Demeter keep the logic near the data, explained with mutual fund redemption and NAV examples.
Why does code become hard to maintain? - Part 1
Code becomes hard to maintain when one change breaks unrelated things, so this article explains cohesion, coupling and the four pillars of object oriented design with a mutual fund example.