Ways to break up a class?

I have a user class with High total complexity. What are some good ways of breaking it up?

It is hard to answer that kind of question without seeing the code directly.

That is a great blog post on the most obvious ways to clean up models. When it comes to the user model be extra proactive about ripping out anything that is not directly related to saving the user model. Try to extract away everything you can into something that is more appropriate for the behavior.

1 Like

Can you identify things that the user might be masking? For example, does your user have an address, contact info, or profile? Could you pull that out?

Does your user do things that can be pulled out? For example, are there long methods that build up something or make requests or tell other objects what to do? Is there a user merger function or some other user admin functionality that could be pulled out?

Does your user do a bunch of stuff for the view? Could that be pulled out?

This is very helpful. Thank you!

BTW, I got the smell from Code Climate.