Saturday, February 23, 2008

ASP.NET MVC in Action - Early Access PDFs

book coverThe cat is out of the bag now!  I’m writing a book on ASP.NET MVC for Manning Press entitled ASP.NET MVC in Action.  I really thrilled to be part of this along with my co-authors Jeffrey Palermo and Dave Verwer.

So far 3 chapters are available on Manning’s Early Access Program.  We’d love to hear your feedback on the book so far.

Writing a book is much harder than I originally thought, but I think that blogging for four years has definitely helped.  With a book, everything has to be much more “polished,” so finishing up chapters tends to take a while.  This might explain my drop in posting frequency, but I hope to add tidbits of information that I’m working on to give you guys a peek at what the book will be like.

Our target release date will be October 2008.

Tuesday, November 20, 2007

Book Review - ASP.NET 2.0 Anthology

A few weeks ago, Jeff Atwood sent me a free review copy of his new book, The ASP.NET 2.0 Anthology.  He co-authored the book with K. Scott Allen (from OdeToCode), Wyatt Barnett, Jon Galloway, and Phil Haack.

Normally I wouldn't get excited about a book like this, but looking at that list of authors I was more than intrigued to give it a try.  Granted, the book is targeted for the beginner to intermediate ASP.NET developer, so a lot of it was not very helpful to me, but I did find quite a few good nuggets that I will take away and utilize in the future.

The first few chapters give a general overview of the newer features of .NET 2.0 and some other basic concepts.  I think that this would be helpful to someone just coming to ASP.NET (maybe from another language) and want to get started. 

The book was published by SitePoint, under their "Anthology" style.  This means the book is organized into 101 different "tips" phrased as questions that someone might ask on a forum or similar.  Some examples from Chapter 1 are "How do I use source control?" and "How do I go about using open source code?" -- I was pleased to see these sections in the book.  You normally wouldn't expect this and I think it helped make the book more well-rounded.

The middle chapters were a bit more targeted to the intermediate ASP.NET level, which made it more interesting for me.  They covered things like custom configuration sections, custom validation, how to maintain control state when viewstate is turned off.  All throughout I think the authors gave solid advice on all these features.  There was a good section on Membership and Access Control, which is sure to be helpful to intermediate ASP.NET developers.

The last few chapters were the most interesting to me, which is funny because most of them weren't specific to ASP.NET.  A section on troubleshooting bothersome SQL queries is sure to help people out.  There were a good number of general web developer tips, such as considering SEO and clean HTML for good search engine rankings.  I appreciated the tip on how to utilize URL rewriting at the IIS level, and how to serve-up custom images to evil hotlinkers on myspace (thanks Jeff Jon!).  These types of things are great to know when pursuing a career as a web developer.  The last chapter introduced SubSonic, which I think was awesome.  Not many developers that I meet have heard of SubSonic and I find it to be a pretty useful tool with a low barrier of entry.  It definitely warranted some attention in this book.

While a lot of the content was your typical ASP.NET 2.0 fodder that I avoid (like SqlDataSource), I thought that the authors did a good job of noting when things were applicable, for example when to use the Web Site model vs. Web Application Projects.  The book didn't have enough beginner content and explanation of ASP.NET to be a beginner book (which is a good thing), but it did have quite a lot of excellent tips that makes this book a great companion to any intermediate developer.

Thursday, August 30, 2007

Professional XNA Game Programming - Review

Xna-bookI just finished reading Professional XNA Game Development by Benjamin Nitchske.  It was my first attempt at using the XNA Framework.  I have some experience with DirectX, as I have been tinkering with it since version 5. Most of my work has been with the Managed DirectX bits for .NET 1.1. I found it to be much easier and readable than C++, just because of the language differences.

XNA takes that next productivity leap and really allows you to hit the ground running.  You start out with a game loop (complete with elapsed time already calculated for you), a graphics device already setup, and a managed content pipeline for imported models, sounds, and textures.  Things like graphics memory getting lost when you alt-tab are already handled for you.

But enough about XNA, this post is a review for Benjamin's book.  If you haven't heard of him before, he was the author of the first Managed DirectX game called Arena Wars, and later wrote RocketCommander. Both games are very well done and he ported RocketCommander to XNA so that you can play it on the XBOX 360. XNA Racer was also done completely by himself, which is very impressive.  Needless to say, with all that background and expertise... I had high hopes for this book.

