Aug-11-2021, 09:02 PM
(Aug-10-2021, 08:18 PM)deanhystad Wrote: I understand the concern. By using lots of attributes in an object that was passed in as an argument your updatevalue method becomes strongly tied to the design of the cards class. This is not good for long term maintenance and it limits the usefulness of the function.
I don't think your problem is with using attributes of a class. I think updatevalue is poorly designed. A key tenet of software design is that each function has a well defined purpose. What is the purpose of updatevalue? Can you describe it in one or two short sentences?
The decision tree for blackjack isn't very uniform and I realized at one point I needed a final value for a hand that could not be resolved based on the cards alone, but also required the user to make choices (in this case about downgrading Aces) and work later routines based on the final value alone.
I'm not a very good strategic thinker so doing a lot of up front planning for something even as simple as blackjack is an exercise in constantly learning where to draw the lines between what does where, AFTER I start programming.