Experimentation

Posted by Mr. Nuggets on Tuesday, June 16, 2009 , under | comments (0)



Folks, since I'm not really blogging here right now....and I have another blogspot blog that is in desperate need of a makeover. I am going to experiment with that make over here.

Just to let you know!

Quick List of Some Blog Entries Comparing .NET Webforms to .NET MVC

Posted by Mr. Nuggets on Thursday, February 5, 2009 , under , , , , , | comments (0)



Pardon me: this is a quick and dirty blog entry to help out some fellow advocates. :D

There are a few others, but they essentially say the same things as the above.

I prefer MVC mainly due to fine-grained control over html, TDD, no viewstate, TDD, separation of concerns, TDD, SEO & REST, TDD, no postback, TDD, follows stateless nature of the web, TDD.

And also because it lends itself so nicely to TDD.

If I can find time in my increasingly jam-packed day job schedule, I hope to elucidate the discussion we are having there. I’m finding that even with the advantages of TDD, Separation of Concerns, REST, etc., getting diehard Webforms guys - who haven’t been steeped in, at a minimum, the value of TDD – to take on the MVC learning curve is a bit of a challenge. Some embrace it, some don’t.

How to Configure Selenium RC for Use In C# NUnit Tests

Posted by Mr. Nuggets on Tuesday, February 3, 2009 , under , , , , , | comments (0)



Please visit my blog at Los Techies for this post. I have moved a number of my posts over there since having been asked to join their blog roll. Thank you!

Use of Predicate On a C# Generic List – Or Not

Posted by Mr. Nuggets on Friday, January 23, 2009 , under , | comments (0)



I ran across a predicament today that, after mucking about for a while, figured there had to be a simple solution to.  I had two classes, each subclassing an abstract class.  Instances of each of these classes were then loaded in a List<T> and I was tasked with finding certain types of items in that list.

DISCLAIMER: this code is NOT production code and there are probably other better ways to accomplish the same thing (such as how to handle role types).  But, for simplicity and (hopefully) readability, hang with me for purposes of this example, if you don’t mind.

So, let’s take a user object, throw a few different roles on him and make sure he’s still a happy camper after he gets to go do something fun.

Here are the roles:

public abstract class UserRole
{
    protected int roleId;
    protected string roleName;
    public UserRole() { }
    public UserRole(int roleId, string roleName)
    {
        this.roleId = roleId;
        this.roleName = roleName;
    }
    public virtual int RoleID {
        get {return roleId;}
        set{ roleId = value;}
    }
    public virtual string RoleName {
        get { return roleName; }
        set { roleName = value; } }
    }
  }

    public class OtherSystemRole : UserRole
    {
        public OtherSystemRole(int roleType, string roleName) : base(roleType, roleName) { }
    }

   
    public class HappyEmployeeRole : UserRole
    {
        public HappyEmployeeRole()
        {
            roleId = 5;
            roleName = "Smiley Head";
       }
    }

…and the user:

public class DaUser
{
    private List<UserRole> roles = new List<UserRole>();
    public virtual List<UserRole> Roles
    {
        get { return roles; }
        set { roles = value; }
    }

    public void GoSomeplaceCoolLikeCaboOrSomething()
    {
       if (ScubaDiving().Surfing().DrinkingHeavily().
           LevelingNewMainToEightyInWorldOfWarcraft().
           AreSuccessful())
        {
            Roles.Add(new OtherSystemRole(1, "Pownage King"));
        }
    }
}

Now, I wrote the test first, but post it last here because that is where I used the predicate:

[Test]
public void verify_an_employee_remains_a_valued_employee_after_going_somewhere_cool()
{
    DaUser daUser = new DaUser();
    daUser.Roles.Add(new OtherSystemRole(1, "Regular Bub"));
    daUser.Roles.Add(new HappyEmployeeRole());
    daUser.GoSomeplaceCoolLikeCaboOrSomething();

    Predicate<UserRole> happyEmployeeRole = IsHappyEmployeeRole;

    Assert.That(daUser.Roles.Exists(happyEmployeeRole),  Is.EqualTo(true));
}

  private bool IsHappyEmployeeRole(UserRole role)
   {
      return role.RoleName.Equals("Smiley Head");
  }

This allowed me to handle instances in which I needed to make sure a certain type of role is/is not added to the roles list without having to do some major refactoring.

On the other hand, Jason Meridth pointed out to me that you could substitute the following for the entire predicate thing:

Assert.That(daUser.Roles.Exists(role => role.RoleName.Equals("Smiley Head")), Is.True);

Several things: 

  1. The lamba works great. 
  2. So, that might be the way to go unless you’re working in older versions of the .NET framework.
  3. Guess I better get off my arse, and really learn lamdas.

Seriously, thanks to Jason for the input.

For a succinct read on the mechanics of predicates, check out Jeremy Kyne's Blog Entry on Generic Collections.

Conclusion - A Response to “Traps & Pitfalls of Agile Development – A Non-Contrarian View”

Posted by Mr. Nuggets on Friday, January 16, 2009 , under , , , | comments (0)



I have moved this post, as well as a number of others to http://agilecruz.lostechies.com/. Please visit the Los Techies blog for these and quite a few more informative entries. :D

Part Five - A Response to “Traps & Pitfalls of Agile Development – A Non-Contrarian View”




I have moved this post, as well as a number of others to http://agilecruz.lostechies.com/. Please visit the Los Techies blog for these and quite a few more informative entries. :D

Quotes That Are Speaking to Me Today

Posted by Mr. Nuggets on Thursday, January 15, 2009 , under | comments (0)



“A morning-glory at my window satisfies me more than the metaphysics of books.”

--Walt Whitman

“Seven blunders of the world that lead to violence: wealth without work, pleasure without conscience, knowledge without character, commerce without morality, science without humanity, worship without sacrifice, politics without principle.”

-- Mahatma Gandhi

“Education is not the filling of a pail, but the lighting of a fire.”

-- William Butler Yeats

“Three things in human life are important. The first is to be kind. The second is to be kind. And the third is to be kind.” 

--Henry James

Just thought this was cool:

“Do not meddle in the affairs of wizards, for they are subtle and quick to anger.”

--J. R. R. Tolkien

My Current All-Time Favorite:

“I tell you, we are here on Earth to fart around, and don't let anybody tell you different.”

-- Kurt Vonnegut