Sgt. Conker We are "absolutely fine"

29Sep/090

The Week in Code (XIV)

No sponsor, no additional comments, no nothing to see here. Please move on :)

15Sep/090

Bnoerj.NamingConventions

// Namespaces are PascalCased
namespace Bnoerj.NamingConventions
{
    // Using statements are inside namespace declarations
    using System;

    // Enums are PascalCased and singular
    public enum Alignment
    {
        // Enum members are PascalCased
        Top,
        TopRight,
        Right,
        BottomRight
        Bottom,
        BottomLeft,
        Left,
        TopLeft,
    }

    // Flag enums are PascalCased and plural
    [Flags]
    public enum Alignments
    {
        // Enum members are PascalCased
        None = 0x00,
        Top = 0x01,
        Right = 0x02,
        Bottom = 0x04,
        Left = 0x08,
    }

    // Class names are PascalCased
    public class ThisIsAClass
    {
        // Members are grouped by type:
        // * Types (nested classes, enums, structures)
        // * Fields
        // * Constructors
        // * Properties
        // * Methods
        //
        // Within these groups the elements are ordered by accessibility,
        // from public to private:
        // * public
        // * internal
        // * internal protected
        // * protected
        // * private
        // Nested classes are PascalCased
        class NestedClass : IDisposable
        {
            public void Dispose()
            {
                throw new NotImplementedException();
            }
        }

        // Publc Fields and constants are PascalCased
        public const float ABitOfPi = 3.14f;

        // Fields are camelCased
        // NOTE: C# type aliases are used
        internal string internalField;

        // Fields are camelCased
        protected int protectedField;

        // Fields are camelCased
        // NOTE: private accessibility modifier is omitted
        // NOTE: C# type aliases are used
        readonly object privateMember;

        // Properties are PascalCased
        // NOTE: Acronyms longer than 2 characters are PascalCased (e.g.
        // Html, Xml)
        public int HtmlLength { get; set; }

        // Properties are PascalCased
        // NOTE: Acronyms of 2 characters are UPPERCASED (e.g. UI, IO)
        internal string UIElementName { get; } 

        // Properties are PascalCased
        protected string ProtectedProperty { get; } 

        // Properties are PascalCased
        // NOTE: private accessibility modifier is omitted
        string PrivateProperty { get; } 

        // Methods are PascalCased
        // NOTE: private accessibility modifier is omitted
        public int Add(int oneValue, int anotherValue)
        {
            // local variables are camelCased
            double result = oneValue * anotherValue;
            return result;
        }

        // Methods are PascalCased
        // NOTE: Abbreviations are not treated as Acronyms (so
        // _Id_entification is Id, not ID).
        protected void AlignObjectById(string id, Alignment alignment)
        {
            throw new NotImplementedException();
        }
    }
}
}

Idea by the Joy of Code.

14Sep/090

The Week in Code (XII)

This is the plain .NET and no XNA Framework special edition.

This post is sponsored by Reflective Perspective: The caffeine fueled thoughts of a UK Software Developer and home of “The Morning Brew”.

8Sep/090

The Week in Code (XI)

  • Cross Platform XNA Projects (X64 Content) John Sedlak (AKA the reason behind of the decline of Ziggyware) shows how to enable x64 compilation targets for XNA FX Windows game library projects; note: it will not magically allow you to build x64 games with the XNA FX (as John himself mentions at the end of the post)
  • K.I.S.S – Fading between images with XNA Conkerjo (now on a shiny, new domain) shares his code to fade between two images, sprite batch style. Someone might claim using a shader, taking two textures as input might be better but that wouldn’t fit the K.I.S.S. moniker well…
  • Realistic Soft Edged Water In XNA The first article on XTaticware deals with the challenges of rendering realistic still water bodies in an efficient way
  • Quick and Dirty Screenshots in PC Games Nick “fanboi” Gravelyn dumps his code to take screenshots of Windows games – Hm, I toyed around with the EndDraw approach to do video dumps once, maybe I should get that into a sharable state…

This post is sponsored by XTaticware, the non profit venture to provide an alternative source of C#/XNA information.