Practical .NET


Best Practices for Lazy Loading in Entity Framework

Sometimes you want child objects retrieved with the parent object, and sometimes you don't. What you NEVER want is to retrieve child objects accidentally. Here's Peter's advice on how to get the best performance when loading child objects.

Setting the Order of Your Script Files

Script bundling speeds up your application by reducing the time it takes to download all of your JavaScript code. But you'll need another object to get your files added to the page in the order you want.

Organize Your Tests to Reduce Overhead

In test-driven development, you have to decide how you'll divide your test methods between your test classes. The best solution is the one that requires the least effort on your part and implements the Single Responsibility Principle for tests.

Defining Columns, Primary, and Composite Keys in Entity Framework

There are two attributes you can put on your entity class properties: one is a convenience, the other is essential, and both are required when the primary key for a table consists of two columns.

SpecFlow Two-Step Parameter Conversions

Here's how to use SpecFlow to convert plain-text scenario steps into .NET types.

Creating HTML Helpers You Can Use in Any ASP.NET View

An HTML Helper is a bit of Razor code that can be called from multiple places in a View. But, if you put your Helper in the right place, you can also use it from any View in your application.

The Reality of Getting Started with Test-Driven Development

Moving to TDD with ASP.NET is not, in fact, as easy as everyone tells you it is. But it's not as much work as you might think, either. Here's what you need to do to start doing TDD in the real world with an existing ASP.NET MVC application.

Nesting Layouts in ASP.NET MVC

If you've got a site that contains subsites and want to visually distinguish between those subsites (while still maintaining your site's visual integrity), consider nesting layouts within layouts.

Use Constants and Enums to Improve Readability (and Reduce Maintenance)

If you're not using Const and Enums then you're just making life harder for the next programmer.

3 Ways to Manage Dependent Classes in the .NET Framework

Once you start implementing current design practices, you'll find that your typical object consists of a lot of other objects.

Best Practices for Loosely Coupled Classes

In an object-oriented world you create flexible applications by combining objects. You'll want to keep those objects loosely coupled, though, so that a change in one class doesn't force you to rewrite every class. Here's how to keep them loosely coupled.

Leverage Lambda Expressions in Your Methods

Integrating lambda expressions into your methods is easy. The trick is in recognizing when to use them. And that means understanding when the strategy and factory method patterns are going to make your applications better.

Do You Know the Answers to These Hanselman Questions?

Back when he had a job, Peter used to hire developers. When he did, there were three questions he got from Scott Hanselman's blog, way back at the beginning of the .NET Framework that he's still asking today.

It's Not the Names that Matter

As you work with other developers (and seek advice from experts) you need to make sure you're discussing what matters rather than arguing about terminology.

With ASP.NET MVC and Data Transfer Objects, The Bigger the Better

Create the best object for moving data from your Controller to your View.

Subscribe on YouTube