]]>http://blog.michaelckennedy.net/2015/03/19/python-cheat-sheet/feed/0mkennedy66996693python-cheetshet-download-imageAnnouncing the 2015 MongoDB Mastershttp://blog.michaelckennedy.net/2015/03/10/announcing-the-2015-mongodb-masters/
http://blog.michaelckennedy.net/2015/03/10/announcing-the-2015-mongodb-masters/#commentsTue, 10 Mar 2015 15:50:04 +0000http://blog.michaelckennedy.net/?p=1479]]>NEW YORK, NY and PALO ALTO, CA – March 10, 2015 – MongoDB today announced the 2015 members of the MongoDB Masters, an annual program run by MongoDB to recognize and empower leaders in the MongoDB community. Comprised of core contributors and community evangelists, the MongoDB Masters are dedicated to sharing their passion and technical expertise with the MongoDB community around the world and play a vital role in the adoption, education and advancement of MongoDB.

]]>http://blog.michaelckennedy.net/2015/03/10/announcing-the-2015-mongodb-masters/feed/045.523062 -122.67648245.523062-122.676482MongoDB Logomkennedy66996693Initialization in Modern C++ vs Apple’s Swifthttp://blog.michaelckennedy.net/2015/03/09/initialization-in-modern-c-vs-apples-swift/
http://blog.michaelckennedy.net/2015/03/09/initialization-in-modern-c-vs-apples-swift/#commentsMon, 09 Mar 2015 17:10:17 +0000http://blog.michaelckennedy.net/?p=1474]]>Time for another great guest blog post from Bradley Needham to follow up on his very popular Swift vs. C++ post. Enjoy!

Initialization in Modern C++ vs Apple’s Swift

A little while ago I wrote a short post comparing some of the basic features of Modern C++ and Apple’s Swift. It was far from comprehensive, basically only touching on the constructs mentioned in Michael Kennedy’s post Comparison of Python and Apple’s Swift Programming Language Syntax. However the post did generate enough interest that I decided to continue the comparison by looking at one of the differences I find interesting between the two languages, initialization. Initialization is very important in any language and both C++ and Swift have built in constructs and checks to help make sure that objects get completely initialized before they are used.

Initialization syntax

Let us start with the syntax of the two languages.

Objects are initialized in C++ through constructors. A constructor has no return value and the same name as the class.

// C++
class Person {
public:
Person() {} // Constructor
};

In Swift objects are initialized through initializers. An initializer has no return value and its name is init.

// Swift
public class Person {
public init() {} // Initializer
}

Invoking a constructor or an initializer is similar.Note: I am only pointing out the syntax here, how the objects are being allocated is different.

// C++
Person p;
// or
auto p = Person();

// Swift
var p = Person()

Constructors and initializers can be used to set initial values for fields.

The constructor for Person will be executed first. It will initialize _age and execute any code in the constructor body. Then _id will be initialized and finally the the code in the Student constructor will be executed.

This is straight forward single-phase construction that works well in C++.

In Swift initialization is done in two-phases.

Two-phase initialization takes a different approach. Instead of completely initializing the base class protion of the object, i.e. initializing the data as well as executing the initialization code, before initializing the sub class protion, it separates the initialization of the data from the initialization code.

The first phase, initializes the data starting with the sub class fields and working its way up to the base class fields. The compilier will enforce this so that you cannot call super.init before all sub class fields have an initialized value and you will not be able to invoke any methods on the sub class until super.init finishes. The second phase then executes code that can now safely access any fields because they are guarenteed to be initialized.

First the field _id would be initialized, then super.init would be called, then _age would be initialized. This would complete the first-phase and the second-phase would then execute any initialization code.

Swift uses two-phase initialization to prevent code from accessing the memory of an object before it has been initialized which might happen if you were to call a method (which is dynamically bound by default) from a base class initializer.

Because _id is initialized before super.init is invoked the following code:

var s = Student(age: 25, id: 1001)

Prints out:

age: 25
id: 1001

In C++ dynamic binding is not fully set up until construction is complete so the above example in C++ would result in the print function on Person being called instead of the print function on Student.

In C++ _id is not initialized before Person’s constructor is invoked but the v-table used for dynamic binding is also not fully set up so Person::print gets called and the following code:

auto s = Student(25, 1001);

Prints out:

age: 25

Note: In Java _id would not be initialized and print would be dynamically bound allowing the access of uninitialized memory.

Two-phase initialization can be implemented in C++ and there are many discussions on the pros and cons of its use. This post is not concerned with addressing those. The intention of this post is to simply point out the difference between C++’s build in initialization mechanism and Swift’s.

This course is specifically build to help teams of existing Objective-C developers quickly but thoroughly get up to speed with Swift. Here are details on the course, read more at DevelopMentor.

This course is a thorough introduction to the Swift language. If you have experience with Objective-C and Apple’s developers tools and APIs and you want you and your team to quickly get up to speed on Apple’s successor to Objective-C, then this hands-on course is the perfect one for you. The time to move to Swift is right now and this is the course to get you there.

New to Apple’s developer tools? We may have a better course for you. If you need a more rounded introduction including iOS and OS X SDKs (e.g. Cocoa Touch) and tooling (e.g. Xcode and storyboards), check out our Essential Swift iOS and OS X Programming which covers language and application topics.

When Apple announced the Swift programming language to cheering crowds at WWDC 2014, we knew it would be important. Swift is destined to replace the aging Objective-C language which was introduced over 32 years ago. Swift is built upon three core principles: safe, modern, and powerful. It fulfills these principles by borrowing the best features from modern languages such as Python, C#, modern C++, and others. While Swift adopts modern high-level language features it also improves upon Objective-C’s native performance and is actually faster than its predecessor.

While there are cross-platform options for building iOS and OS X applications, if you are ready to go all in on the Apple ecosystem you need to learn Swift today. This language fundamentals course is a great place to start.

Course outline and topics

Day 1

Introduction to Swift for iOS and OS X

This first module introduces developers to the Swift ecosystem. You will learn why Swift was created and understand how it fits into the Apple developer ecosystem. You will learn about the various tools and SDKs needed to start building applications.

Language Basics

Swift is a modern language which borrows many of the best features from successful, established languages of the day such as Python and C#. Swift values readability and productivity over terseness. In this lesson, you will get a quick introduction to the major language features. We will see how to define variables and understand Swift’s variable scope. Next up is a variety of flow control constructs (if, while, etc.). We will pay special attention to loops in Swift, which has traditional for and while loops but also adds rich iteration and range based loop constructs. Finally we discuss how to import external libraries to extend our capabilities.

Optionals and Optional Chaining

The Swift language adds two clean and powerful features to the developer’s toolkit: optional chaining and generics. Unlike most languages, Swift types cannot be null / nil. Even though Swift has both value types and reference types, they must have a value. To specifically allow for missing values, Swift introduces optionals and optional chaining to work with these types. Using optional chaining you can entirely avoid those one-line if statements required to juggle null / nil optionals and reference types. We will also cover generics, a powerful feature to use strong-typed features in a general way.

Common Types

Swift has a rich type system. This lesson explores some of the fundamental types and tips for working with them (numbers, strings, dates, etc.). You will see how to convert between types and parse text into common types (e.g. dates). You’ll learn about the most used operations on these types so you can jump right into using them in your applications.

Day 2

Collections

Swift has a rich collection system. This lesson explores Swift’s collection classes (arrays, dictionaries, and tuples). These types have very powerful features and only some of them are covered in this lesson (saving the best for deeper examination later). You will learn to splice (via subscript ranges), combine, and generally manipulate these collections here.

Functions and Closures

Functions, along with classes, are key building blocks of any self-respecting language. Swift’s support for functions is very sophisticated. We start by defining basic functions and discussing parameters, return values, and related concepts. Unlike many languages, you will see that Swift functions naturally support returning multiple return values and assigning them all in one step. You will see how to define functions with varying numbers of parameters, how to create named parameters, and work with default and optional parameters. Finally we look at some of the best features of functions enabling modern, concise programming techniques: closures, expressions, and lambdas in Swift.

