Best Practices
Tips and techniques of best development practices
Craig Shoemaker sits down with Miguel Castro to follow up on the first show on Architecting for Extensibility. In the previous show, Miguel takes us through a number of the patterns that make it possible for you to design points of extensibility into your applications. In the sequel to part one, Miguel describes in detail how he uses this pattern in CodeBreeze.
Raising Money for Diabetes with Halo 3 on Oct 11
Join Scott Hanselman in his enduring fight against diabetes by playing Halo 3 in high-def! For details on the event
check out Scott's blog (http://tinyurl.com/yue4qm). To sign up go to http://iammasterchief.com/
Thanks!
I want to send a warm greeting and a big thanks to:
- Jeffrey Norris
- Buddy Stein
- Brian Deacon
Still an MVP
My ASP.NET MVP award was renewed this year!
The Design Patterns Bootcamp : Model View * Patterns series is now complete!
The series features two audio pieces and five instructional videos. The audio portions take care of introducing the concepts and answering frequently asked questions, while the videos cover the following topics:
- Implementing Model View Presenter
- Supporting Windows Forms
- Controlling User Messages
- Data Sources, Service Layers & Maintaining State
- Encapsultaing DropDownList Data Sources
Good luck while you build your applications to last!
Check out the latest release in the video releases of the
Design Patterns Bootcamp Series: Model View * Patterns.
This video will show you how to report messages back to users in a web application written with MVP (Supervising Controller).
Check out the latest release in the video releases of the Design Patterns Bootcamp Series: Model View * Patterns. This video will show you how to take an existing web application written with MVP (Supervising Controller) and re-purpose the lower layers for use in a WinForms application.
Check out the latest release in the video releases of the Design Patterns Bootcamp Series: Model View * Patterns. This video will show you how to implement a web application using the Model View Presenter (Supervising Controller) design pattern.
Make sure to keep checking the show notes page as there will be more in this series of videos!
I am now an ASP Insider!
I was accepted last month into the prestigious group, the ASP Insiders. The Insiders
are a group of industry professional that get an inside look at Microsoft products and provide early feedback. I am quite honored to be a part of the group for the opportunities that Microsoft provides as well as being associated with the stunning roster.
Shout Outs
Declarative Progamming with ASP.NET 2.0
Listener Michael Hamrah wrote an interesting blog post on Declarative Progamming with ASP.NET 2.0. Check it out an comment up!
Working with SubSonic and Loving It!
One of the activities that has kept me from podcasting is working on a side project. For this project I have been using SubSonic. I must say I am impressed... check it out!
Rockford Lhotka
Rockford Lhotka is the Principal Technology Evangelist for Magenic Technologies, a company focused on delivering business value through applied technology and one of the nation's premiere Microsoft Gold Certified Partners.
Rockford is the author of several books, including the Expert VB 2005 and C# 2005 Business Objects books. He is a Microsoft Regional Director, MVP and INETA speaker. He contributes to several major magazines and regularly presents at major conferences around the world - including Microsoft PDC, Tech Ed, VS Live! and VS Connections.
Rockford has worked on many projects in various roles, including software architecture, design and development, network administration and project management. Over his career he has designed and helped to create systems for bio-medical manufacturing, agriculture, point of sale, credit card fraud tracking, general retail, construction and healthcare.
Source: http://lhotka.net/Area.aspx?id=1
I came into the office today to find zero emails generated from my exception management engine. This is a particularly good thing as I had just setup a windows service to archive data from SharePoint to the file system. But I am getting ahead of my self...
When this project was originally defined, the customer stated that they wanted a web part that would handle archiving documents from SharePoint document libraries to the file system. After evaluating the amount of data that is moving in an archive we pushed back. Our position was that a smart client application that uses the SharePoint object model makes more sense in this case as we basically just pulling data out of the SharePoint database and placing it on disc. Yes we have no banannas. This proposal was rejected as the client doesn't want to have to login to the server just to run an archive.
The next option was to create a windows service that polls for flags in a SharePoint list. When an item is marked as queued, then the archive job inititates. Now it all works perfectly.
An important point to make is that we didn't consider SharePoint or the Windows service or anything until the very END. I mean this to say all of the functionality was written first in business objects against test fixtures running in NUnit. You have probably heard me sing the praises of automated testing before and I can not emphasize enough how key these techniques are to sucess in an application of this nature.
For more goodness in application architecture check out the latest podcast:
Architecting for Extensibility
Miguel Castro is a Visual Developer C# MVP, CoDe Magazine Writer, Speaker at VSLive! and many usergroups and any other place geeks tend to congregate.
Miguel is known for is work with custom web controls which is a natual outpouring of his penchant for elegant object oriented development. Visit Miguel's website at DotNetDude.com and read his blog at http://www.geekswithblogs.com/mcastro
Thanks, Brennan!
Brennan had some nice things to say about the show, check out his blog!
Resources
We mention a number of design patterns and object oriented priciples in the show. If you would like to learn more, here are some places to start.
Books
Pattern Definitions
Code Samples
Download the Miguel's code samples here.
Featured CoDe Magazine Content
Web Control Enhancements in ASP.NET 2.0 by Miguel Castro
Compilation and Deployment in ASP.NET 2.0 by Rick Strahl
Here is a nice little utility you might be interested in - the
Refesh Detection control over at joel.net. The explanation page is outfitted with a nice example and places to download source code. Check it out!
In our interview, David West discusses his motiviation to write
Object Thinking and why its so different from all the other object
oriented programming books on the shelf. David also tells us how treating objects
like people can greatly simplify your code as well as lead to better design.
Part One
Featured CoDe Magazine Content
The Baker’s Dozen: 13 Productivity Tips for Remoting in Visual Studio 2005
Featured CoDe Magazine content in part one is is
"The Baker’s Dozen: 13 Productivity Tips for Remoting in Visual Studio 2005" by
Kevin S. Goff.
Part Two
Be An Early Adoper!
Paul Sheriff is starting Paul Sheriff's Inner Circle, a place
for developers to get exclusive content and a look inside professional
software development processes.
MeetMe emails feature Michael Hamrah Media Vast, Inc. Michael is a senior developer over
of http://www.wireimage.com/ and
http://www.filmmagic.com/. We also heard from
Michael Perry of Radiant Systems. He runs Mallardsoft, makers of the
Dependency framework. Check them out!
System.Transactions and ADO.NET 2.0
Featured in part two, our CoDe Magazine content comes from
Sahil Malik who brings us
System.Transactions and ADO.NET 2.0
Speaking at the Podcast and Portable Media Expo
I am speaking at the Podcast and Portable Media Expo this year. If you have
any plans to attend, please let me know!

Part One
In part one of our interview, David West discusses his motiviation to write Object Thinking and why its so different from all the other object oriented programming books on the shelf. David also tells us how treating objects like people can greatly simplify your code as well as lead to better design.
The Baker’s Dozen: 13 Productivity Tips for Remoting in Visual Studio 2005
Today's featured CoDe Magazine content is "The Baker’s Dozen: 13 Productivity Tips for Remoting in Visual Studio 2005" by Kevin S. Goff.
The Google-happy John Kuhn recently sent me a link to an older article about ViewState that deserves some new attention. You might want to check this article out because author Milan Negovan does a great job of taking you through many of the nuances of ViewState. This is just what the doctor order recently on one of our projects, perhahps it will help you too.
Have you ever read Good to Great? This book is a must-read for you because each level of an organization can become great - even perhaps your humble programming team.
Jim Collins spends time in this compact work breaking down his research of what it took to turn a mediocre companies into banner organizations. The book is built on a foundation of a five year research project where companies are compared and contrasted against one another in order to bring light to why some organizations transcend to greatness and why others simply enjoy spurts of unsustainable success.
What I thought was most intriguing about one of the examples he uses is the study of 3M vs Norton. The point Collins makes is that 3M would out-manuver and out-wit Norton every time because of a culture of agility and iteration.
The 3M corporate culture is reported to be that of encouragement to try new things without an oppresive framework of bureacracy to "get the project approved". Failures were not only went unpunished, but were expected. The endeavor to try "new things" was more important to 3M than the need to come to create perfection the first time around.
Norton on the other hand, boasted of its ability to plan and strategize for each response to the market they planned to make. The culture is described as rigid and over-thought, over-planned, and dare I say "over-engineered".
Interesting, but why bring it up?
Well I am sure you see the obvious correlations between the agile and waterfall approaches to software development. Each with thier own virtures and chinks in the armor - the agile approach seems to find success as a philosphy in some enduring places.
Here are some reasons I think are siginficant:
- "Command and Control" doesn't stimulate creativity. When you receive a specification for a new feature of the system where every detail is spelled out - don't you bristle just a little?
Developers People don't like being told what to do... we want to contribute our unique creative ideas to a project.
- Hubris abounds. When attempting necromancy by trying to spec out an entire application before a single line of code is written, you will make make false assumptions. The saying goes, "you know most about your application once it's written."
- Failure is not failure. In a truly iterative environment failure is not failure, but an object lesson of what doesn't work. Now that you know that XYZ doesn't work, you won't attempt the same solution to that problem again.
Notice how we are not really talking about software development here. The tenents of agility and iterative development seem to fit well with humans - not necessarily software development or making the latest and greatest roll of Scotch tape.
I recently did a
podcast on exception management. In that show I spoke of some best practices and techniques to formalize your exception management. There is a new technique that I would like to add to the collection of ideas that are in the podcast.
Deal with Exceptions Late
One of the tenents I explained was the benefit of catching an exception late. This means you would wait to the last point possible to do any significant exception handling. Why should you wait? Wraping up your exceptions in the lower-levels of your application will hide errors and make debugging and application support difficult. With the idea's merits, this technique presents a problem. If you wait to catch your exceptions, when you are debugging the .NET runtime will build a stack trace that will guide you through the lowest catch block. If your lowest catch block is late in the call chain, then you are taken many steps away from the offending code.
Stay Close to the Source
A great way to help you stay closer to the source of an exception is to write some debug statements in a catch block and then re-throw the exception. Here is an example:
try
{
// some nasty, super buggy code
}
catch(Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
throw; // make sure you just use "throw" and not "throw ex"
}
Now when you are debugging the application you can set a break point at the first line in your catch block and your exception will still flow through the call stack as if it was never touched. The benefits are:
- You are able to interrogate an exception and look at run-time variable values catch block without having to prematurely deal with an exception
- This technique does not add any overhead. Debug statements are not included in a Release build.
- This technique will not recast or change your original execption in any way.
This will give you more control of your code in keeping you close to the origin of your exceptions.
- Craig
Be sure to check out the latest podcast, "Introduction to Atlas".
A technique you can use to speed up development and use of your prototypes is to use the TEXT attribute of your ASP.NET server controls.
The issue is when you create a new prototype page you often add a number of server controls to the page and bind the data up in code behind. Another option you have available to you is to add data to the TEXT attribute of the control and leave it there - even when you move the page into production.
As your page moves through the development lifecycle code will be written against those controls and the code behind will take care of replacing the sample data.
Why would you want to put "silly" sample data in your prototypes?
- Sample Data Can Be Easy to Spot: If you use silly sample data, you can spot places where you have misssed placing real data
- Persistence of Intent: Keeping the sample data in the page will help designers and other developers to see why type of data is intended to be in the control
The benefit of this technique is that the sample data in your TEXT attribute may remain in the page and allow as a guide for what the data should look like.
- Craig
Be sure to check out the latest podcast, "Introduction to Atlas".
Do you ever pull up a project you haven't worked on in a while and when you run the solution the pages refuse to work correctly? The symptoms include server control events don't fire all the while the client-side validators seem to work just fine.
The cause for this is the JavaScript files that ASP.NET installs on your sever get somehow mangled. If you run into this problem here are some steps you can take to fix the problem:
- Delete your temporary internet files: In IE click
Tools > Internet Options > General Tab > Delete Files
- Delete your VSWebCache. To find the location on your machine open VS.NET and click Tools > Options > Projects Folder > Web Settings
- Run aspnet_regiis /c: Use the Visual Studio.NET command prompt to run this utility.
Note: If you get an error saying that you must be the administrator on the machine to run the utility, then make sure all files are not marked as Read Only under the C:\Inetpub\wwwroot\aspnet_client path (or wherever your home directory in ISS is set to).
Special thanks to Robert Liccardo (our debugging guru at PDSA) for this tip :)
Make sure you to check out the latest podcast about the ASP.NET 2.0 Atlas Framework.