Installing MongoDB on Windows and OS X

Ready to get started with NoSQL and MongoDB? Here are two 7-minute walkthroughs for installing MongoDB as a Windows service / OS X daemon.

These are both excerpts from my upcoming online MongoDB course for DevelopMentor. You can take the first 1 1/2 hours for free here:

Early access: MongoDB and NoSQL for .NET developers

Windows:

OS X:

Feedback welcome.

cheers
@mkennedy

A Roundup of MongoDB Management Tools

I’ve been working with MongoDB for a long time now. Back in the early days, there really were no management tools analogous to RDBMS tools (e.g. SQL Server Management Studio). Since then, things have changed significantly. It’s time to look around and see what management / monitoring tooling is around these days for MongoDB.

The news is good. There are many different options to choose depending on your platform and use-cases.

1. Robomongo, price: $0 / open-source, platforms: Windows, OS X, Linux
http://robomongo.org/

Robomongo — is a shell-centric cross-platform open source MongoDB management tool (i.e. Admin GUI). Robomongo embeds the same JavaScript engine that powers MongoDB’s mongo shell. Everything you can write in mongo shell — you can write in Robomongo!

Robomongo

Key features: Continue reading

Optimistic concurrency in MongoDB using .NET and C#

[Update: Available via NuGet - MongoDB.Kennedy.Concurrency]

This article demonstrates a technique and supporting library for adding optimistic concurrency control to NoSQL databases and MongoDB in particular.

Watch a video walk-through using this library:

Quickly, what is optimistic concurrency control?

Ideally, all databases that allow concurrent access or disconnected access need to implement some form of concurrency control. This usually comes in two flavors:

  1. Pessimistic concurrency control
  2. Optimistic concurrency control

Pessimistic concurrency control is usually used when working heavily within transactions. That may be fine for bank transfers, but it typically falls down in the face of disconnected models used by almost all ORMs such as Entity Framework. Moreover, it is entirely inappropriate for NoSQL databases.

Frameworks such as Entity Framework have optimistic concurrency control built in (although it may be turned off). It’s instructive to quickly see how it works. Basically there are three steps:

  1. Get an entity from the DB and disconnect.
  2. Edit in memory.
  3. Update the db with changes using a special update clause. Something like: “Update this row WHERE the current values are same as original values”.

If that update returns “0 rows modified” then we know it was changed since we loaded it and are about to overwrite someone’s changes. This results in a concurrency exception and not changes go through.

Optimistic concurrency control for MongoDB

By carefully constructing update commands in C# with the official 10gen C# driver, we can achieve almost exactly the same flow. At the end of this article is a simple C# class (data context) which has save and delete methods which internally are safe via optimistic concurrency control. Continue reading

Announcing LearningLine: Instructor-led online training from DevelopMentor

I am very proud to announce an exciting new online learning platform from DevelopMentor:


http://www.learninglineapp.com

At DevelopMentor we have been thinking deeply about online training. We wanted to create an environment that combines the best parts of online learning and classroom training, the best parts of self-directed exploration and expert-led mentoring. We believe we have created just such an environment and I am thrilled to publicly announce it today.

Here’s a short 2-minute video which will give you a quick overview. You can get more details at http://www.learninglineapp.com.

Online training today

There are many shortcomings in how developers learn online today. Continue reading

3 Open-Source Validation Projects for ASP.NET MVC

The goal of this post is to show you validation options beyond those that come in-the-box from Microsoft and the ASP.NET team.

Currently, there are nine pre-built validation attributes that come with MVC:

hierarchy

While these are very helpful, knowing where to look to find additional validation options is super helpful. For example, what if the State property is only supposed to be required if Country property is set to USA? Good luck with that one! Continue reading

Use NuGet package restore to simplify code sharing

Here’s a quick post on how and why you want to consider using NuGet package restore.

First, if you’re unfamiliar with NuGet, it’s basically “add reference” to external software projects (typically open source ones such as jQuery, but also for Microsoft ones such as Entity Framework). You definitely need to check out David Ebbo’s post introducing it. NuGet will change the way you develop.

Now when using NuGet it maintains a packages folder near your solution file. For things like ASP.NET MVC that heavily leverage NuGet, you’ll see this folder is very large. It’s usually much larger than your project itself in the beginning.

If you write small projects and share them out as compressed files (e.g. zip’s), and size matters to you, you might want to consider enabling NuGet package restore (off by default) for those projects and delete the packages folder before zipping and sending it out.

As an example, with a typical MVC 4 project, the “raw” content is 680 KB. After doing a build and counting the packages folder you’ll see it jumps to 16.9 MB. If that helps you significantly, then it’s probably a good idea to use package restore.

Three things have to happen to use NuGet package restore. Continue reading

Download My Web Apps Have HotKeys Too Sample App

