Created
September 6, 2013 12:19
-
-
Save anonymous/6463033 to your computer and use it in GitHub Desktop.
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
private static LeaderboardName getLeaderboardName( | |
Kind kind, LeaderboardKind lbKind | |
) { | |
var kg = kind as Kind.Global; | |
if (kg != null) | |
return new LeaderboardName( | |
string.Format("lb_{0}", leaderboardKindToString(lbKind)), lbKind | |
); | |
var kw = kind as Kind.World; | |
if (kw != null) | |
return new LeaderboardName( | |
string.Format("lb_w{0}_{1}", kw.world, leaderboardKindToString(lbKind)), | |
lbKind | |
); | |
var kl = kind as Kind.Level; | |
if (kl != null) | |
return new LeaderboardName( | |
string.Format( | |
"lb_w{0}_l{1}{2}_{3}", kl.world, kl.level, kl.bonus ? "b" : "", | |
leaderboardKindToString(lbKind) | |
), lbKind | |
); | |
throw new Exception("Unknown kind " + kind); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Once again, very strange code, clearly not in C#-way.
So, you want to get leaderboard name from some object that is of class Kind. But why the hell do you create a separate static method for that? A clear and pretty simple objected-oriented approach would be to create an abstract method in Kind and to define it in it's children.
Are there any downfalls to this traditional OOP way of doing things that I don't see?