Do you make developer resolutions every year? I do as a way to push myself into situations that will make me grow as a developer and consultant. In late 2007, I made resolutions to start embracing the Alt.Net movement to expand my horizons to all things that do not originate in Redman. Do not get me wrong. I love the Microsoft Kool-Aid; I just needed to see what the grass was like on the other side. With successfully completed projects using open source software like Castle Windsor, Spring.Net, NAnt, XUnit and Log4Net, I believe that my resolutions were successful.

A new calendar year comes with a new set of resolutions and challenges. My resolution for 2009 will be to become a competent developer in the field of cloud computing on the Microsoft Platform. To help me in my resolution, Microsoft has just granted me access to the Azure Computing Platform and the Live Services Platform. Talk about great timing.

You might be thinking to yourself why would he pick cloud computing? The answer is simple, cloud computing is the way of the future. Non-scalable, monolithic desktop or web farm applications are so 2005. The future of application development is distributed computing power running your application across hundreds of servers that you do not own or maintain. Today, companies like Amazon, Google, and Microsoft, are creating services and solutions to enable this type of cloud distributed applications. I am certain that the hip cloud computing buzzword of today will materialize into an established platform choice for my application in the near future.

As an early adopter of new technology, I can’t wait. See you in the cloud.
Adam J Wolf

Polyglot Python

Published 8/25/2008 by Adam Wolf in Craft | Development | DLR | Python

I have been developing software in one form or another ever since Junior High School and have used languages like Basic, Pascal, C, VB, VB.Net, JavaScript and C#. In the last few years, I have only used C#, a little JavaScript and I am feeling a little stale, so I decided to find a new development language to add to my skill set.

My initial search for a new language was open to anything including different platforms and non-Microsoft technologies. I was somewhat like the preverbal “kid in a candy store” because I just could not stop searching and wondering what each language would taste like. Therefore, after looking at languages like Java, Haskell, F#, Smalltalk, Ruby, Boo, Scala and Python, I decided that I needed some help and created some criteria to help me choose.

  • Usable for daily development
  • Must be able to produce Smart Client, and Silverlight application
  • Interoperable on the .Net platform
  • Positive cost benefit analysis (Dice Consulting Positions)

The cost benefit is simple, I need to absorb large amounts of technical information and the benefits need to outweigh the time spent learning the new language. The real benefit would be an increase in bill rate for my consulting services. Since I already know the two major languages for the .Net platform, and with the reluctance of program managers to use non-standard languages, the cost benefit criteria is looking a little weak. So I added a new criteria, the language will need to show me a different view on programming that I am not getting with my C# and VB.Net.

The winner is IronPython, a dynamic language used in conjunction with the new .Net Dynamic Language Runtime. Python was created in the 1980s by Guido van Rossum, who is now working at Google. The Python language is a wrist friendly language due to its terse syntax and no need for the normal text enclosures like C# and VB.Net. The language comes with the “batteries included” and this refers to the numerous libraries that come with the language, which will enable you to write almost any type of software. The IronPython implementation on the .Net platform has full access to these standard Python libraries as well as the full .Net Framework.

Benefits of Python

  • very clear, readable syntax
  • strong introspection capabilities
  • intuitive object orientation
  • natural expression of procedural code
  • full modularity, supporting hierarchical packages
  • exception-based error handling
  • very high level dynamic data types
  • extensive standard libraries and third party modules for virtually every task
  • extensions and modules easily written in C, C++ (or Java for Jython, or .NET languages for IronPython)
  • embeddable within applications as a scripting interface
Python is a dynamic object-oriented programming language that can be used for many kinds of software development. It offers strong support for integration with other languages and tools, comes with extensive standard libraries, and can be learned in a few days. Many Python programmers report substantial productivity gains and feel the language encourages the development of higher quality, more maintainable code.
From www.Python.org

Learning Python

I have started learning Python from the Manning’s early access program from the book “IronPython in Action”. The early access program gives you access to the book as the authors and editors are working on future chapters. In the first part of the book, the authors build a Windows application using an iterative development style and design patterns to teach the reader the Python language. I really enjoy this approach because I can read and try the concepts in a real application development scenario.

The Python.org website has a wealth of information for the beginner and advance users. The documentation is also available for download in PDF, HTML, LaTeX formats. The Python language installer also installs a basic integrated development environment for you, which makes learning Python very easy.

Conclusion

Learning Python will enable me to use a new and different language on the .Net platform but also learn a language that runs on almost every platform. I am really looking forward to delving into the different programming styles that Python supports. The fact that Python is the first language that Google has introduced with their Google App Engine service is also a plus.

Links