Classes

Swift is a first class object-oriented language. You will see how to define your own classes and how to add methods and fields to them. We will cover how to hook into object lifetime and initialization.

Structures and Enumerations

Classes are not the only way to define your own custom types in Swift. Structures allow many of the same features and functionality as classes but as a value type rather than reference type. Structures are key to high performance code in certain situations. You will also learn about enumerations which again share many features with classes and structures but they model situations where the set of data is a finite set (e.g. days of the week). You will also learn when you should use classes, when to use structures, and when to use enums.

Day 3

Protocols and Extensions

Next up are two powerful features for extending, adapting, and reusing types. We will begin by learning about protocols. If you are coming from another language, you may know these as interfaces. Protocols allow your types (classes, structs, and enums) to guarantee they support a minimum level of functionality and allow for greater type reuse and polymorphism. Protocols work great when extending types you control. But Swift has another feature which allows you to add functionality and features to existing types even types imported from other libraries like the String class. These are extensions and they are a powerful feature not found in many other languages.

Generics

The Swift language is strongly-typed. While strong typing is usually an advantage it can also get in your way. This module will show you how to reuse algorithms in Swift irrespective of their types. This is done via generics, a powerful feature to use strong-typed features in a general way. You will see how to define custom generic types, factor elements of the type into your algorithms and restrict the types can be applied via type constraints and where clauses.

Memory management

In this module, you will learn the ins-and-outs of memory management in Swift. Swift has two broad categories of types (reference types and value types) and you will see they differ dramatically in how memory is managed for these types. You will learn when and how to use each of these and how to identify them. We will see, that for reference types, Swift uses Automatic Reference Counting (ARC) to track and manage your app’s memory usage. In most cases, this means that memory management ‘just works’ in Swift, and you do not need to think about memory management yourself. We will discuss various types of references and see how they affect memory management (strong, weak, and unowned references) references.

I have been teaching a lot of Python at DevelopMentor and most people who are learning Python are coming to it from one of two places. Either they are experienced with another language but not Python or they know Python but only just enough to keep some basic scripts running.

While teaching the in’s and out’s of Python is a key goal, another thing we try to convey is that Python is a serious, full stack, professional, and comprehensive platform. For most projects, I’d gladly put Python up against C# / .NET, Java, and C++.

Mahmoud’s post conveys the same basic idea. The beautiful thing about his post is that he backs this up with solid usage and large enterprise data.

Here are a few key myths dispelled in the post:

False Myths about Python

Python is not compiled

Python is not secure

Python is a scripting language

Python is weakly-typed

Python is slow

Python does not scale

Python is not for big projects

The large scale use of Python is particularly impressive. For example, Mahmoud writes:

Scale (as in performance)

Scale has many definitions, but by any definition, YouTube is a web site at scale. More than 1 billion unique visitors per month, over 100 hours of uploaded video per minute, and going on 20 percent of peak Internet bandwidth, all with Python as a core technology. Dropbox, Disqus, Eventbrite, Reddit, Twilio, Instagram, Yelp, EVE Online, Second Life, and, yes, eBay and PayPal all have Python scaling stories that prove scale is more than just possible: it’s a pattern.

Scale (as in size)

Myth #7 discussed running Python projects at scale, but what about developing Python projects at scale? As mentioned in Myth #9, most Python projects tend not to be people-hungry. while Instagram reached hundreds of millions of hits a day at the time of their billion dollar acquisition, the whole company was still only a group of a dozen or so people. Dropbox in 2011 only had 70 engineers, and other teams were similarly lean. So, can Python scale to large teams?

Bank of America actually has over 5,000 Python developers, with over 10 million lines of Python in one project alone. JP Morgan underwent a similar transformation. YouTube also has engineers in the thousands and lines of code in the millions. Big products and big teams use Python every day, and while it has excellent modularity and packaging characteristics, beyond a certain point much of the general development scaling advice stays the same. Tooling, strong conventions, and code review are what make big projects a manageable reality.

Hopefully this has given you a new perspective on Python. Once again, you really should check out the original article:

When Apple announced the Swift programming language to cheering crowds at WWDC 2014, we knew it would be important. Swift is destined to replace the aging Objective-C language which was introduced over 32 years ago. Swift is built upon three core principles: safe, modern, and powerful. It fulfills these principles by borrowing the best features from modern languages such as Python, C#, modern C++, and others. While Swift adopts modern high-level language features it also improves upon Objective-C’s native performance and is actually faster than its predecessor.

This course is a deep, practical, and hands-on exploration of the Swift language and surrounding ecosystem. You will learn why Swift was introduced. You will see how Swift is a safe, modern, and powerful language. You will learn how to build iOS (iPhone and iPad) applications as well as native OS X applications using Xcode. All of these lessons will be reinforced with hands-on exercises and many example applications built live during class.

There are cross-platform options for building iOS and OS X applications. However, if you are ready to go all in on the Apple ecosystem you need to learn Swift today. This comprehensive course is a great place to start.

If you’re looking for MongoDB training for you or your team, please consider DevelopMentor. We also have my MongoDB for .NET developers course if you live in the .NET camp.

Here’s some more background on this course.

MongoDB for Python Developers

This course is a deep exploration of building applications in MongoDB (the most popular NoSQL document-database). There are many benefits to choosing a NoSQL database over traditional RDMBSs such as SQL Server or Oracle. This course starts out by looking at why you should choose a NoSQL database in the first place. We will explore the native query language and capabilities of MongoDB. Then we will start working with MongoDB from our Python applications and look at several topics that explore the advanced aspects of the MongoDB Python API including MongoDB from Python, PyMongo, ODMs such as MongoEngine, and more. We will see how to leverage the immense scalability of MongoDB using the aggregation framework, replica sets, and sharding. You will discover how to store and manage files of virtually unlimited size in MongoDB using GridFS. We will discuss how to properly design your entities and documents (both natively and in Python) to take full advantage of what MongoDB has to offer. Finally, we will round out the course with a few topics that you will need to be successful with MongoDB including Server administration for developers and Security and permissions.

Note that some of the topics cover in this course are technology agnostic (for example the native query lesson is equality applicable to Python developers as well as .NET or Java developers) and some are specifically optimized for Python developers (for example MongoEngine and ODMs).

Why should you choose DevelopMentor’s MongoDB course? At DevelopMentor we have experience building and running large scale MongoDB deployments including our online learning platform LearningLine and develop.com itself. The course authors work closely with the MongoDB team and are in the MongoDB Masters program. We have been teaching MongoDB in our Python courses and our Guerrilla .NET course for several years. In short, we know what we’re doing with MongoDB and Python and we’d love to share it with you.

When Michael wrote his Python vs Swift article, I found it interesting how similar each of these languages (Python, C#, and Swift) are and thought it might be worth having a similar article comparing Modern C++ and Swift.

Switch statements

Default behavior differs between languages. At the end of a case statement, Swift has an automatic break while C++ falls through to next case.

// Swift
switch (i)
{
case 1:
// do work
case 2:
// do work
default:
// do work
}
// C++
switch (i)
{
case 1:
// do work
break; // must explicity break out of switch
case 2:
// do work
break; // must explicity break out of switch
default:
// do work
break; // must explicity break out of switch
}

fallthrough keyword is used to fall through a case in Swift. In C++, removal of the break causes a fall through

// Swift
switch i
{
case 1:
// do work
case 2:
// do work
fallthrough // must explicity fall through
default:
// do work
}
// C++
switch (i)
{
case 1:
// do work
break; // must explicitly break out of switch
case 2:
// do work
// no break will fall through
default:
// do work
break; // must explicitly break out of switch
}

Swift allows for switching on Strings, C++ does not

// Swift only
switch str
{
case "hello":
// do work
case "goodbye":
// do work
default:
// do work
}

Swift allows for range cases. C++ uses the default fall through to accomplish similar functionality

Conclusion

Most modern 3rd-generation languages have many similarities, it just takes getting use to the small differences in order to be able to code between them. Once you get past the language issues, you can spend your time on the platform API which is the thing that really lets you get your work done.

]]>http://blog.michaelckennedy.net/2014/12/08/comparison-of-modern-c-and-apples-swift-programming-language-syntax/feed/5cpp-vs-swiftmkennedy66996693Python for the .NET Developer on .NET Rockshttp://blog.michaelckennedy.net/2014/12/05/python-for-the-net-developer-on-net-rocks/
http://blog.michaelckennedy.net/2014/12/05/python-for-the-net-developer-on-net-rocks/#commentsFri, 05 Dec 2014 14:49:00 +0000http://blog.michaelckennedy.net/?p=1382]]>[Note: This news is old, I some how missed posting it to my blog. So here it is!]

