29Sep/090
The Week in Code (XIV)
- Anaglyph Stereoscopic Rendering in First Person Renaud Bédard shares his code for anaglyph stereoscopic rendering
- Shapes, the 2D geometry and collision library, is available from CodePlex now
- How Are Methods Compiled Just-In-Time and Only Then? Sasha Goldshtein examines how and when methods are JITted
- String interning and String.Empty Eric Lippert on strings and how they are handled in the .NET runtime. The notes in the last 3 paragraphs about possible optimizations by using String.Intern is interesting…
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.
- .NET Naming Conventions Josh Twist shares his coding style by example (note: I do not like his style much but the idea of using a simple code example to visualize the style).
- Should We Change the Way We Name Interfaces in .NET? Russell Ball about dropping the I of the interface names and annotate the implementations with an Impl suffix instead. The first two comments pretty much sum up my current thoughts on this.
- It's Generic, not Multipurpose Sergio Pereira looks at some possible misuses of Generics in APIs where strings or type objects may be better suited – e.g. something I may be held guilty off, too…
- First videos of the structured editor prototype Kirill Osenkov shows off some videos of his structured editor prototype, which seems to be something nice for scripting IDEs…
- Thread Synchronization in .NET Ricardo Peres takes a look at the variety of means of synchronization available in .NET for different types of synchronization.
- Generic constraints for enums and delegates Jon Skeet explores the possibility of applying generic constraints to enums and delegates in the CLI and presents a prototype of his experiments.
- K.I.S.S. - C# Properties conkerjo discusses C# auto properties.
- Integration Tests Are a Scam presentation about things commonly tested via integration tests can be better verified through more isolated unit tests.
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.