I recently blogged about how web apps have hotkeys too. To encourage more developers to add hotkeys to their web applications, I created a jQuery plugin called jQuery.hotKeyMap.js and a sample application.

I just added a download link for the source code:

WebAppsHaveHotKeysTooSample-MichaelKennedy-v1.zip

It’s an ASP.NET MVC 3 web app. Hope you find it useful!

Cheers,
@mkennedy

Add Hot Keys to Web Apps With jQuery.hotKeyMap.js

Hot keys (or accelerator keys) have been an important navigational tool for desktop applications for many years. Finally, web applications are adopting this functionality too. Check out this simple example of a web app with hotkeys.

Expect a more general blog post on the topic soon. For now, I’d like to share my jQuery plugin that enables this capability with you.

Announcing jQuery.hotKeyMap.js: A jQuery plugin that allows you to add complex hot-key functionality and navigation to your web apps with very little effort.

Continue reading

Speaking on NoSQL and MVC at the South Sound .NET User Group (Near Seattle, WA)

Update: Thanks to everyone who came. You can download the sample application we build here and slides below:

   Kennedy-Demo-Amazoon-Sound-Sound-Usergroup.zip

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

Portland CodeCamp Downloads: Demos and Slides

Thanks to everyone who came to my two sessions at the Portland CodeCamp this weekend.

The NoSQL Movement, LINQ, and MongoDB – Oh My!

Panel Discussion: NoSQL vs. RDBMS

You can download the slides, demo code, and the mongoctx code snippet for Visual Studio here:

NoSQL + MongoDB + LINQ:
http://www.michaelckennedy.com/Talks/Downloads/PortlandCodeCamp/Kennedy-PdxCodeCamp-2010-MongoDB-NoRM-LINQ.zip

NoSQL vs. RDBMS Panel:
http://www.michaelckennedy.com/Talks/Downloads/PortlandCodeCamp/Kennedy-PdxCodeCamp-2010-NoSQL-vs-RDBMS-Panel.zip

If you missed the sessions and want to see some MongoDB + LINQ or if you would like to recommend this session to a friend, I’ll be doing a webcast on a very similar talk tomorrow:

NoSQL + MongoDB + LINQ Webcast

Cheers!
@mkennedy

Webcast: NoSQL Movement, LINQ, and MongoDB

[Update: This webcast is in the past, but you can download the video and audio recordings.]

Download Video (WMV)
Download Audio (MP3)

I’m happy to announce I’ll be doing a free webcast in the DevelopMentor webcast series on MongoDB, .NET, LINQ, and NoRM.

NoSQL Movement, LINQ, and MongoDB 
Tuesday May 25th – 11AM PST
Register here

I hope to see you there. We’ll be building out a website in ASP.NET MVC with MongoDB as the back-end using LINQ. There will be plenty of code so it should be fun and educational.

Cheers!
@mkennedy

The NoSQL Movement, LINQ, and MongoDB – Oh My!


Maybe you’ve heard people talking about ditching their SQL Servers and other RDBMS entirely. There is a movement out in the software development world called the “NoSQL” movement and it’s taking the web application world by storm.

“Insanity!” you may cry, “for where will people put their data if not in a database? Flat files? Tell me we aren’t going back to flat files.”

No, but in the relational model, something does has to give. The NoSQL movement is about re-evaluating the constraints and scalability of data storage systems in the light of the way modern web applications generate and consume data.

The outcry about flat files above is meant to highlight an assumption developers often have about building data-driven applications: Data goes in the database (SQL Server, Oracle, or MySql). Just maybe, if we are really cutting-edge, we might consider storing our data in the cloud, but the choices generally stop there.

The NoSQL movement asks the question:

“Is the relational database (RDBMS) always the right tool for data storage and data access?”

Continue reading

Attend My Live, Free TDD Webinar with Llewellyn Falco and Myself at 10am Tomorrow!

[Update: See the follow-up post here: TDD Invades Space Invaders]

Tuesday, October 27, 2009 at 10am Pacific time Llewellyn Falco and I will be giving a live, unscripted, and no safety-net demonstration of Test Driven Development (TDD) as part of the DevelopMentor webinar series (this particular series is a 3-part series on Agile development).

We already have a bunch of attendees registered. But we have room for as many of you who are interested in agile and TDD. Sign up here:

http://bit.ly/dm-tdd-m-and-l

In addition to core TDD techniques, you will see how an amazing technique and set of tools designed by Llewellyn called Approval Tests makes writing tests as simple as verifying an image or text file. Tired of writing 50 lines of test code for every 50 lines of production code but you still want the power of TDD? You need to learn more about Approvals and we’ll demo that live tomorrow!

I hope to see you all online. Feel free to help me get the word out by tweeting this or shouting it (see icons below).

Cheers, Michael.

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