Back in February, I had the honor of being the guest on the .NET Rocks podcast with Carl Franklin and Richard Campbell. We talked about the similarities between Python and C# and the Python and .NET ecosystems. It was a great show and I think you’ll find it interesting if you are a .NET or Python developer.

]]>http://blog.michaelckennedy.net/2014/12/05/python-for-the-net-developer-on-net-rocks/feed/0dotnetrocks-headermkennedy66996693Better Python Integration in Windows: Shebangs and Version Selectorshttp://blog.michaelckennedy.net/2014/12/04/better-python-integration-in-windows-shebangs-and-version-selectors/
http://blog.michaelckennedy.net/2014/12/04/better-python-integration-in-windows-shebangs-and-version-selectors/#commentsThu, 04 Dec 2014 22:31:53 +0000http://blog.michaelckennedy.net/?p=1363]]>I’ve written several times on efforts to make Python better on Windows. I also have an outstanding request to the Windows 10 team to get Python built directly into Windows 10 (please upvote it!). In this post, I’ll show you some very simple techniques to put Python on Windows relatively on par with Python on OS X and Linux.

On OS X and Linux, we can use a special kind of comment at the top of our script called a shebang.

#!/usr/bin/env python3
# normal python code here...

This tells the OS which Python runtime to select and allows the script to be executed directly. For example, imagine that file was named program.py. Without the shebang, if we type simply ./program.py we likely will get an error. We have to specify which version of Python by running python3 ./program.py. This has several problems. It’s not obvious to users they have to do this to run the script. Moreover, if that program is for Python 2 and we guess to use Python 3 too bad for us! The shebang solves both of these for us… on OS X and Linux.

Shebangs on Windows

If you try this little trick on Windows, you are likely to be disappointed even if you have Python installed. One possibility is to get this lovely experience.

Another possibility is you’ll see a dialog to choose how to run *.py files.

If you pick Python.exe you may get the right outcome. But now all Python scripts are tied to a single Python version (Python 2 or Python 3). What we need is to fix this with something like the shebangs of Linux.

Consider this simple program that states the version of Python executing it.

Notice that if we directly execute it by specifying the Python version to run, it works great.

Nice. But we still have the problem of the user deciding which version of Python to try (not good). Since Python 3.3, they have introduced a program named Python Launcher for Windows. This lovely little program allows us to use shebangs to let the script select its version.

Integer Bounds

Type Inference

Swift is a strongly-typed language which makes heavy use of type-inference although you can declare explicit types. Python is a dynamic language so while there is a type system it is not evident in the syntax.

Switch statements

Swift has them, Python does not.

Functions

Functions are very rich in both languages. They have closures, multiple return values, lambdas, and more. Here is a simple version. Note that this example also leverages tuples and tuple unpacking in both languages.

Conclusion

As you can see, the similarities to Python are striking. I expect with some experience transitioning between the languages will be easy. The major differences actually lie underneath at the standard library vs cocoa base classes. As with most languages, this is where the real mastery of the platform happens.

Ubuntu and OS X include the Python runtimes by default. Please Include the 64-bit version of Python 3 and Python 2 with Windows.

I believe many developers choose OS X and Linux over Windows because these OSes are more open source and CLI friendly. You have done a lot of fix the CLI experience in Windows 10. Please make Python development better on Windows by including it out of the box.

Need more inspiration? Watch this video about the future of Python (hint: it involves Windows)

]]>http://blog.michaelckennedy.net/2014/11/10/shipping-python-with-windows-10/feed/2mkennedy66996693Convert LINQ to MongoDB queries to JavaScript shellhttp://blog.michaelckennedy.net/2014/03/05/convert-linq-to-mongodb-queries-to-javascript-shell/
http://blog.michaelckennedy.net/2014/03/05/convert-linq-to-mongodb-queries-to-javascript-shell/#commentsThu, 06 Mar 2014 01:03:20 +0000http://blog.michaelckennedy.net/?p=1251]]> If you do a lot of work with MongoDB from .NET,
this code should look familiar:

]]>http://blog.michaelckennedy.net/2014/03/05/convert-linq-to-mongodb-queries-to-javascript-shell/feed/20.000000 0.0000000.0000000.000000mkennedy66996693github_iconEver wonder how big the .NET and Python communities are?http://blog.michaelckennedy.net/2014/02/21/ever-wonder-how-big-the-net-and-python-communities-are/
http://blog.michaelckennedy.net/2014/02/21/ever-wonder-how-big-the-net-and-python-communities-are/#commentsFri, 21 Feb 2014 17:13:13 +0000http://blog.michaelckennedy.net/?p=1062]]>Do you ever wonder how big .NET and Python communities are? I’m working on an article about Python and .NET and this comparison definately came to mind. So I did some research on meetup.com.

I chose seven locations:

Chicago, IL

Los Angeles, CA

New York, NY

Seattle, WA

Portland, OR

San Francisco, CA

Silicon Valley, CA

And did a search for meetups on .NET and on Python. Here is a graph of the results:

In my home town of Portland, OR we have 1,146 Python devs. I don’t have any data on .NET, sorry that is missing. But Portland is notable that because we have a larger Python community than LA, Chicago, and Seattle even though all three are much larger than Portland and LA is over 4 times as populous.

Finally, it probably won’t surprise you that Python is more popular in Silicon Valley. But it is kind of shocking to see it 28 *times* more popular.

You can download the spreadsheet I used to make this graph and tweak it with your own data if you wish:

]]>http://blog.michaelckennedy.net/2014/02/21/ever-wonder-how-big-the-net-and-python-communities-are/feed/70.000000 0.0000000.0000000.000000mkennedy66996693Relative size of python and ,net communities via user groups.Much of my blog’s sample apps are now on GitHub and Azurehttp://blog.michaelckennedy.net/2014/02/15/much-of-my-blogs-sample-apps-are-now-on-github-and-azure/
http://blog.michaelckennedy.net/2014/02/15/much-of-my-blogs-sample-apps-are-now-on-github-and-azure/#commentsSat, 15 Feb 2014 22:02:05 +0000http://blog.michaelckennedy.net/?p=1053]]>Here is a quick announcement if you have been downloading or using any of the libraries and sample applications from my blog. The most popular ones are now all on GitHub. This means you’re welcome to come and download or fork them! You can even contribute back if you see something useful that is missing.

If you know of something I’ve published and you’d like it on GitHub, just send me a note!

Finally, the keen reader will notice I’ve moved my sample apps to Windows Azure Websites. I’ve been a vocal critic of Azure at times, but Azure Websites are quite nice. You get up to 10 domains for free. They are worth checking out.

]]>http://blog.michaelckennedy.net/2014/02/15/much-of-my-blogs-sample-apps-are-now-on-github-and-azure/feed/00.000000 0.0000000.0000000.000000mkennedy66996693Python and .NET in Portlandhttp://blog.michaelckennedy.net/2014/01/29/python-and-net-in-portland/
http://blog.michaelckennedy.net/2014/01/29/python-and-net-in-portland/#commentsThu, 30 Jan 2014 01:28:15 +0000http://blog.michaelckennedy.net/?p=1020]]>If you live in Portland, OR and are interested in Python, you might want to drop by my user group talk at PADNUG February 20, 2014. I’ll be speaking on Python for .NET developers and it’s hosted by the Portland Area .NET User Group. Here are the details. The event is free and held downtown at the Microsoft office. Hope to see you there!

Welcome to the PADNUG !West meeting! We’ve had people clamoring for some content on the other side of the hills and there are now people who can help make that happen! This is an experiment, for sure, but one we hope can be a regular feature.

Don’t fear, though, we’re not eliminating our westside meetings. We will continue to meet at our (mostly) regular time out west. These downtown/east meetings will be added to our regular schedule.

If you love C# and .NET, you may be surprised to see how many of the features you love also exist in Python (often first). Python is a wonderful language. It is a clean high-level language which values readability over many trade-offs. You can build web applications serving billions of monthly page views. You can build cross-platform GUI applications such as DropBox. You can access amazingly powerful database servers such as MongoDB and SQL Server. But did you know many of the things you absolutely love about C# also exist in Python? Lambda expressions – check. foreach loops – check. Rich class library – check. Iterators – check. And there is more. Come learn about all the things you love from C# and see how they are accomplished in Python.

]]>http://blog.michaelckennedy.net/2014/01/29/python-and-net-in-portland/feed/00.000000 0.0000000.0000000.000000mkennedy66996693Special Event: MongoDB in New York from DevelopMentorhttp://blog.michaelckennedy.net/2014/01/14/special-event-mongodb-in-new-york-from-developmentor/
http://blog.michaelckennedy.net/2014/01/14/special-event-mongodb-in-new-york-from-developmentor/#commentsTue, 14 Jan 2014 18:43:32 +0000http://blog.michaelckennedy.net/?p=1013]]>I’m excited to announce that I will be teaching MongoDB for .NET developers from DevelopMentor in New York City at MongoDB Inc.’s headquarters on Times Square. The class is March 11, 2014 to March 13, 2014.

If you are interesting in learning MongoDB or bringing MongoDB and NoSQL to your team, this is the perfect opportunity. Not only is it an amazing class, you will have the opportunity to mingle with developers at MongoDB.

Contact me directly and I can likely get you a discount on admission especially if you are sending more than one developer.

Here is a little info on the course, see the full course page for all the details.

This course is a deep exploration of building applications in MongoDB (the most popular NoSQL document-database). There are many benefits to choosing a NoSQL database over traditional RDMBSs such as SQL Server or Oracle. This course starts out by looking at why you should choose a NoSQL database in the first place. We will explore the native query language and capabilities of MongoDB. Then we will start working with MongoDB from our .NET applications and look at several topics that explore the advanced aspects of the MongoDB .NET API including MongoDB from .NET, Advanced serialization in .NET, Untyped API in .NET via BSON documents, and more. We will see how to leverage the immense scalability of MongoDB using the aggregation framework, replica sets, and sharding. You will discover how to store and manage files of virtually unlimited size in MongoDB using GridFS. We will discuss how to properly design your entities and documents (both natively and in C#) to take full advantage of what MongoDB has to offer. Finally, we will round out the course with a few topics that you will need to be successful with MongoDB including Server administration for developers and Security and permissions.

Note that some of the topics cover in this course are technology agnostic (for example the native query lesson is equality applicable to .NET developers as well as Python developers) and some are specifically optimized for .NET developers (for example Advanced serialization in .NET).

Why should you choose DevelopMentor’s MongoDB course? At DevelopMentor we have experience building and running large scale MongoDB deployments in .NET including our online learning platform LearningLine and develop.com itself. The course authors work closely with the MongoDB team and are in the MongoDB Masters program. We have been teaching MongoDB in our Guerrilla .NET course for several years. In short, we know what we’re doing with MongoDB and .NET and we’d love to share it with you.

Are you interested in Python training for you or your team?

]]>http://blog.michaelckennedy.net/2014/01/03/part-1-welcome-and-lightning-fast-python-introduction-in-python-for-net-developers-series/feed/00.000000 0.0000000.0000000.000000mkennedy66996693Series: Python for .NET Developers Introductionhttp://blog.michaelckennedy.net/2014/01/03/series-python-for-net-and-csharp-developers-introduction/
http://blog.michaelckennedy.net/2014/01/03/series-python-for-net-and-csharp-developers-introduction/#commentsFri, 03 Jan 2014 18:20:14 +0000http://blog.michaelckennedy.net/?p=963]]>Welcome to my series of blog posts covering Python for .NET developers. In this many-part series, I will introduce you to Python from a .NET developer’s perspective.

As .NET developers, we generally adore C# and the .NET ecosystem. It has brought great productivity, expressiveness, and features to software developers. I believe you will be deeply surprised to see a side-by-side comparison of C# / .NET and Python. Many of the features we think make C# special and unique have parallels in Python (sometimes even improved parallels). Join me in this series as I compare C# / .NET to Python in a feature by feature breakdown.

Each post in the series will be short and to-the-point coverage of a single feature in video format. It may also include downloadable source code.

Are you interested in Python training for you or your team?

]]>http://blog.michaelckennedy.net/2014/01/03/series-python-for-net-and-csharp-developers-introduction/feed/145.526697 -122.68805045.526697-122.688050mkennedy66996693Watch Python for the C# and .NET developershttp://blog.michaelckennedy.net/2013/12/18/watch-python-for-the-c-and-net-developer/
http://blog.michaelckennedy.net/2013/12/18/watch-python-for-the-c-and-net-developer/#commentsWed, 18 Dec 2013 14:35:24 +0000http://blog.michaelckennedy.net/?p=955]]>We just published my latest webcast. Feel free to watch it or download the demos and slides. Hope you enjoy it!

Python for the C# developer

Here is the summary:

If you love C# and .NET, you may be surprised to see how many of the features you love also exist in Python (often first). Python is a wonderful language. It is a clean high-level language which values readability over many trade-offs. You can build web applications serving billions of monthly page views. You can build cross-platform GUI applications such as DropBox. You can access amazingly powerful database servers such as MongoDB and SQL Server. But did you know many of the things you absolutely love about C# also exist in Python? Lambda expressions – check. foreach loops – check. Rich class library – check. Iterators – check. And there is more. Come learn about all the things you love from C# and see how they are accomplished in Python.

]]>http://blog.michaelckennedy.net/2013/12/18/watch-python-for-the-c-and-net-developer/feed/10.000000 0.0000000.0000000.000000mkennedy66996693bootstrap-webcast-starterWatch Building beautiful websites with Bootstraphttp://blog.michaelckennedy.net/2013/11/14/watch-building-beautiful-websites-with-bootstrap/
http://blog.michaelckennedy.net/2013/11/14/watch-building-beautiful-websites-with-bootstrap/#commentsThu, 14 Nov 2013 22:20:14 +0000http://blog.michaelckennedy.net/?p=945]]>We just published my latest webcast. Feel free to watch it or download the demos and slides. Hope you enjoy it!

Building beautiful websites with Bootstrap: A case study

]]>http://blog.michaelckennedy.net/2013/11/14/watch-building-beautiful-websites-with-bootstrap/feed/10.000000 0.0000000.0000000.000000mkennedy66996693bootstrap-webcast-starterMongoDB for .NET developershttp://blog.michaelckennedy.net/2013/10/23/mongodb-for-net-developers/
http://blog.michaelckennedy.net/2013/10/23/mongodb-for-net-developers/#commentsWed, 23 Oct 2013 17:18:54 +0000http://blog.michaelckennedy.net/?p=937]]>I’m very proud to announce DevelopMentor’s soon-to-be released MongoDB for .NET course which I am authoring along with Pierre Nallet.

NoSQL and MongoDB for .NET developers

