Foundations of Programming, AKA, the ALT.NET FREE Book!!

“Foundations of Programming, Building Better Software” is a new eBook by Karl Seguin. The book does not say in its introduction that it’s all ALT.NET-ish, it starts by introducing what ALT.NET is, it’s goals etc, afterwards, all the topics the book covers are inspired by ALT>NET frequent topics. This includes Domain Driven Design (DDD), Dependency Injection (DI), Object Relational Mapping (ORMs), Mocking, etc…

Here’s what Channel9 had to say about it (which is how I originally found it too):

Karl Seguin recently released a great free 79 page eBook for .NET developers covering design patterns, unit testing, mock objects, memory management, object relational mapping, and more.  Get it while it’s free!

Now, if I did my job well getting your interest, then you may want to get to the best part:

Foundations of Programming, Building Better Software – EBook Download

IF you’re not interested yet, I know this must get your most interest in the book, the table of contents (highlighting chapter titles in bold):

About the Author ……………………………………………………………………………………………………………….6
ALT.NET …………………………………………………………………………………………………………………………..7
Goals ……………………………………………………………………………………………………………………………8
Simplicity ………………………………………………………………………………………………………………………8 YAGNI…………………………………………………………………………………………………………………………..8
Last Responsible Moment………………………………………………………………………………………………….9
DRY ……………………………………………………………………………………………………………………………..9
Explicitness and Cohesion ………………………………………………………………………………………………….9
Coupling ……………………………………………………………………………………………………………………….9
Unit Tests and Continuous Integration …………………………………………………………………………………9
In This Chapter……………………………………………………………………………………………………………..10
Domain Driven Design………………………………………………………………………………………………………..11
Domain/Data Driven Design……………………………………………………………………………………………..11
Users, Clients and Stakeholders ………………………………………………………………………………………..12
The Domain Object ………………………………………………………………………………………………………..13
UI ………………………………………………………………………………………………………………………………15
Tricks and Tips ………………………………………………………………………………………………………………16
Factory Pattern ………………………………………………………………………………………………………….16
Access Modifiers ………………………………………………………………………………………………………..17
Interfaces ………………………………………………………………………………………………………………..17
Information Hiding and Encapsulation …………………………………………………………………………….18
In This Chapter……………………………………………………………………………………………………………..19
Persistence……………………………………………………………………………………………………………………..20
The Gap ………………………………………………………………………………………………………………………20
DataMapper ………………………………………………………………………………………………………………..20
We have a problem …………………………………………………………………………………………………….23
Limitations……………………………………………………………………………………………………………….24
In This Chapter……………………………………………………………………………………………………………..25
Dependency Injection ………………………………………………………………………………………………………..26
Sneak Peak at Unit Testing……………………………………………………………………………………………….27
Don’t avoid Coupling like the Plague ………………………………………………………………………………….28
Dependency Injection……………………………………………………………………………………………………..28
Constructor Injection…………………………………………………………………………………………………..28
Frameworks……………………………………………………………………………………………………………..30
A Final Improvement …………………………………………………………………………………………………..32
In This Chapter……………………………………………………………………………………………………………..33
Unit Testing…………………………………………………………………………………………………………………….34
Why Wasn’t I Unit Testing 3 Years Ago?………………………………………………………………………………35
The Tools …………………………………………………………………………………………………………………….36
nUnit ………………………………………………………………………………………………………………………36
What is a Unit Test …………………………………………………………………………………………………………38
Mocking ……………………………………………………………………………………………………………………..38
More on nUnit and RhinoMocks………………………………………………………………………………………..41
UI and Database Testing ………………………………………………………………………………………………….42
In This Chapter……………………………………………………………………………………………………………..42
Object Relational Mappers ………………………………………………………………………………………………….43
Infamous Inline SQL vs. Stored Procedure Debate …………………………………………………………………43
NHibernate ………………………………………………………………………………………………………………….46
Configuration……………………………………………………………………………………………………………46
Relationships …………………………………………………………………………………………………………….49
Querying …………………………………………………………………………………………………………………50
Lazy Loading ……………………………………………………………………………………………………………..51
Download ……………………………………………………………………………………………………………………52
In This Chapter……………………………………………………………………………………………………………..52
Back to Basics: Memory ……………………………………………………………………………………………………..53
Memory Allocation………………………………………………………………………………………………………..53
The Stack …………………………………………………………………………………………………………………53
The Heap …………………………………………………………………………………………………………………54
Pointers …………………………………………………………………………………………………………………..55
Memory Model in Practice……………………………………………………………………………………………….57
Boxing …………………………………………………………………………………………………………………….57
ByRef………………………………………………………………………………………………………………………58
Managed Memory Leaks ……………………………………………………………………………………………..61
Fragmentation …………………………………………………………………………………………………………..61
Pinning ……………………………………………………………………………………………………………………62
Setting things to null …………………………………………………………………………………………………..63
Deterministic Finalization ………………………………………………………………………………………………..63
In This Chapter……………………………………………………………………………………………………………..63
Back to Basics: Exceptions …………………………………………………………………………………………………..64
Handling Exceptions ……………………………………………………………………………………………………….64
Logging……………………………………………………………………………………………………………………65
Cleaning Up ………………………………………………………………………………………………………………65
Throwing Exceptions ………………………………………………………………………………………………………67
Throwing Mechanics …………………………………………………………………………………………………..67
When To Throw Exceptions ………………………………………………………………………………………….68
Creating Custom Exceptions …………………………………………………………………………………………….69
In This Chapter……………………………………………………………………………………………………………..72
Back to Basics: Proxy This and Proxy That……………………………………………………………………………….73
Proxy Domain Pattern …………………………………………………………………………………………………….74
Interception…………………………………………………………………………………………………………………75
In This Chapter……………………………………………………………………………………………………………..77
Wrapping It Up ………………………………………………………………………………………………………………..78

