NetFXHarmonics .NET SolutionTemplate with E-Book ----------------------------------------------------------------------------- =Introduction= This template contains the base architecture and functionality that all projects need. This template is also organized in a very clear way that clearly separates each type of element into it's own section. In order to make sure that the solution is understandable by many different types of developers, there are commentaries in each file in the solution. Some of these range from a short snippet stating how obvious the function of the file is to what could easily be turned into a book chapter. That's why I consider this SolutionTemplate not only a template, but also a living .NET e-book. Over time, I will be updating SolutionTemplate to account for more .NET technologies, I will also continue to expand the commentaries and lessons to the point where the solution itself becomes a case study, a sample application, and book all wrapped up in one. =General Lessons= ==Client-Side Type Organization== The first lesson you should learn from this solution template is that type organization is a critically important topic. Without type organization you will have to go out of your way to look for the type you are looking for. To aide in type organization in a website, you should always group your file types and resources in their respective areas. For example, images should go in the Images folder. In this example, you know exactly where your images are at all times. Furthermore, you should structure your client-side code to match a well-defined server-side model as much as possible. For example, where do you keep your server-side ASP.NET code that will be executed at run time? You keep it in the App_Code folder. In the same way, where should you keep your client-side JavaScript code that will be executed at run time? In the Code folder. Simple. This example in particular will should help you out tremendously in your JavaScript development. Why? Because when you start to think of JavaScript as a programming language with a programming platform instead of simply a scripting language, your brain will identify it with programming and development instead of childish scripting. JavaScript is a full programming language just like C# and we should treat it that way. So, never put JavaScript in a Script folder as that is misleading, will lead to severe confusion, and will signify to others that you are using JavaScript as a scripting language (i.e. validating fields and submitting forms) not as a programming language (i.e. making Ajax calls and creating objects). ==Framework Design== There's absolutely nothing to say about Framework Design, because as a .NET developer you are required to understand and obey the constitution of the .NET Framework written by Krzysztof Cwalina and Brad Abrams titled "Framework Design Guidelines". This book explains not only how to design your frameworks, but also how to make your code virtual self documenting and how to make sure it doesn't have any of your own personality written into the types. Furthermore, the book explains common patterns to make sure your frameworks are properly built. For example, it explains the dispose pattern and asych pattern in great detail as well as how to properly think about and structure your exception handling infrastructure. If you do not have this book, you need to get this book immediately. The .NET framework has more people working on it then probably any open source project in the world, yet the entire .NET framework looks like it was written by just a few people, because each of the people involved follow the guidelines and therefore play as a team. There are some places where the framework strays away from the guidelines, but these places were most likely built before the guidelines were established and many of these are mentioned in the book as known mistakes. Have you ever looked at C# v1 and wondered why it looked so much like Java? The answer is simple: C# used most of Java's coding guidelines as it didn't have its own. Now that we have the guidelines C# looks much different then Java and finally has an identity of its own. Some have also noticed that some C# code looks like MFC code, but this is simply because that C# code didn't follow the guidelines. When you follow the guidelines, people should be able to use your framework without ever looking at the documentation and should be able to tell you exactly what it does in detail by simply looking at the type and assembly names. In addition to having the book, you should also watch Brad Abram's lectures of framework design at the following links (the videos are also on the DVD that comes with the book): http://msdn2.microsoft.com/en-us/netframework/aa497250.aspx David Betz dfb@davidbetz.net http://www.netfxharmonics.com/ ----------------------------------------------------------------------------- Please see http://svn.netfxharmonics.com/SolutionTemplateWithEBook/trunk for the most up-to-date release of this solution. template.