This course is a deep exploration of building applications in MongoDB (the most popular NoSQL document-database). There are many benefits to choosing a NoSQL database over traditional RDMBSs such as SQL Server or Oracle. This course starts out by looking at why you should choose NoSQL in the first place. We will explore the native query language and capabilities of MongoDB. Then we will start working with MongoDB from our .NET applications and look at several topics that explore the advanced aspects of the MongoDB .NET API including (MongoDB from .NET, Advanced serialization in .NET, Untyped API in .NET via BSON documents, and more). We will see how to leverage the immense scalability of MongoDB using the aggregation framework, replica sets, and sharding. You will discover how to store and manage files of virtually unlimited size in MongoDB using GridFS. We will discuss how to properly design your entities and documents (both natively and in C#) to take full advantage of what MongoDB has to offer. Finally, we will round out the course with a few topics that you will need to be successful with MongoDB including Server administration for developers and Security and permissions.

During this class, you will learn:

Learn why you should consider NoSQL as your database.

Discover the MongoDB shell and ‘native’ query language and capabilities

Work with MongoDB from .NET and LINQ

Design your classes and entities to take full advantage of MongoDB

Build and tune high performance applications with indexing and profiling

Use the extensive .NET serialization API to go between .NET and MongoDB

Note: Some of the topics cover in this course are technology agnostic (for example the native query lesson is equality applicable to .NET developers as well as Python developers) and some are specifically optimized for .NET developers (for example Advanced serialization in .NET).

Why should you choose DevelopMentor’s MongoDB course? At DevelopMentor we have experience building and running large scale MongoDB deployments in .NET including our online training platform LearningLine and develop.com itself. The course authors work closely with the MongoDB team and are in the MongoDB Masters program. We have been teaching MongoDB in our Guerrilla .NET course for several years. In short, we we know what we’re doing with MongoDB and .NET and we’d love to share it with you.

The world of data offers new choices and MongoDB is the most popular alternative to SQL databases today. In this one hour webinar, we’ll look at the reasons developers turn to NoSql databases and what makes MongoDB special. Then we’ll look at how to manipulate MongoDB data from C# efficiently and safely by leveraging Linq.

Creating a dynamic UI for data display and navigation takes time – in this 1 hour webinar, we’ll look at using C# and Xamarin.iOS to pull data from the web and display it in a quick, easy fashion in table views using the cool services of DialogViewController. With this technique, you can quickly build data-driven applications to display almost any form of data and be positioned to port that code to other platforms like Windows Phone and Android easily.

Bootstrap has literally changed the game when it comes to web design. This is especially true for developers who have traditionally struggled to build beautiful and engaging sites. With Bootstrap, developers can now start from a good design and evolved. This webcast look at how we at DevelopMentor have used bootstrap to completely redesign our website. We’ll take you through a quick introduction to bootstrap and then look at the various ways we have made use of it’s simple and productive design foundation.

I’m super excited to announce that I’ll be speak at the brand new SDD conference in London next May. I’ll be doing two sessions on ASP.NET MVC and two on MongoDB as well as a full day post conference workshop on MongoDB.

]]>http://blog.michaelckennedy.net/2013/10/07/come-to-my-sdd-conference-sessions-in-may-2014/feed/10.000000 0.0000000.0000000.000000mkennedy66996693sdd14_speak_wide500New online course: Source Control with TFS Version Controlhttp://blog.michaelckennedy.net/2013/09/17/new-course-source-control-with-tfs-version-control/
http://blog.michaelckennedy.net/2013/09/17/new-course-source-control-with-tfs-version-control/#commentsTue, 17 Sep 2013 15:20:57 +0000http://blog.michaelckennedy.net/2013/09/17/new-course-source-control-with-tfs-version-control/LearningLine blog - online developer courses:We’re excited to announce a new online course at LearningLine: Source Control with TFS Version Control by John Bowen This course is a hands-on exploration of Team Foundation Server’s and Visual Studio’s source control system authored by the very talented John Bowen. Here are all the…]]>

This course is a hands-on exploration of Team Foundation Server’s and Visual Studio’s source control system authored by the very talented John Bowen. Here are all the details:

Course Summary

Do you need to get up to speed on Team Foundation version control? Then the Source Control with TFS Version Control course is built for you! This course digs into all the details of using TFS source control. It covers all the basics: checkin, checkout, and changesets. Then you’ll dig into more advanced topics such as branching and merging, leveraging the TFS power tools, getting the most out of workspaces and more. The course also covers important changes introduced in Visual Studio / Team Foundation Server 2012.

Course Objectives

After completing this course, you should be proficient in the following:

]]>http://blog.michaelckennedy.net/2013/09/17/new-course-source-control-with-tfs-version-control/feed/00.000000 0.0000000.0000000.000000mkennedy66996693Reblogged: What should I learn to get started in .NET and web development?http://blog.michaelckennedy.net/2013/05/06/what-should-i-learn-to-get-started-in-net-and-web-development/
http://blog.michaelckennedy.net/2013/05/06/what-should-i-learn-to-get-started-in-net-and-web-development/#commentsMon, 06 May 2013 23:48:33 +0000http://blog.michaelckennedy.net/?p=912]]>[Note: I am reblogging this post which originally was posted to the LearningLine blog. Hope you all find it useful here as well]

I recently had a conversation with someone who is looking to make a fresh start and become a developer (coming from other IT positions). The question they had was:

What should I learn to get started in .NET and web development?

Now this question was starting from a position of “I’d like to get started with .NET and the web. How do I do that?” So please hold your “No, choose Ruby (or NodeJS or … )” comments. That’s another blog post. :)

Here’s my advice along with a bunch of courses you can use to accomplish this efficiently and affordably.

To go from “zero to web dev in .NET” I think you should start on these topics, in an iterative fashion:

Basic objected-oriented programming in C# (what is a class, what is inheritance not patterns per say)

Fundamentals of ASP.NET and MVC (controllers, views, razor, a few things like that)

LINQ (simple focus on LINQ to objects)

JavaScript fundamentals (assuming that’s new to you)

jQuery basics

The ins-and-outs of user input in MVC (including security).

Entity framework basics.

Now if you’d like some advice on where to get this training, check out our content on LearningLine.

Here are the related LearningLine courses from DevelopMentor which will walk you through this path. Because you can preview the first lesson of each course, you have about 7 hours free and the rest are all included in an affordable $29 subscription.

What’s great about taking these classes on LearningLine is there is zero duplication. If a lesson (task) happens to be shared across courses, you’ll see it already marked as completed for you and you can just skip to the next.

Hope this has help give you some guidance on getting serious about becoming a .NET developer.

]]>http://blog.michaelckennedy.net/2013/05/06/what-should-i-learn-to-get-started-in-net-and-web-development/feed/10.000000 0.0000000.0000000.000000mkennedy66996693Why Choose NoSQL and Document Databases over RDBMShttp://blog.michaelckennedy.net/2013/05/03/why-choose-nosql-and-document-databases-over-rdbms/
http://blog.michaelckennedy.net/2013/05/03/why-choose-nosql-and-document-databases-over-rdbms/#commentsFri, 03 May 2013 14:25:32 +0000http://blog.michaelckennedy.net/?p=904]]>Do you want to know the biggest single reason you should choose document databases over SQL Server, Oracle, or MySQL? Hint: It’s not performance or scalability.

Here is a short screencast which shows you the stark contrast in simplicity between an application using a relational database and one using a document database such as MongoDB, CouchDB, or RavenDB.

This is an excerpt from my upcoming online MongoDB course for DevelopMentor. You can take the first 1 1/2 hours for free here:

]]>http://blog.michaelckennedy.net/2013/05/03/why-choose-nosql-and-document-databases-over-rdbms/feed/10.000000 0.0000000.0000000.000000mkennedy66996693Installing MongoDB on Windows and OS Xhttp://blog.michaelckennedy.net/2013/05/02/installing-mongodb-on-windows-and-os-x/
http://blog.michaelckennedy.net/2013/05/02/installing-mongodb-on-windows-and-os-x/#commentsThu, 02 May 2013 18:41:49 +0000http://blog.michaelckennedy.net/?p=905]]>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:

]]>http://blog.michaelckennedy.net/2013/05/02/installing-mongodb-on-windows-and-os-x/feed/30.000000 0.0000000.0000000.000000mkennedy66996693A Roundup of MongoDB Management Toolshttp://blog.michaelckennedy.net/2013/04/22/a-roundup-of-mongodb-management-tools-nosql-database/
http://blog.michaelckennedy.net/2013/04/22/a-roundup-of-mongodb-management-tools-nosql-database/#commentsMon, 22 Apr 2013 19:38:42 +0000http://blog.michaelckennedy.net/?p=884]]>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.

