In software design, there is seldom if ever a 'best way'. Often there are dozens of variables that must be considered. The primary ones are speed, memory use, and code readability. 99% of the time (in my opinion), the third one is the most important.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors