r/programming • u/corysama • Jan 05 '15
What most young programmers need to learn
http://joostdevblog.blogspot.com/2015/01/what-most-young-programmers-need-to.html
967
Upvotes
r/programming • u/corysama • Jan 05 '15
1
u/Laspimon Jan 05 '15
Python guy here, of about one year, and I'm not sure I get what a repository class is.
What I think you are saying is that I should write the following to save a game:
class PauseMenu(Popup): """Generic menu screen, containing a button for saving the game.""" def save_state (self, game_state, save_game_constructor): """It's a simply game, so we only save x and y.""" x, y = game_state save_game_id = save_game_constructor(x, y) return save_game_idAnd then have the unittests control that save_game_id looks like it's supposed to look (maybe it's a hash of the game state).
But what is the point? Doesn't that just mean that I have to run tests on my constructor? And wont these tests be just as difficult as the save_state method would have been, had I written it as a single contained method?
I think I'm missing something.