My take: Robomongo is definitely my current favorite management tool for MongoDB. It beautifully blends the power of the mongo shell and JavaScript API with a classy and intuitive user interface. Basically every rich UI can be driven by shell commands and then further manipulated with the UI. Brilliant. The fact that it’s free and works on all platforms is nice too.

The mongo shell is an interactive JavaScript shell for MongoDB, and is part of all MongoDB distributions.

Key features:

Complete (albeit command-line only) access to MongoDB

Comes with MongoDB

My take: While the mongo shell might not be your favorite way work with MongoDB, it is very powerful and it’s always available. So you should take the time to learn it properly. Especially since you’ll need to know most of the features to take advantage of Robomongo above anyway.

Mongovue, price: $0 / $35 / $up, platforms: Windows

MongoVUE is an innovative MongoDB desktop application for Windows OS that gives you an elegant and highly usable GUI interface to work with MongoDB. Now there is one less worry in managing your web-scale data.

Import relational data from MySQL or SQLServer into MongoDB automatically and start building your applications right away

User Managment

Special GridFS interface

Limited shell support

Copy collections from a database to another database

My take: Mongovue has been around for awhile and is solid and affordable. I really like the “overview” view for a given database to see just how much space everything is using and how your data is growing.

C# “shell” rather than JavaScript shell.
Can leverage utility functions from your library
Directly work in the objects and classes of your application

My take: If you are writing .NET apps to talk to MongoDB do not overlook LINQPad. You can take your classes and queries directly from your app and test and view the results in this GUI. Follow Jim Wooley’s blog post link above to see how to put your classes in LINQPad to get started (you might not be using NoRM, so adjust accordingly).

My take: While this is just the basic REST API of MongoDB, you can monitor your log files, run commands using the REST API, and otherwise check in on your server. Not bad. Just requires the –rest command-line to mongod.

My take: This is a very interesting web monitoring app. Just drop a single .RB or .PHP file on your server and you get a well rounded management tool. Only requires that you can run Ruby or PHP on your server.

MMS (MongoDB Monitoring Service) is a service for monitoring MongoDB infrastructure. MMS was created by 10gen and is provided for all users of MongoDB. Designed with security and ease of use, MMS collects statistics on all key server and hardware indicators and then presents the data in a powerful web console. The data is a great asset when optimizing applications during development and potentially invaluable when diagnosing production issues. For sharded clusters consisting of dozens of nodes, MMS is particularly useful because it provides a holistic overview of MongoDB deployments so that administrators can asses quickly the health clusters.

Key features:

Allows secure access to your server’s stats and errors remotely

Great graphical dashboards about server usage

Error reports and logs

Alerts for server issues

My take: MMS is an interesting, free service from 10gen, the makers of MongoDB. It’s pretty easy and quick to setup.

Conclusion:

Hopefully you’ve found something new or interesting that can help you get started or keep going with MongoDB. The lack of management tools was hurting MongoDB’s adoption in the early days. I think those days are past.

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:

Pessimistic concurrency control

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:

Get an entity from the DB and disconnect.

Edit in memory.

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.

The only thing you need to do to use this library in your apps is to implement this interface on all top-level MongoDB entities and use a class derived from ConcurrentDataContext (in library below) for your data access.

Using this interface, the data context will manage a unique ID for you named _accessId per save. If someone else edits this object after you have gotten it but before saving it, you’ll get a concurrency exception, just like EF, and no changes will go through. All you do is call save and access entities via LINQ queries. Nice huh?

Here is an example of your entities with this interface in the db:

Here is an example of an app running end to end with only one editor on the document. See, no errors:

And here is simulating a concurrent edit, which results in an error.

Conclusion

There you have it! For all of you who want to adopt MongoDB and .NET but are concerned about concurrency issues, you now have the same level of concurrency safety as Entity Framework. That should be quite reassuring.

Download for the source, library with the concurrent data context, the sample app, and unit tests from GitHub:

]]>http://blog.michaelckennedy.net/2013/04/08/optimistic-concurrency-in-mongodb-using-net-and-csharp/feed/60.000000 0.0000000.0000000.000000mkennedy66996693github_iconIMongoEntityentityno errorserrorTake the first hour of any online developer course for free at LearningLinehttp://blog.michaelckennedy.net/2013/04/01/take-the-first-hour-of-any-online-developer-course-for-free-at-learningline/
http://blog.michaelckennedy.net/2013/04/01/take-the-first-hour-of-any-online-developer-course-for-free-at-learningline/#commentsMon, 01 Apr 2013 20:43:07 +0000http://blog.michaelckennedy.net/?p=840]]>[Note: reblogged from blog.learninglineapp.com. I’d like to personally invite you to check out our work over at LearningLine – just follow the links below.]

We believe that LearningLine is the most effective online training for developers, period. Today it gets even better. We are announcing the ability to preview any of our online courses, for free without entering any payment information.

This is not a trial that becomes a subscription or a silly 5 minute preview like other company’s offer. You can now study approximately the first hour of any one of our courses. And you can spend as much time as you like doing so.

This means there is now a lot of content available to you right now. At a typical student speed working for an hour a day, it would take over a month to complete all the content that is available for preview.

Do you want to learn how to build rich input forms and avoid security holes in your ASP.NET MVC applications? Just head over to Accepting user input in ASP.NET MVC and click preview:

You get the idea. At the time of this writing, there are 27 courses which run between 4 and 15 days in length. There is definitely something out there for your to try. So head on over to the schedule page and find a course that is right for you:

]]>http://blog.michaelckennedy.net/2013/04/01/take-the-first-hour-of-any-online-developer-course-for-free-at-learningline/feed/00.000000 0.0000000.0000000.000000mkennedy66996693preview-online-developer-course-for-freeSlides and demos from DevWeek 2013http://blog.michaelckennedy.net/2013/03/08/slides-and-demo-from-devweek/
http://blog.michaelckennedy.net/2013/03/08/slides-and-demo-from-devweek/#commentsFri, 08 Mar 2013 08:43:08 +0000http://blog.michaelckennedy.net/?p=833]]>[Update: I added the downloads for the demo code on March 12th.]

I had a great time discussing these topics with everyone at DevWeek 2013. Thanks to all who attended my sessions. Here are the slides:

Important note: In order to run this demo, you must download MongoDB and start it on your local machine. You do not need to initialize a database or anything like that but the db will be empty so use the admin feature to create categories and books. Running MongoDB as a Windows Service is not required.

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.

Online training today

There are many shortcomings in how developers learn online today.

Some developers choose online video libraries. Many of these are well done by highly qualified people. However, software development is a contact sport. We learn by doing, not just watching. Did you happen to watch the (American Football) Superbowl this year? If so, you’re probably more knowledgeable about football. You can have great conversations about football and seem (and feel) connected and current. But can you play football any better because of it? Some things in life are learned through participation – software development is one of them.

Some developers are self-starters and just piece together the knowledge they need. With blogs, YouTube, social media, Channel 9, and a plethora of other sources, motivated and skilled peopled can learn on their own, and many do. This process is definitely hit and miss, and it’s inefficient. You spend a lot of time separating the wheat from the chaff – and there is a lot of chaff out there.

Some developers choose instructor-led classroom training. DevelopMentor has long been known as an industry leader in classroom training. While we think classroom training is great for teams that have the time, schedule, and budget that is an increasingly less common situation for many developers. Online training (of any variety) offers a clear alternative to classroom training and it provides immediate on-demand learning.

