SAF(NET) = STEPHEN A. FUQUA operating on the Web since 1995

Stephen is a web developer, Bahá'í, and interfaith activist in St. Paul, Minnesota. He likes to write about religion, social justice, sustainability, science, programming, &c.

June 20, 2009

Think For One ... Second

What’s wrong with this code? There are unnecessary lines. So? Why care about unnecessary lines? Because it shows that the programmer was not really thinking about what he was doing.

        MyObject obj = someList.Find(delegate(MyObject test)
        {
            if (test.Id.Equals(packageId))
            {
                return true;
            }
            else
            {
                return false;
            }
        });

We always need to be thinking carefully about even little things like this, if we want to produce quality code. Thankfully in the sense that I mean “thinking carefully” it is something we can develop into habits, rather than having to stop and consciously think carefully :-). One way to write this more simply:

        MyObject obj = someList.Find(delegate(MyObject test)
        {
            return test.Id.Equals(packageId);
        });

TrackBack

Comments

Post a comment

Remember personal info?




deprecated

On safnet.com

Other sites managed or developed by S.A.F.

S.A.F. elsewhere on the web

  • LinkedIn
    LinkedIn can actually be useful when looking for prospective hires and business or organizational partners
  • GoodReads
    A fun and relatively-unknown social networking site geared towards one's book list
  • Live Journal
    Mirror of the blog at safnet.com, so that a few LJ friends can more easily read and comment there