.NET Triplet and Pair classes… and a lesson in lousy namespacing.

 

This week I was working on a project and came across a class I’d never used in C# called a Triplet. You can look up the Triplet on MSDN here.

The Triplet is just a class with three properties: First, Second, and Third. Each of the properties holds an instance of an object. That’s it. That’s all this thing does. The very first thing I noticed once I saw what it did was the namespace it’s in. You’d think it would be in System.Collections, or System.Collections.Specialized or something, but no… it’s it System.Web.UI along with things like the System.Web.UI.Control class. WTFBBQ?

I would love to hear a rational explanation for this. I am pretty anal about namespacing and I don’t like having to stretch the tasteful bounds of a namespace to put something in. I will on occasion, but this is a bit much.

I downloaded Reflector to see if I could find any other gems stored in that namespace. Lo and behold… I find Pair. Care to guess what Pair is? Exactly.. it’s the same as Triplet… but with…. TWO properties.

Upon obsessing over this I started to think about why these classes even exist at all.  What is wrong with object[] objArray = new object[2]; ? Is that so complicated that there needs to be a type, and a horribly misplaced type at that?

In lieu of my findings I have created the following class I want added to the .NET Framework …. The Duodecuple.

 
using System;


//  Stay consistent with completely nonsensical namespacing
namespace System.Workflow.Runtime.DebugEngine
{
            // that’s "12" for those of you who don't feel like going to wikipedia
            public class Duodecuple
            {
                        public object First { get; set; }
                        public object Second { get; set; }
                        public object Third { get; set; }
                        public object Fourth { get; set; }
                        public object Fifth { get; set; }
                        public object Sixth { get; set; }
                        public object Seventh { get; set; }
                        public object Eighth { get; set; }
                        public object Ninth { get; set; }
                        public object Tenth { get; set; }
                        public object Eleventh { get; set; }
                        public object Twelfth { get; set; }
 
                        /// <summary>
                        /// Constructor. Since we're taling C# 3.5+ here you can just
                        /// instantiate with ... new Duodecuple { First = whatever, Second = anotherObject };
                        /// No sense in having all those constructors
                        /// </summary>
                        public Duodecuple (){}
            }
}
  

You're welcome.

-Mike

 


Posted by: Jerzakie
Posted on: 2/20/2010 at 11:16 AM
Tags: , , ,
Categories: .NET | Complaining | Development
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (1) | Post RSSRSS comment feed

SweetLIB is LIVE!

I've finally uploaded SweetLIB.

You can go view the project here (http://sweetlib.codeplex.com/).

SweetLIB is a library I've had for probably 3 years but never really had the balls to publish. I've done a lot to it.

The Major Features:

  • ADO Wrapper and Factory (helps make apps db agnostic)
  • Helpers for
    • Regex validation of data (zip codes, credit cards, email addys, etc)
    • Finding controls in control trees
    • Finding nodes in Tree controls
  • Object Validation classes
  • Web page error handling with base classes

If you use it, let me know what you think. There is an included web project that serves as documentation right now, but it's not all that great.


Posted by: Jerzakie
Posted on: 9/19/2009 at 12:27 PM
Tags: , , ,
Categories: Development | OOP | Techie
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (1) | Post RSSRSS comment feed

iPhone Development - Very Discouraging.

I started an iPhone app about 3 weeks ago in the hopes to learn Objective C, keep myself somewhat involved in the actual act of programming, and make a little extra scratch to pay for the monthly cost of this thing.

I came up with this sweet idea. I decided I would do a calculator, but not just a regular calculator. Mine would have the ability to save the calculated result with a note, AS WELL as the ability to save to "formula" (and I use that term loosely) with a single variable in it.

So I learned Obj-C well enough to write the basic calculator. Lemme tell you, the workflow of a calculator isn't as simple as you'd think. Moving on...

So I got the basic calculator working and it was nice. Mine had a few options that the basic iPhone calc didn't, such as % and √. I figured I could sell that basic calc for maybe $1 or just plop it out there for free. Then I am reading reviews for another calc by the same guy who wrote I Am Rich, and a user mentions turning the iPhone calc sideways and it's a scientific.... WTF?! So I did... lo and behold.. it's got like.. a hozillion options... pretty discouraging

*sigh*

So I take 3-4 days off before I finish the other options. Tonight I was going to get back on track and finish that thing before Christmas.

So tonight I find ThinkDigits.   It's pretty much what I was going to do... only a lot prettier. So.. now.. here I sit gazing over my other ideas ... 50% of which already exist.

Wow.. very discouraging. At least I am more smarterer now.

Posted by: Jerzakie
Posted on: 12/14/2008 at 9:24 PM
Tags: , ,
Categories: Apple | Development | iPhone
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (1) | Post RSSRSS comment feed