Improve perceived performance of ASP.NET MVC websites with asynchronous partial views

github_icon

[Note: The code for this project is available on GitHub.]

Imagine you’re building an ASP.NET MVC website which has some performance problems. I’m sure this would never actually happen to you, but imagine you’re facing this problem just for the sake of exploring the possibilities. :-)

Now, your web app is mostly fast and responsive, but there are certain types of data that just bring the whole thing to a grind. This article will cover a technique using ASP.NET MVC partial views, along with just a sprinkle of jQuery, JavaScript, and HTML5 to make your site feel nice and responsive even if you cannot increase the speed of certain operations. Continue reading

Preventing JavaScript Files from Loading Multiple Times

This post is about ensuring that you do not execute a particular JavaScript file more than one time. Let’s start by asking:

What happens if you link to a js file twice in your page?

Here is a contrived example.

Notice that we are including bad-example.js twice. Do modern browsers somehow realize they loaded this file already and skip this? Not yet, as we’ll see!

Imagine bad-example.js had this code in it. Continue reading

No, You Don’t Need A Windows App

[This project is available on GitHub.]

Do you think you need a Window’s app for your next project? Here’s a thought: No you don’t.

Let me give you one less reason choose the rocky-road of desktop apps today. You’ll hear people tell you that if you build applications for business users (so-called LOB apps) that are input heavy or have complex navigation, your only choice is to build a Windows application.

Why? Because your power users will want hot-keys. They don’t want to use the mouse and navigation and all that stuff that makes the web less usable. They’ll just want to hit a few keystrokes and jump from place to place and do that quick look-up or data entry.

If you haven’t looked carefully around the web lately, here’s a revelation:

Real web apps have hot-keys too.

Continue reading

9 Ways Your Brand New ASP.NET MVC Project Can Be Better

So you’re ready to start that new and ambitious ASP.NET MVC project. Maybe you’re kicking off a new startup or just finally moving that old-and-crusty webforms project into modern development world. Either way, here are a few very simple things you can do immediately after creating that new MVC project that you will thank yourself for as your project grows in complexity.

1. First of all, even MVC 3 has old-and-crusty aspects lurking in its projects. There are old MicrosoftMvc*.js AJAX and validation libraries that have be replaced with new jQuery hotness. These *.js files aren’t used so just delete them.

2. Many of the dependencies of your MVC project are out-of-date as soon as you create your project. You have an old version of jQuery, Entity Framework, etc. Luckily Phil Haack and crew had the brilliant insight to link these to NuGet. So the next thing you do is just run NuGet and choose the Updates tab.

Continue reading

Managing Cumbersome Shared Views Folder for Large Projects in MVC

While ASP.NET MVC promotes clean separation-of-concerns for your web applications, there are some short comings. A problem you’ll run into on large ASP.NET MVC projects is the Views section of your web application becomes completely crowded with hundreds or thousands of files.

Usually, these view files are organized into sections by controller which keeps this manageable. For example, your solution might look like:
Continue reading

Building a Cloud OS for .NET Developers – Part 2

In Part 1 of my Building a Cloud OS for .NET Developers series, I talked about setting up a pure cloud OS focused on developers. But the one crucial aspect I left out was the developer tools.

In this second installment, we’ll be covering exactly that. How do we manage having Visual Studio and associated tools and servers universally accessible in the cloud, even on mobile devices such as iPads?

Continue reading

Building a Cloud OS for .NET Developers – Part 1

Let’s talk about cloud operating systems. This article explores the options and potential of moving entirely “To The Cloud” for developers who normally demand significant offline power from their applications (IDEs, compilers, debuggers, etc). We’ll focus on .NET / Visual Studio developers, but I’m sure you can adapt this to your technology of choice.

I’ve been fascinated with what Google is doing with Chrome OS. I think finding a way to fully “live in the cloud” has a lot of promise. However, in practice Chrome OS is entirely unappealing to me. It’s just a single browser window, maximized. Yuck. I don’t mind doing most things in the browser, but I’d like multiple non-maximized browser windows and a desktop to organize things like shortcuts. That’s OK though because Chromebooks aren’t the only option. We have decent operating systems right now that can function largely in the same way if we set them up with discipline.

Continue reading

11 Killer Open Source Projects I Found with NuGet

So maybe I’m late to the party, but I recently started playing with NuGet. It’s a killer new way to find, install, maintain, and manage references to open source libraries in Visual Studio 2010. Plenty of people have written about it (Phil Haack and  Scott Hanselman for example). Let’s just say you should learn about NuGet if you don’t know it already.

What I want to talk about is all the cool open source projects I found just by flipping through the pages of the NuGet directory in the Visual Studio “Add Library Package Reference” dialog.

Continue reading

MongoDB vs. SQL Server 2008 Performance Showdown

This article is a follow up one I wrote last week entitled “The NoSQL Movement, LINQ, and MongoDB – Oh My!”. In that article I introduced the NoSQL movement, MongoDB, and showed you how to program against it in .NET using LINQ and NoRM. You can also watch my conference presentation at MongoDB Seattle 2011 or this DevelopMentor webcast.

I highlighted two cornerstone reasons why you might ditch your SQL Server for the NoSQL world of MongoDB. Those were

1. Ease-of-use and deployment
2. Performance

For ease-of-use, you’ll want to read the original article.

