javaspringooparchitectureframeworks

Spring framework vs Object Oriented Programming


By default Spring framework creates all the beans as singletons. Isn't this contradicting with basic Object Oriented Programing concept of creating multiple object instances based on a template (class).


Solution

  • Well, if you really think about it, spring does make some practices of OOP really hard/impossible, say:

    return new Cached(new ImageLoader("cat.png")).load();
    

    or

    return new Parrarel(new ImageLoader("cat.png"), new ImageLoader("dog.png")).load();
    

    It's really hard (don't know if even possible) in spring (and most DI frameworks in general).