Skip to content

Instantly share code, notes, and snippets.

@anelson
Created August 31, 2010 10:24
Show Gist options
  • Save anelson/558842 to your computer and use it in GitHub Desktop.
Save anelson/558842 to your computer and use it in GitHub Desktop.
Methods vs Properties, Kyiv 2010
public class UserManager {
// This property is doing WAY too much work to be a property
public string[] Users {
get {
var usersList = new List<string>();
using (var connection = ConnectToDatabase()) {
var users = connection.GetUsersTable();
users.Rows.ForEach((row) => usersList.Add(row.UserName));
}
return usersList.ToArray();
}
}
// This method doesn't do anything; it just wraps a field.
public string GetCurrentUserName() {
return _userName;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment