Created
August 31, 2010 10:24
-
-
Save anelson/558842 to your computer and use it in GitHub Desktop.
Methods vs Properties, Kyiv 2010
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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