World, meet something better

While there are benefits to all the above styles of learning, there are many drawbacks too. In creating LearningLine, we have carefully studied over 30 online learning offerings (both higher education and professional training) and have selected some of the best elements from each. We think the unique blend of the features that we have rolled into LearningLine address many of the shortcomings of online training head-on.

LearningLine is online, and self-paced. You learn when and what you need. Our dependency engine provides the means to “back up the bus” and allow you to fill in any missing prerequisites or immediately see what you can do just after a given lesson.

Our lessons are comprised of learning activities which come in multiple modalities. Everyone learns in a unique way. This is why LearningLine uses multiple learning modalities including videos, articles, code demos, and exercises.

We learn by doing. LearningLine is not a passive experience. It is intense learning where you write code and submit work at every turn. The harder you work, the more you learn. LearningLine is all about creating developers who can ship software.

LearningLine is instructor supported. With LearningLine, you won’t get stuck. When you submit work, your instructors will review your code and suggest improvements. They will answer any question you have for your class. LearningLine instructors are professional software developers with real-world experience building applications with the technology you are learning right now.

Modern software development is a social activity. Why should learning be different? On LearningLine you can talk with your instructor and other students, see who is ahead of you, and you learn as a team. With LearningLine’s reputation system, you can show your teammates just how smart you are as you compete for the #1 ranking.

LearningLine is built around your team. You have full access to our content, and platform, to create your own custom learning that suits your team and project. You can annotate our content and add your own internal learning material to make learning directly relevant for your team. Your own experts can also be instructors using the same tools we have built for ourselves.

Check out our class schedule and pricing options. If you are used to classroom instructor-led classes, I think you’ll be blown away at how affordable instructor-led learning can be.

Do you believe in us?

If you believe that online learning can be more than it is today, and if you believe LearningLine is a step forward, I encourage you to spread the word. Tell your co-workers, tell you boss, talk about us on social media, email a friend and so on.

This is the beginning of a bold adventure. I look forward to sharing it with you all.

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!

So in this post, I will point you at a few open-source DataAnnotation libraries built for MVC.

Jump over there and browse through the various attributes available. There are a bunch, such as RequiredIfTrue. Like so many things with ASP.NET MVC, the way to add foolproof to your project is to use NuGet. Just fire it up and search for FoolProof:

Foolproof is great for dependent validation scenarios such as this field is required if that field is checked or something like that.

DataAnnotationsExtensions is a nice one as well. This library is focused more on validating certain data types: credit cards, dates, urls, etc. Again, it’s available from NuGet. This time you probably want to reference DataAnnotationsExtensions.MVC3 rather than the base project.

Look at the files there that end in “Attribute”. Again, there are some nice, dependent validation attributes here.

I hope that gives you a sense of what’s out there beyond just the built-in validation options. I’m sure there are a bunch of projects that I missed. If you know of any, add a comment with a link and why you like it!

In this short screencast, I will show you how to leverage ASP.NET MVC’s excellent model binding as well as the DataAnnotations attributes to easily add both server-side and client-side validation for MVC websites.

Here’s a quick ASP.NET MVC tip to help you be more productive and write cleaner code. We will see how to leverage C# 4’s optional and default parameters in our action methods for greatly simplifying our code while keeping it fully functional and error free.

Often you want to pass data to your controllers based on URL parameters. This can either be part of the URL itself in the case of route data or it can be part of the query string. In fact, this tip even works for input forms.

Let’s take a basic method which shows some census data, potentially filtered and sorted if that information is passed along, otherwise we’ll just show everything with a default sort.

This looks great, right? If you had a URL such as

/census/detailsvaltype/1?sortAscending=false

It would work perfectly. But what if we omit sortAscending? Well, bool is a value type and doesn’t like missing data much:

I’m just guessing, but most users don’t love this page.

So we can make the parameters strings (no MVC conversion required, missing data can be detected, etc.) like this. But notice how ugly and complex the code becomes

Yikes, we went from 1 line of code to many! However, (here’s the point of this post), let’s try that again with optional parameters:

Almost as simple as the naive version. However, you see making the request with and without data works perfectly! In fact, the data passed to GetDataAndResult are the same here as for the complex variant.

With Data (filtered and ordered):/census/detailsoptionaldefault/1?sortAscending=false

Without Data (unfiltered and default order):/census/detailsoptionaldefault

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.

The next set of steps are only done by the you – the one sharing the code. Right-click on the solution file and choose enable package restore:

After doing this, you’ll see 3 new files in your solution:

Finally, when you zip and share your code, be sure to include the .nuget folder but not the packages folder (and maybe not the bin and obj either).

Now I did say at the beginning why to consider this, not just you should use it as a blanket statement. This whole workflow was introduced for simplifying source code management. Two reasons that come to mind right away to not use package restore are:

If not many of your users / readers / downloaders have package restore enabled globally it might be more effort than its worth.

In the source code scenario, you are dependent on NuGet keeping the right version around forever. Suppose you want to roll-back to the way the code was 2 years ago (some time in the future). It might be safer to have the packages folder just checked in so you’re sure it gets versioned and labeled exactly right.

]]>http://blog.michaelckennedy.net/2012/12/17/use-nuget-package-restore-to-simplify-code-sharing/feed/10.000000 0.0000000.0000000.000000mkennedy66996693enable-globalenablesol2Attend my sessions at DevWeek 2013 in Londonhttp://blog.michaelckennedy.net/2012/12/04/attend-my-sessions-at-devweek-2013-in-london/
http://blog.michaelckennedy.net/2012/12/04/attend-my-sessions-at-devweek-2013-in-london/#commentsTue, 04 Dec 2012 19:39:05 +0000http://blog.michaelckennedy.net/?p=737]]>Want to see some of the topics covered in my blog presented live and in-person? Make your way to London in March 2013 to DevWeek! I’ll be presenting 4 sessions covering NoSQL, ASP.NET MVC, and Cloud (Auzre and AWS mostly). Details below.

Sessions:

Building Rich Input Forms in ASP.NET MVC

ASP.NET MVC has gained broad adoption over the last year. This is in part due to it’s clean and simple design. However, one aspect that new-comers typically get hung up on is building pages that accept user input in various manners. In this talk we will explore the powerful features of ASP.NET MVC that allow us to build rich forms that accept user input. We’ll begin by discussing the built-in HTML Helpers and Model Binding. Next we’ll add validation and show how we can do both client- and server-side validation using DataAnnotations. We’ll see that sometimes using domain models as our form-bound objects doesn’t make sense and so we will cover more advanced scenarios using View Models. Finally, time permitting, we’ll see how client-side programming with JavaScript and jQuery can take this even farther.

Applied NoSQL in .NET

Perhaps you’ve heard about the next generation of databases roughly classified as NoSQL databases? These databases are generally much better than RDBMS at scaling, performance, and easy-of-development (i.e. in NoSQL the object-relational impedance mismatch usually disappears). Unfortunately, many talks on NoSQL are very academic and general. Not this one.

In this talk, we’ll explore the NoSQL landscape and look at the the various options out there. Then we’ll learn how to leverage MongoDB (a popular NoSQL DB) to build .NET applications using LINQ as the data access language. From there we will build out a .NET application using LINQ and MongoDB in a series of interactive demos using Visual Studio 2012 and C#.

Getting Serious About The Cloud – For Developers

You’ve been hearing all about “the cloud” for several years now. Maybe now is the time to take the leap and get started developing for this next-generation platform. That’s what this talk is all about. Learn what options you have for cloud hosting (and the related trade-offs). See how to create and host applications in the cloud. And learn about the tricks the pros use to achieve the scalability and durability promised by all the hype.

