Timeline for Are Spring beans declared as static a poor design choice?
Current License: CC BY-SA 4.0
17 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 26, 2023 at 14:37 | comment | added | Tristan | Spring autoconfigure classes do use static beans though. For example : github.com/spring-projects/spring-boot/blob/v2.6.6/… | |
| Jun 9, 2020 at 20:55 | comment | added | GC_ | I am also not clear about memory consumption. The class will get loaded by the classloader either way. And it will stay in memory either way. If anything Spring is worse, since it keeps the class and the object in memory. (Rather that just the static class.) | |
| S Dec 8, 2019 at 21:41 | history | suggested | CommunityBot | CC BY-SA 4.0 | Spelling corrections |
| Dec 8, 2019 at 17:06 | review | Suggested edits | |||
| S Dec 8, 2019 at 21:41 | |||||
| Jan 15, 2019 at 15:50 | vote | accept | Yassine Badache | ||
| Jan 11, 2019 at 14:45 | comment | added | Dherik | @Walfrat, I was explaining generally the problem, but you are right, Spring Beans are singleton by default. I added this explanation on my answer, thanks! | |
| Jan 11, 2019 at 14:44 | history | edited | Dherik | CC BY-SA 4.0 | added 95 characters in body |
| Jan 11, 2019 at 12:10 | comment | added | Walfrat | Though I mostly agree with that, I fail to see the point about memory consumption, since a Spring Beans will generally eager instantiated at startup and will remain in memory as a singleton unless you specify otherwise. | |
| Jan 11, 2019 at 11:15 | history | edited | Dherik | CC BY-SA 4.0 | Broken link |
| Oct 22, 2018 at 14:00 | history | edited | Dherik | CC BY-SA 4.0 | added 25 characters in body |
| Jun 7, 2018 at 13:03 | history | edited | Dherik | CC BY-SA 4.0 | added 36 characters in body |
| Jan 25, 2018 at 13:18 | comment | added | Yassine Badache | I think one of the main points there (that I missed) would be that states on beans are strictly to banish. | |
| S Jan 24, 2018 at 10:19 | history | suggested | ichantz | CC BY-SA 3.0 | Mainly syntactic improvements |
| Jan 24, 2018 at 10:10 | comment | added | Laiv | Having static beans would mean you call them whenever you want, This doesn't remove either coupling nor dependency. It only will obfuscate it and, over time, the coupling and the dependency over these beans will go for worse. When a component is present anywhere in the code, it's a design flaw regarding cohesion. Statics will act like global variables what in general, is a bad thing. Mainly because makes the whole application less predictive. Overall if these beans are stateful | |
| Jan 24, 2018 at 8:48 | review | Suggested edits | |||
| S Jan 24, 2018 at 10:19 | |||||
| Jan 24, 2018 at 8:22 | comment | added | Yassine Badache | Thank you for the litterature, it will take me a while to read :) BTW I added a relevant piece of code. | |
| Jan 23, 2018 at 22:31 | history | answered | Dherik | CC BY-SA 3.0 |