The first few chapters introduced how Benjamin approaches game development.  He calls them "Unit Tests" but that term often implies that the tests are automated.  His tests are basically slices of game functionality that he calls manually.  For example he might have a unit test to verify that shadows work properly, or that a specific collision detection algorithm works.  He is able to setup the update and render loops using anonymous methods and execute them using batch files or manually calling the unit test instead of the main game.  I found this to be very interesting, however the code that he used to write it was somewhat ugly and unintuitive.  I coded the Pong game following his coding style and was disappointed the whole way through it.  While he does say that we will utilize better code for the next game, the code he wrote here was inexcusably bad. I got the game working, however new features and modifications would prove to be difficult because it is just spaghetti code.  I swallowed my pride and told myself, ".. it will get better."

So then I started to follow his next example: Breakout.  I have built breakout before using Managed DirectX, and it was quite fun.  I was disappointed to find out that he didn't really buid the game through the book, he rather took the reader on an exploration of code already written. And he was true to his word, the code pulled a lot of functionality into "helper" classes which made them reusable.  And yes, the code was still horrid.

I mentioned reusable code.  It wasn't reusable like you're thinking.  He actually tells you to copy the code from the previous game and paste it into the new game.  I'm not kidding.  I'm a professional developer.  This book is called Professional XNA.  Professionals don't write code like that. He begins to talk about 3D programming in a way that is -- while full of information -- poorly organized and generally boring.  I learned a lot in this section, but nothing I can really refer to later.  It was more like a stream of conciousness than organized writing.

Let me give you a hard example of how bad the code is.  At one point he is talking about how he handles car physics, which was very interesting.  Then I saw the class diagram where he implemented it.  It looked something like this:

CarPhysics-crap

What!?!? So ChaseCamera inherits from CarPhysics which in turn inherits from Player?  Sounds like an object model from the Twilight Zone. This is pure junk as an object model, and is really only there because the CarPhysics object needs to know details about what the player is doing, and indeed so does the camera. But that doesn't mean you should break all rules of OO just to achieve a hack that works.  I was so appalled by this I almost didn't finish the book.

Benjamin knows his stuff, no doubt.  I think it’s amazing that someone can build something as beautiful as RocketCommander or XNA Racer in less than a month by yourself.  But I just can’t recommend this book because of the code quality.

I will wrap this up by saying that I *did* enjoy the book because it got me into game programming again, but I find this type of writing almost intolerable.  I enjoyed to learn about some nuances around XBOX 360 vs. PC versions of XNA Games, and I especially liked his Unit Testing technique. The information on Shaders was mildly useful, albeit boring. But if you're going to be reading this book, be fore-warned that the code sucks.

I give it 2.5 / 5 stars.

Thursday, April 19, 2007

Review - Agile Principles, Patterns, and Practices in C#

Robert Martin has a great book here.  I just finished reading Agile Principle, Patterns, and Practices in C# (what a mouthful!). 
 
In this book you get a fantastic play-by-play of a typical TDD/pairing session, which I think is a great way to demonstrate the process. 
 
This was also the book that really got me to appreciate UML for what it is.  I'm typically the guy who knows the UML basic shapes, and draws a bunch of interconnected rectangles on a whiteboard to help me solve problems.  I was never a "fan" of UML because I always associated it with the monolithic CASE tools that use UML as the source for an architecture, and out spits generated code.  The book described what Martin feels are the essential (read: useful) components of UML and really abandons the rest.  He emphasizes throwing away your diagrams when you're done and encourages writing them on a napkin or a whiteboard, which is infinitely faster than, say, Visio.
 
The section on patterns is well written, and it is always nice to get refreshers on patterns that you might not know about or haven't used recently.  Again he emphasizes not to go crazy with patterns.  They are there when they help, but don't be shy about throwing them out when they complicate things.  Indeed, this book is agile.
 
The final section (or rather 1/3 of the book!) goes about a payroll system.  He does a bit of UML to get the basic idea in his head and then he goes straight to the tests.  He fleshes out the entire thing, right there in the text.  The model changes, the tests drive the design and behavior, and he frequently consults with his "Customer" (himself) over what the requirements are.  After he has a working model that is fully tested, he bolts on persistence using a custom ADO.NET pproach, which is difficult.  Seeing him do this reminds me of how I like to use NHibernate, but I found it difficult to repeat this approach using flat ADO.NET calls.
 
I'm thoroughly impressed with this book.  If any of the topics above interest you, then go pick it up!
Friday, January 19, 2007

Free book on Domain Driven Design

InfoQ has published a small book on DDD called Domain Driven Design Quickly.  They're giving away the PDF for free!  The print version is only $22, so I'll probably buy it if I like the PDF version.

Check it out:
http://www.infoq.com/minibooks/domain-driven-design-quickly