(At Least) 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, this talk will give you some easy things you can do immediately after creating that new MVC project that you will thank yourself for as your project grows in complexity.

]]>http://blog.michaelckennedy.net/2012/12/04/attend-my-sessions-at-devweek-2013-in-london/feed/10.000000 0.0000000.0000000.000000mkennedy66996693Introduction to ASP.NET MVC Routeshttp://blog.michaelckennedy.net/2012/12/03/introduction-to-asp-net-mvc-routes/
http://blog.michaelckennedy.net/2012/12/03/introduction-to-asp-net-mvc-routes/#commentsMon, 03 Dec 2012 18:19:35 +0000http://blog.michaelckennedy.net/?p=734]]>Here’s another screencast, this time on MVC and routing.

In this short screencast, I’ll show you everything you need to know to get started with ASP.NET MVC routing. You’ll see how default routes in MVC map to controllers and actions. Next you’ll see how to map additional data from query-strings in addition to simple route data. Finally, we’ll create a custom route to pass additional data in a clean, URL based manor.

As an instructor at DevelopMentor, I have the unique opportunity to watch many developers experience ASP.NET MVC for the first time. This typically goes through several stages:

Extreme Interest (the web is exciting again!)

Confusion (where does the view go again? wait, what’s routing?)

Shock (you have got to be kidding, forearch in the html file?)

Loss (surely there are some drag-and-drop controls, right… right?)

Acceptance (OK, I will learn HTML and CSS after 10 years of working on the web)

Joy and Freedom (How could I have ever used webforms?)

I rarely hear developers who’ve adopted MVC returning to webforms voluntarily. But not everyone makes it to level 6 of MVC enlightenment. So here is an article to help the new comers make it across step 2 more easily as well as help the advanced MVC developers be more productive.

MVC subscribes to the philosophy of convention over configuration. This both makes MVC easier to use but also more confusing to beginners. For example, given an action method in a controller (say the Hello method in the Home controller) your view must be placed in the Views/Home/ folder and named Hello.cshtml. Luckily in the case of views, Visual Studio has the tooling built in to make this brain-dead.

Consider this action method:

First, you could do it the somewhat painful, manual way. Create the views sub-folders (Home), then right-click and choose “Add new item > View”:

And you get this dialog. You then have to fill it out correctly. Make sure you call the view Car and make it strongly-typed to the Car class. It is not initialized for you.

Creating Views via Action Methods

But there is a faster and better way. Make sure your app is compiled. Then right-click inside the action method and choose add view.

Now the wizard that comes up has the name of the view auto-filled by Visual Studio. Nice! It will also create any needed View subfolders and place the file in the correct one.

Creating Views via Resharper

Now, if you have Resharper installed, there are still better ways. First, the view will be red when it is missing. Here’s that same action with Resharper enabled.

Placing the cursor on the view line gives you the red-light fix-it symbol. Hit ALT-ENTER to get the Resharper options.

Choose the bottom option, “Create view ‘Car’ by VS”. This will bring up the dialog fully populated correctly:

Resharper populates the Add view dialog (make take a sec):

Hit enter and you’re all set! That’s the easiest way.

Resharper also has goodness for partial views. See the Car_ShowSummary is red below because it doesn’t exist.

Choosing the same Resharper option, gives you a partial view populated perfectly (make sure you pass the model).

Now you see how easy adding views to MVC projects can be. No need to remember the naming conventions or where exactly to place them. Visual Studio and Resharper handle it all for you.

]]>http://blog.michaelckennedy.net/2012/12/01/create-new-asp-net-mvc-views-the-easy-way/feed/30.000000 0.0000000.0000000.000000mkennedy66996693wizard-4wizard-4wizard-4wizard-4wizard-4wizard-4action-rs-go- selectwizard-4wizard-4wizard-4Nested Layouts in ASP.NET MVChttp://blog.michaelckennedy.net/2012/11/30/nested-layouts-in-asp-net-mvc-razor-pages/
http://blog.michaelckennedy.net/2012/11/30/nested-layouts-in-asp-net-mvc-razor-pages/#commentsSat, 01 Dec 2012 00:25:55 +0000http://blog.michaelckennedy.net/?p=713]]>In this screencast, I’ll show you how easy it is to create ASP.NET MVC layout pages based on existing layout pages. This let’s you achieve a nested layout which you can compose to build beautiful websites in MVC with minimal code duplication or effort.

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.

First a disclaimer / warning. I’m going to show you how to make your site feel faster without speeding it up. If the users feel that it’s fast, then it’s fast enough. However, it might be better to try to just make it faster in the first place. This article assumes you have either tried or ruled out things like increasing the DB performance by adding the proper indexes, caching data where feasible, optimizing queries, etc. OK, assuming you’ve done as much as you can for pure performance, let’s get to improving the experience for the users.

Consider a basic website that shows data from several sources. In the sample case, it’s kind of an iGoogle landing page with different items: TODO, news, etc. In the screenshot below you can see there are several sets of information shown (my details, news, and most popular items).

(click to enlarge)

It turns out that my details and the main page are actually pretty fast. The news and popular items are not. Yet, we are computing them all at once in the MVC action. Thus the whole page feels sluggish and slow. Here is the underlying controller action method.

This is a perfectly reasonable action method. But after doing some profiling we see that we have the following performance footprint:

So a simple solution would be to break the loading of the slower sections (news & popular in our case) apart from the faster sections in the page. We can load the fast data immediately using direct model to razor processing and push the loading of the slow parts to an asynchronous operation using AJAX.

That might be a lot of work in general. But with MVC we can employ a few techniques and really make this simple and foolproof.

First, we’re in luck from the start because we are already using partial views (a key step) for our razor code. If you don’t have partial views, they are easy to add. Here is the relevant page section which renders the data synchronously.

MVC will easily serve the PopularControl’s content up over AJAX and same for any other partial view. So let’s change our controller action in the most simple way to allow us to ask for those elements independently. Here’s the new controller code:

It is important to note that we are returning PartialView (not View) for the parts that were previously managed in the view (news & popular).

Assuming the metrics above, the page will now load in 10ms. That’s vastly better than 2,500ms. With razor rendering time and other overhead it’s more like 50ms, but still vastly better.

But our CSHTML is now messed up. What do we need to do to load this content asynchronously? First, we start by punching “holes” in our razor page where the JavaScript can add the content async. Notice how we use the data-url attribute to simplify coordinating the proper location for the content. We’ll see the JavaScript side of things shortly.

Each section that will be loaded asynchronously now has three changes.

We have a div with the class partialContents. We use this in jQuery to locate them.

Each partialContentssection has a data-urlfor the location of the partialview controller action.

Each partialContentssection has a message and image to show an AJAX indicator that we are working on that area. There is no extra effort to show this. It appears by default and will be replaced as the content loads.

So the controller is ready to serve up this partial content. The view is showing a pending action and has a place to put the results. The final step is to just add the smallest amount of jQuery to do the download and update.

Here is the JavaScript file that does the work. Notice we simply select all the partialContents sections on page load with jQuery. The foreach one we pull out the url and call jQuery.load(). This does the download and updates the HTML for the correct partialContents.

That’s it! Now our site loads the slow sections in parallel and asynchronously.

To fully appreciate the difference you should see it for yourself. Check out the live demo I’ve posted here:

]]>http://blog.michaelckennedy.net/2012/11/01/screencast-refactoring-with-partial-views-in-mvc/feed/345.523452 -122.67620745.523452-122.676207mkennedy66996693Screencast: Strongly-Typed Views in ASP.NET MVChttp://blog.michaelckennedy.net/2012/10/31/screencast-strongly-typed-views-in-asp-net-mvc/
http://blog.michaelckennedy.net/2012/10/31/screencast-strongly-typed-views-in-asp-net-mvc/#commentsWed, 31 Oct 2012 14:59:56 +0000http://blog.michaelckennedy.net/?p=655]]>In this screencast I discuss the how to create strongly-typed razor views in ASP.NET MVC. We look at how Models can be used to pass data (both simple and complex) from controller action methods down to razor views. We also look at the concept of ViewModels which hold aggregate data to pass to views. Finally, we cover some of the tooling for generating views in Visual Studio.