In my next blog on the SEVDNUG ORM shootout series, I am going to show how the LINQ to SQL ORM can be used with a Domain Driven Design (DDD) philosophy. To give people a better understanding of DDD, I decided to group all of my DDD books into this one review. Domain Driven Design is more of a philosophy than a technique or a methodology. It is in this philosophy or understanding that complexity in a computer system is broken down into a model that contains the systems business logic.

Over the last decade or two, a philosophy has developed as an undercurrent in the object community. The premise of Domain-Driven Design is two-fold:
  • For most software projects, the primary focus should be on the domain and domain logic.
  • Complex domain designs should be based on a model.
From: www.domaindrivendesign.org

I have used the DDD techniques found in the books in this review to build systems with some very good success, and that success was dependent on the frequent open communication with the domain experts. If you cannot get a client or organization to agree on open communication with domain experts, then using DDD would be inappropriate and I would look for other, more traditional, techniques like waterfall.


 

Domain Driven Design Tackling Complexity in the Heart of Software

Title: Domain Driven Design
Auther: Eric Evans
Publisher: Addison Wesley
ISBN: 0321125215
Copyright: 2004
Rating: Excellent

If Domain Driven Design were a religion then this would be “The Good Book”. In “Domain-Driven Design Tackling Complexity in the Heart of Software” Eric Evans has distilled his object modeling and development philosophy insight into a readable and readily usable book. I really enjoyed this book and I have read sections of the book many times gaining more insight into the object domain-modeling world each time. If you are going to purchase one book on DDD, then this is the one you should purchase.


 

Applying Domain Driven Design and Patterns with Examples in C#

Title: Applying Domain Driven Design and Patterns
Auther: Jimmy Nilsson
Publisher: Addison Wesley
ISBN: 0321268202
Copyright: 2006
Rating: Great

Jimmy Nilsson has expertly combined Domain Driven Design, Enterprise Application Architecture, Test Driven Development and the C# language into a single approachable text for the .Net Developer. In the book, you will find real world examples that shows how DDD and enterprise architecture combine to develop working and, more importantly, maintainable software. Jimmy has done a tremendous job on “Appling Domain Driven Design and Patterns with Examples in C#.” If you know C#, this book will teach you how to use DDD with enterprise architecture and how to do it correctly.


 

.Net Domain Driven Design with C#

Title: .Net Domain Driven Design with C#
Auther: Tim McCarthy
Publisher: Wrox
ISBN: 9780470147566
Copyright: 2008
Rating: Good

When learning a topic as big as Domain Driven Design (DDD), an example is very helpful and that is what Tim McCarthy has provided in “.Net Domain Driven Design with C#.” The community surrounding the DDD movements has been asking for a more thorough example application using the Domain Driven Design technique. Tim starts from the bottom and in successive chapters builds a DDD inspired application complete with all the major DDD concepts covered. If you need an example application to help you learn DDD, then this book is what you are looking for.

I need to warn readers that this book has a terrible binding and it's printed on toilet paper. I suggest you do not highlight pages in this book because they will bleed through multiple pages. Wrox should upgrade the paper from toilet paper to something above tissue paper!


Mouse != fast

Published 9/15/2007 by Adam Wolf in Craft

Are you a mouse or a hacker? Do you build your project by moving your mouse over to build menu and then select "Build Solution" or do you hit F6 or Ctrl + Shift + B? If you said a mouse, then you might not know how powerful the Visual Studio IDE is and how much faster you can get things done by using keyboard shortcuts. Knowing how to use your tools properly and to their fullest potential is a craftsman’s value that all developers should strive to attain. 

The Visual Studio IDE contains pre configured shortcuts for every common editing and navigation tasks and gives you the ability to create your own keyboard shortcuts. My favorite custom shortcut is mapping Ctrl + Alt + Delete to the "Remove and Sort Using" feature in Visual Studio 2008. This handy shortcut will sort and remove unused "Using" statement from the top of my classes. I love cleaning up my code by using my new shortcut; and it so simple, I just open a file and hit Ctrl + Alt + Delete and my using are clean and necessary.

Lately I have been trying to improve my Visual Studio IDE keyboard skills by learning and using a new keyboard shortcut every week. To facilitate this learning, I purposely put my mouse out of my reach to force myself to use my keyboard shortcut list. This technique has also helped me free-up a great deal of monitor space by removing all of the toolbars (unnecessary if you don’t use the mouse) and minimize most of the tool pallets from my Visual Studio IDE. I have also started using full screen mode {Shift + Alt + Enter} on my 24" dell monitor in portrait mode, can you say joy!

The only problem with this technique is that it does not work well when coding a user interface for my projects, but for code it makes me much faster.

My current shortcut list; and no, I have not mastered them all yet.


Shortcut List

