Modernizing the factory method pattern