ChallengeWrite the check in comment

time to read 2 min | 291 words

In my code base, I have the following commit, which doesn’t have a checkin comment. This is the before:

private Entry GetEntryForSlug(string slug)
var entry = session.CreateCriteria(typeof(Entry))
.Add(Restrictions.Like("Slug", slug))

if(entry != null)
return entry;

//try load default document
return session.CreateCriteria(typeof (Entry))
.Add(Restrictions.Like("Slug", slug + "/default"))

And this is the after:

private Entry GetEntryForSlug(string slug)
var entries = session.CreateCriteria(typeof(Entry))
Restrictions.Like("Slug", slug) ||
Restrictions.Like("Slug", slug + "/default")

return entries
.OrderBy(x => x.Slug.Length)

What was the silent committer thinking about when he made the change? Can you write the check in comment?

More posts in "Challenge" series:

  1. (03 Jan 2020) Spot the bug in the stream–answer
  2. (15 Feb 2010) Where is the optimization?