Window Show MDI File List Ctrl+Alt+Down   Solution Explorer Ctrl+W+S
Format Selection Ctrl+K,+F   Class View Ctrl+W+C
Format Document Ctrl+K, D   Server Explorer Ctrl+W+L
Edit Insert Snippet Ctrl+K, X   Properties Window Ctrl+W+P
Edit Surround With Ctrl+K, S   Object Browser Ctrl+W+J
Edit Cycle Clipboard Ring Ctrl+Shift+V   Toolbox Ctrl+W+X
Make Upper Case Ctrl+ Shift+U   Task List Ctrl+W+T
Make Lower Case Ctrl+U   Command Window Ctrl+W+A
Delete Hrzntl White Space Ctrl+K, Ctrl\   Output Ctrl+W+O
View White Space Ctrl+R, Ctrl+W   Immediate Ctrl+Alt+I
Word Wrap Ctrl+R, Ctrl+R   Document Outline Ctrl+Alt+T
      Error List Ctrl+W+E
Project Add Class Shift+Alt+C      
Project Add Existing Shift+Alt+A   Resource View Ctrl+Shift+E
Add New Item Ctrl+Shift+A   Full Screen Shift+Alt+Enter
      Navigate Backwards Ctrl+-
Collapse To Definitions Ctrl+M, Ctrl+O   Navigate Forwards Ctrl++
Find Next F3   New Breakpoint Ctrl+B
Find Ctrl+F   Clear All Breakpoints Ctrl+Shift+F9
Replace Ctrl+H   Breakpoints Ctrl+Alt+B
Incremental Search Ctrl+I   Insert Breakpoint F9
Find in Files Ctrl+Shift+F      
Replace in Files Ctrl+Shift+H   Toggle Bookmark Ctrl+K, Ctrl+K
Find Symbol Alt+F12   Next Bookmark Ctrl+K, Ctrl+N
Find Symbol Result Ctrl+Alt+F12   Previous Bookmark Ctrl+K, Ctrl+P
Clear Bookmark Ctrl+K, Ctrl+L      
Add Task List Shortcuts Ctrl+K, Ctrl+H   Toggle Outlining Expansion Ctrl+M, Ctrl+M
IntelliSense Ctrl+J   Toggle All Outlining Ctrl+M, Ctrl+L
List Members Ctrl+K+P   Stop Outlining Ctrl+M, Ctrl+P
Parameter Info Ctrl+K;   Collapse To Definitions Ctrl+M, Ctrl+O
Quick Info Ctrl+I      
Window Close-Document Ctrl + F4      
Code F7      


XML Comments

Published 1/22/2007 by Adam Wolf in Craft

When building applications, one of my normal coding practices is to add XML comments to all publicly assessable types and members. This practice has two major benefits: it enables me to add some substance to Visual Studio’s IntelliSense and allows me to generate API documentation at the same time.

To assist developers, the IntelliSense List Members, Parameter Info and Quick Info features use the XML documentation comments to add tool tip hints for each type and type members. These tool tip hints in IntelliSense help me, and more importantly, future developers use these types and type members in my API’s.

Generating API documentation from the XML comments is relatively painless because Visual Studio has an optional setting that when enabled will produce a XML extract file as part of the build process. With this XML extract and some extensible stylesheet work, I can produce API documentation with little or no effort.

Microsoft Comment Tags

This is a list of the available tags that Microsoft has defined for use in the XML comment.


 
    /// <summary> - A summary of the object
    /// <remarks> - Supplemental information
    /// <example> - An example of using a member
    /// <param> - A method parameter
    /// <returns> - Return value of a method 
    /// <exception> - Specifies an exception that can be thrown  by the current member 
    /// <exception cref="System.Exception">Thrown when....</exception>
    /// <value> - The value of a property 
    /// <list> - 
    /// <list type="bullet"|"number"|"table"> The heading row of a list
    /// <listheader>
    /// <term>term</term>
    /// <description>description</description>
    /// </listheader>
    /// <item>
    /// <term>term</term>
    /// <description>description</description>
    /// </item>
    /// </list>
    /// <para> - A paragraph of text 
    /// <c> - Embedded code font in other text 
    /// <code> - Multiple lines of source code
    /// <paramref> - A reference to a parameter in other text 
    /// <permission> - The security permission required by a member    
    /// <see> - An embedded cross-reference to another member 
    /// <seealso> - A reference in a See Also list.
 

Microsoft has defined these common XML tags but they are not the only tags allowed in the comments sections. You can add your own well formed XML tags to this section and they will be extracted to the same file with the other tags. This is very helpful if you have some special need from a client, like adding the authors name to each class or update history of the class. I would much rather use source control for update history but some clients like this information close to the code.

Tags Matrix

This tags matrix shows what tags are available for use on types and members.

