Want to follow this site? Here's the RSS feed.

NetFXHarmonics Code Annotation Format

Friday, April 24, 2009

If you look at any of my open-source projects or even the Themelia source code, you will see that I use a special type of coding annotation.  The annotation format I designed (based on the designs of Sky Morey at Digital Evolution Group) is intended to maximize code readability and understandability.  The format is NOT a coding standard, but just what it says: an annotation format.

What’s that means?  Essentially when you are reading code you are constantly parsing all the symbols that you see.  Your brain can only work so fast, though, and some things have a higher parsing latency than others.  For example, VB code is incredibly verbose and uses long symbols to representing even the smallest things.  It will use the symbol “Then” where C# will use the symbol “}” (to some it may seem odd to think of a word as a symbol, but that’s all it is—you never read ever letter of a word you know.  If you know the word, your brain treats it as a symbol, not a series of symbols.)  It will also use two different character sets (what we call upper case and lower case) interchangeably, thus ever increasing the latency.  Though C# was designed with extremely low latency in mind, it, like all other languages, still has excess latency.

Thus, my code annotation format comes on the scene to make mental code parsing extremely fast.  It covers everything from how to case comments, when NOT to write comments, when to add metadata to class members, and how to deal with line breaks (the cardinal rule of the format!)  Most importantly, every annotation rule has an extensive commentary explaining why the rule exists and what value it provides in the long run.

Now, as with ALL THINGS EVERYWHERE, when you first start to apply it, it’s going to seem odd and it will slow you down at first.  After time, however, you will become extremely efficient at it and your code readability should dramatically improve.  When this is used in groups, it should seriously lower decrease the time it takes to read and understand the purpose of code.

You can view the NetFXHarmonics Code Annotation Format at http://www.netfxharmonics.com/document/code/format.

New Silverlight 3 Features

Monday, April 20, 2009

Though I’m a member of the Silverlight 3 Early Adopter’s Program (and thus have been getting weekly builds of Silverlight long before the public beta), I’m probably not going to be writing anything about the new features.  This isn’t because Silverlight 3 is boring, but, rather, because I have a strict policy of never doing something that other’s are already doing.  So, I would like to direct your attention to a few web sites showing the awesome provided by Silverlight 3 (and you won’t find business-application boringness here).

First, Tim Huerer has a nice post giving a very quick rundown of the new features:

Second, Jeff Prosise’s blog shows some of the cooler features of Silverlight 3.  Maybe it’s just because I absolutely HATE business application development, but I find Jeff’s blog to be 100x more interesting than the “how to write use X to write your boring line-of-business application.”  His work is also not for the naive or faint of heart.  Instead, it’s for professional developers (i.e. the extremely rare people who aren’t afraid to do things the right way.)  If Jeff adds more stuff, I’ll add them to this list.

Finally, you can always head over to the Mix ‘09 web site and watch some Silverlight 3 (and 2) videos.  Most of them also have PowerPoint files associated with them.  Personally, I can’t stand the torture of listening to someone take 30 minutes to say something that I can ready in 3 minutes.  That’s one reason I turned Microsoft down when they asked me to turn my Understanding WCF Services in Silverlight 2 into a talk at Mix.  Boring.  Here’s the Mix link:

Jeff Prosise’s Silverlight Tips

Friday, April 10, 2009

This post may be completely meaningless to most of the developers out there as it deals with my type of development: non-business application development.  More specifically, Jeff Prosise of Wintellect (the Navy SEALs of .NET) has posted a few really nice tips and tricks for Silverlight development.  These are really great tricks that serve as great examples of some of the more powerful things you can do with Silverlight:

Links

CitationAttribute for Citing Work

Saturday, April 4, 2009

As a researcher, designer, and open-source developer, it's very important to me to both cite the work I reference as well as to be cited appropriately.  Few things are more lame than finding my research some place on CodePlex disguised work different working under someone else's name... or a file from one of my many open-source systems in someone else's project without my copyright information.