The book cover has the www.codebetter.com URL, the community blogs whose owners originally started ht ALT.NET movement (I wrote about it very early back). I suspected it even before reading the table of contents!

Oh my. This is the book I always wanted to either read or write. Now I only have one option!!!

Microsoft’s IoC Container is no longer BETA – Please Welcome the Unity 1.0!

One Line Statement

Microsoft’s IoC container Unity, hosted on CodePlex as an Application Block for Enterprise Library is now released in ver. 1.0.

Introduction

If you do not know what IoC is, you might want to check sample articles:

I have been interested in Dependency Injection (DI) and Inversion of Control (IoC) for few months, and I brought other guys interested too such as Mohamed Nour :D. I’m not going to discuss when I believe those strategies should be used, and how they relate to each others (at least not in this post).

The usual story

If you know about IoC, you’d know that there’re few big players in the field that are speaking .NET. I’ll not compare them here. I’m not even talking about them with relevance to time order, but I like to see how the "vendors / characteristics" map looks like.  For comparisons, check the end of this section.

The usual story, a player coming from Java world, moving from Java’s Spring to .NET’s Spring.NET. As you’d expect, this is the one mostly in love with XML configurations – too much of them sometimes, but, it’s the most mature one.

Then, as for everything coming from other worlds, Castle group/project was interested. They had their own player, Windsor. Windsor is of course less XML-ish, and as you may expect, it fits best in combination with other Castle stuff. As usual with Castle, the documentation is way far from complete, however, a funny joke about it is someone saying that a big feature of Windsor is that Ayende blogs a lot about it!

Also as usual, there had to be an individual player who tries to do the thing from scratch. That was StructureMap.

For a true comparison between those players, check the following articles:

Here comes Microsoft

As happened with AJAX and unit testing frameworks, when Microsoft decided to create it’s own game into the scenes, Microsoft has come to this ground as well to make its standard flavor, going with the relatively recent strategy of not trying to kill the existing players (The proof is approving supporting them in ASP.NET MVC Framework).

Microsoft IoC container as usual had a unique characteristic, and as usual, the unique thing is related to integration with more MS stuff. The Unity IoC container is actually an Enterprise Library Application Block. It’s meant to be part of Enterprise Library 4.0. Although Enterprise Library 4.0 is not "released" yet, The Unity Application Block itself is done 1.0, and available to download and use.

Being part of the Enterprise Library (and being an IoC container in general actually – LOL), it didn’t escape the XML configuration hassle. Again, that’s (unfortunately) a necessity for any IoC. For more information and examples on using Unity, check any of the following articles:

Create you own (Just for fun!!)

If you want to see how this thing from inside looks like, and you do not have time to investigate the source code of a sophisticated IoC container from any of the big players, check Ayende’s Building an IoC container in 15 lines of code article. But do not expect that to make you one more player :D.

You can also check how you can try achieving very basic functionality with the existing components of the BCL – that was before Unity of course :).