This article is about the performance argument for MongoDB over SQL Server (or MySql or Oracle). In the first article, I threw out a potentially controversial graph showing MongoDB performing 100 *times* better than SQL Server for inserts.

“A potentially controversial graph showing MongoDB performing 100 times better than SQL Server”

We’ll see source code, downloadable and executable examples and you can verify all of this for yourselves. But first, here’s a new twist on an old proverb:

“Data is money”

Continue reading

Article: Building a Twitter Application in .NET

I recently wrote an article for DevelopMentor‘s Developments newsletter entitled Building a Twitter Application in .NET. You can read it at the DevelopMentor website:

http://www.develop.com/twitternetapps

I’ve republished here for my readers. Enjoy!


Building a Twitter Application in .NET

by Michael Kennedy (@mkennedy)
http://www.michaelckennedy.net

Twitter has become one of the web’s hottest properties. It is a central part of mainstream news programs such as CNN’s Anderson Cooper 360, congressional debates, and talk shows. In fact, it grew at a rate of 1400% this past year [bit.ly/jG9BG].

If your company wants to interact with your customers in a modern and engaging experience, you need to be on Twitter. In fact, if you have customers that really like or dislike you, they are probably talking about you on Twitter. You should be part of that conversation.

In this article, we will explore how to build a rich interactive experience on Twitter that goes beyond just creating a new Twitter account. We will build a .NET application that uses the Twitter API (a free service) alongside other cool technologies such as the WCF REST Starter Kit [http://bit.ly/v8mBb] and LINQ to fully leverage the Twitter experience.

Continue reading

Article: Avoiding 5 Common Pitfalls in Unit Testing

Llewellyn Falco and I recently wrote an article for DevelopMentor’s Developments newsletter entitled Avoiding 5 Common Pitfalls in Unit Testing.

You can read it at the DevelopMentor website:

http://www.develop.com/testingpitfalls

I’ve republished here for my readers. Enjoy!

[Update: We have also done a webcast demonstrating some of these ideas, which we wrote up here:

http://www.michaelckennedy.net/blog/2009/10/28/TDDInvadesSpaceInvaders.aspx]


Avoiding 5 Common Pitfalls in Unit Testing

by Llewellyn Falco and Michael Kennedy

When I started out with unit tests, I was enthralled with the promise of ease and security that they would bring to my projects. In practice, however, the theory of sustainable software through unit tests started to break down. This difficulty continued to build up, until I finally threw my head back in anger and declared that

“Unit Tests have become more trouble than they are worth.”

So we stopped. Not all once, but over the months our unit tests died a quiet death. When tests would stop working, we just ignored them. When new features were reported, they were developed without unit testing. At first, it seemed great. We were able to move without the baggage of maintaining the old tests! But soon all the original problems of having a system without tests came back to us. Things keep breaking, deadlines were increasingly pushed back. Releases came with an extraordinary amount of stress, late nights & weekends. The final straw came when we were forced to rush out an immediate update, and ended up taking down the company for 2 days straight. Our new motto became:

“Unit Testing: you’re damned if you do, you’re damned if you don’t.”

In the end, we decided that despite the hardship caused by maintaining unit tests, it just wasn’t feasible to operate without them. So we started down the road to re-incorporate testing into our software development process. As the months went by, however, we discovered that the hardships we remembered had not returned. Looking back, we realized that we had made many mistakes the first time around. The second time around we were smarter. So you, too, can enjoy the benefits of unit tests here are the 5 major pitfalls we encountered the first time around, and how you can avoid them.

Continue reading

Significant Advances in Unit Testing Windows Workflow

This post describes a unit testing library for testing Windows Workflow Foundations.It is not a framework like HarnessItNUnit, or MsTest. Rather it’s a library that can be used in conjunction with any of these testing frameworks.

Download the library with sample test project here:
Kennedy.WorkflowTesting.zip
(216 KB)

You can also just jump to the code.

First a Little History:

Last September I posted this teaser entitled Unit Testing Coming to a Workflow Near You. My intention was to post this article that you’re reading now shortly thereafter when I got some free time to polish things up. In that previous post, I highlighted what I could determine to be the current state-of-the-art with regard to unit testing workflows, circa September 2008.
Continue reading

MSDN Magainze: Web Apps That Support Long-Running Operations

I’m pleased to announce that MSDN Magazine just published my Windows Workflow article entitled

“ASP.NET WORKFLOW: Web Apps That Support Long-Running Operations”

I hope you find it useful and interesting.

Unit Testing Coming to a Workflow Near You

[Update: See the follow up post "Significant Advances in Unit Testing Windows Workflow"]

If you’ve been working with Windows Workflow, you’ll find it has some cool features for orchestration, long running operations, state machines, etc.

However you won’t find very much support for Test Driven Development (TDD) or unit testing in general. In fact the architecture that makes Windows Workflow powerful (strict separation of workflow, activities, and the host for example) really gets in the way of unit tests.

There has been some work done on unit testing Windows Workflows. Here’s some links:

 

These are all very creative solutions. But, personally I find all of them more complex than they need to be. So in the near future I’ll be putting together some libraries and samples on unit testing Windows Workflow. I think you’ll find them far more powerful and at the same time simpler than anything out there.

So until I get that finished, if you have any feedback or considerations on unit testing Windows Workflow I’d love to hear it. If there are other articles I’m missing, please post them in the comments.

I think you’re going to like this…