DEV Community

Discussion on: Tackling a Problem From a Beginner's Perspective

Collapse
 
rduggan profile image
Robert Duggan

Oh no, I really appreciate the feedback! It's nice to get the perspective of someone who currently does this stuff for a living.

I'm checking that stackoverflow out now.

Collapse
 
deciduously profile image
Ben Lovy

I've only been a "real" programmer for a few months ;). People who write programs that work are real programmers.

Thread Thread
 
rduggan profile image
Robert Duggan

Hey, I'm not expecting to spend a whole lot more time on this exercise, however I can't help thinking about ways to improve it...

What if I used a class to handle the players? (I'm at my actual day job right now, so I can't look at it) The problem I see is how to handle instantiating some random amount of players? If you look at the code I have now I'm handling it with dictionaries, which I think is a good method, however could I do the same type of thing for classes?

Thread Thread
 
deciduously profile image
Ben Lovy

Definitely! I think that's a good idea. You can have an overarching Game class that maintains a list of players and the list of cards, and ask for how many players to create in the constructor. Then, each player can be a Player instance, you can have a CardDeck, and a Card...I think classes and objects are really useful for organizing your code as it gets bigger. You can keep most of the same actual logic, it just provides a convenient, readable structure.