To help me keep track of where a file or piece of research came from, I wrote a quick attribute to help keep some of this metadata around: CitationAttribute.  This is in my Themelia Framework and I use it extensively in my projects to keep track of where research and files came from.  Below is an example of how to use the attribute.  Fritz Onion was kind enough to allow me to include his ViewState parser in my work.  Notice the metadata in the attribute:

[Citation("http://www.pluralsight.com/fritz/", Copyright = "Copyright (c) 2008 Fritz Onion", DateUpdated = "03/25/2008")]
public static class ViewStateXmlBuilder
{
    //+ implementation here
}

Here you can see that the reference source is cited as well as the copyright and date the local file was updated with the appropriate version.  Note that this does not replace a file copyright.  I asked Fritz for a complete copyright comment block and he provided that for me.  Above the actual file I include with my Themelia Framework is his actual C# comment stating his actual copyright/disclaimer.

Here's the CitationAttribute as seen in my Themelia Framework:

#region Copyright
//+ Themelia Framework 2.0 - Core Module
//+ Copyright © Jampad Technology, Inc. 2007-2009
//+
//+ This file is a part of the Themelia Framework.
//+ The use and distribution terms for this software are covered by the
//+ Microsoft Permissive License (Ms-PL) which can be found at
//+ http://www.microsoft.com/opensource/licenses.mspx.
#endregion
using System;
//+
namespace Themelia
{
    /// <summary>
    /// Used to signify that a particular type was pulled from a third part project or piece of research.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
    public class CitationAttribute : Attribute
    {
        private readonly String _source;

        //+
        //- @Copyright -//
        /// <summary>
        /// Represents the copyright of the referenced entity.
        /// </summary>
        public String Copyright { get; set; }

        //- @DateUpdated -//
        /// <summary>
        /// Represents the date the local version was updated with the referenced entity.
        /// </summary>
        public String DateUpdated { get; set; }

        //- @DateUpdated -//
        /// <summary>
        /// Represents the 2 (i.e. "en") or 5 (i.e. "en-US") character culture used to format the date (default = en-US)
        /// </summary>
        public String DateCulture { get; set; }

        //- @License -//
        /// <summary>
        /// Represents the license associated with this file (e.g. BSD, MIT, LGPL, Public Domain; default = Custom). This property is not legally binding.  It should only be used as a means of finding the general direction of where to look for the legally binding license.
        /// </summary>
        public String License { get; set; }

        //+
        //- @Ctor -//
        public CitationAttribute(String Source)
        {
            _source = Source;
            //+
            DateCulture = "en-US";
            License = "Custom";
        }
    }
}

There are a few things to notice about this attribute.  First, there is also a property for DateCulture.  This is very important.  Depending on your culture 05 03 2009 or 03 05 2009 may be March 5th.  Second, there's a License property.  In this example, it's "Custom".  As another example, if you were to cite Themelia, you would use "Ms-PL" as your License.  Third, the source is required.  It's not that it absolutely has to be a URL, but it's definitely required nonetheless.

Where should you use this file?  Anywhere you cite someone's research, where you use someone's file, or derive from their work.  This doesn't mean only in places where you copy/paste a class from another person's framework.  This also means in places where you find an article online and you use the research in that article to write your own class.

For example, if you were looking online for a solution to create a solution for getting Silverlight to access the clipboard (the mother of all security breaches, but whatever!) and you find a blog post about that, then when you write your classes to use that, you need to cite the blog post.  If you don't, then you are depriving a future developer from seeing the commentary of that code.  By citing the research with the attribute, you are telling the future reader where to see the research.  In the case of using a someone else's files, the attribute will tell future developer's (and you) where to find the updated version.

Creative Commons License
This work is licensed under a Creative Commons Attribution 2.5 License.

Built on Themelia Pro 2.0

Mini-icons are part of the Silk Icons set of icons at famfamfam.com