I'm working on a Soccer management game. Project is fairly new and small and I'm new to PHP. The project was starting to get a bit messy so I've been looking into refactoring. The first thing I've done is to make my functions smaller, which helps a lot. I also added my functions to my classes, since they were originally a bunch of small functions, included in the project. The problem is, now my classes are starting to get large and I don't want to go in the wrong direction with my coding/learning.
I'm thinking of removing some of the methods into their own class but I'm not sure of how this works. For example, my Team
class currently does two things (which is one too many?). Firstly it does database work (load/save/create a team) and I'm now adding functions to allow the AI to select a squad. This is already six small methods. Could I make a second class, just for this second group of methods, with no properties? If so, how would this work?
For example, say that I already have my 'Team' object. Do I create a 'Team Select' object, just to use those methods, then pass my 'Team' object into the methods, so something like teamselectobj->SelectTeam($Teamobject)
. Although this makes my classes smaller, it does seem like extra unnecessary steps. Is this good refactoring practice?