Tag Top Level In Line   Class Struct Interface Enum Delegate Field Constant Property Method Event Operator
<c>   X   X X X X X X X X X X X
<code>                     X X X X
<event> X                     X   X
<example> X     X X X X X X X X X X X
<exception> X                   X X X X
<include> X     X X X X X X X X X X X
<list>   X   X X X X X X X X X X X
<para>   X                        
<param> X             X     X X    
<paramref>   X   X X X X X X X X X X X
<permission> X               X X X X X X
<remarks> X     X X X X X X X X X X X
<returns> X                     X    
<see> X X   X X X X X X X X X X X
<seealso> X X   X X X X X X X X X X X
<summary> X     X X X X X X X X X X X
<typeparam> X                     X    
<typeparmref>   X                   X    
<value> X                   X      

Getting Some Help

One of my favorite additions to the Visual Studio IDE is Roland Weigelt's Ghost Doc. It is a helper Addin to Visual Studio that aids me in the task of documenting my code by intelligently guesses the meaning of member names and variables and then it emits the generated comment to the proper place in the file. You will have to edit the comments but it does give you a nice place to start.

Before GhostDoc

public int GetEmployeeWorkingHours(Employee employee, DateTime workWeekStartDate)
{
     return 40;
}

After GhostDoc

/// <summary>
/// Gets the employee working hours.
/// </summary>
/// <param name="employee">The employee.</param>
/// <param name="workWeekstartDate">The work week start date.</param>
/// <returns></returns>
public int GetEmployeeWorkingHours(Employee employee, DateTime workWeekStartDate)
{
     return 40;
}

Conclusion

With the XML commenting and extracting feature of Visual Studio and the use of tools like Ghost Doc and XSL, creating API documentation is simple and easy. The process of generating documentation from comments has been helped by products like Sandcastle from Microsoft and NDoc from the open source world. Unfortunately, the NDoc development has been halted and I have not heard of the development starting back up. I have had some good result from using Doxygen. This open license product will generate documentation from your project files and creates some nice graphs for type dependencies.

Links


Be Assertive

Published 5/10/2006 by Adam Wolf in Craft

Hopefully you are familiar with one of the best proactive programming tools in your debugging toolbox, the Debug.Assert(). Not only do I hope that you know what an assertion is, but that you use them liberally in your code as a professional best practice.

If you’re not familiar with one of my favorite tools, then here is a brief definition. Assertions from the System.Diagnostics namespace are methods that are only available in debug builds that check whether a certain condition is true in your code. Because the assertions are removed in production builds automatically by the compiler, they should always be used in conjunction with your normal error checking.

Assert statements are a developers best defense against other code modules, yourself and anyone else who uses your code, by defining statements that check whether the state of information in their running program is correct or within an acceptable range. In a running application, the assert statements will halt the application when the assert statement is evaluated to false, and, will then notify you as to where the assert failed and not let your application continue, unless you choose to ignore the failed assertion. Assertions speed debugging by focusing your effort on the failed assumption and not make you back track from a thrown exception up the stack to the source of the problem.

Benefits

  • Early notification of assumptions not being met prior to a thrown exception
  • Defends your code from inappropriate or incorrect input from other modules.
  • Asserts add additional documentation to the code and explains the codes intent by describing what values are acceptable to other developers.
  • In debug builds, assertions are preserved and are remove from compiled production builds automatically.
  • The assert statement, when triggered, will stop the execution of your code and preserve the applications state even if you are not in a debugger, like when your application is tested in QA or by your manager.

How and What

  • Always assert data that comes from outside of your API or code. The property setters and method parameters are the prime candidates for using assert statements.
  • Assertions should be read only, they should not modify application state or variables in any way. Your asserts will not be compiled in production builds so if you rely on asserts to change state you will not see this happen in production builds.
  • Assertions should be simple and check one thing and one thing only. That way, when the assertion is triggered, you will know exactly what assertion is invalid.
  • Use the two parameter assert statement Debug,Assert(bool, string) with the second parameter being a string representation of the actual condition statement. Debug.Assert(1>0, “1>0”);
  • Be thorough and completely check method parameters and property setters.
  • Make assertions about the values returned from an external API are within the expected ranges.
  • Enable tracing to get assert message output in your code.
  • Use conditional compilation and compiler switches to assert complex assumptions.

Conclusion

With all of the benefits of assertions, I always find developers that do not see the benefits of assertions, and complain that they are a nuisance and clutter the application with unecessary code blocks. I personally like having a tool that tells me when something is wrong, speeds up my debugging time, and melts away when not needed for production builds. My suggestions to .Net developers is to be assertive in your code.

Links


Adam J Wolf

The Intersection of the Arts and Crafts Esthetic and Programming