Back to the Learning!

Laracasts is packed full with over 1,000 lessons just like this one.

Sign up to get full access or log in to your account and sit back.

Published On Apr. 14th 2016

Whip Monstrous Code Into Shape: God Object Cleanup #2: Traits and Socks

Episode 5 Run Time 7:59

Download
Let's review the next option you have, when cleaning up big, bad God objects: extracting traits. While some developers have knee-jerk reactions to the concept of a trait that will never be used elsewhere, I find it to be a clean and convenient solution. It's akin to cleaning up your room, by placing all the socks in one drawer, and the shirts in another. Admittedly, you didn't design a new closet space, but there's no denying that the room is now cleaner as a result.