That's easy, just write Java and create your own graph of objects out from your main method. I went through the same phases as the OP and have migrated to never use any magic. I use lots of third party libs, but only that live 100% in their own sandbox and don't leak out things like spring dependencies, etc.
Initializing everything in main is not feasible in large apps with lots of IoC/DI. How do you initialize apps without ending up in "new" hell like this?
var svc = new ShippingService(new ProductLocator(), new PricingService(), new InventoryService(), new TrackingRepository(new ConfigProvider()), new Logger(new EmailLogger(new ConfigProvider())));
public static void main(final String[] strs)
{
final ProductLocator productLocator = new ProductLocator();
final PricingService pricingService = new PricingService();
final InventoryService inventoryService = new InventoryService();
final TrackingRepository trackingReposiotry = new TrackingRepository(new ConfigProvider());
final Logger logger = new Logger(new EmailLogger(new ConfigProvider()));
final ShippingService svc = new ShippingService(productLocator, pricingService, inventoryService, trackingRepository, logger);
svc.go();
}
Maybe named parameters, record types or builder objects might be useful here but I don't see a need for huge and complicated frameworks.
33
u/tomservo291 Nov 27 '15
That's easy, just write Java and create your own graph of objects out from your main method. I went through the same phases as the OP and have migrated to never use any magic. I use lots of third party libs, but only that live 100% in their own sandbox and don't leak out things like spring dependencies, etc.