Timeline for Should constructors ever be used only for side-effects?
Current License: CC BY-SA 3.0
20 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 27, 2021 at 10:47 | comment | added | Thorbjørn Ravn Andersen | Just walk away.... | |
Apr 27, 2021 at 8:45 | comment | added | Martin Maat | You mentioned it, we acknowledge you are right, it is a stupid way to implement static behavior. I suggest you leave it at that. You obviously do not have the leverage to change this, it is a waste of energy. You will only drive your tech lead into more defensive behavior, it is already obvious he is not willing to change this. "It works, we are used to it, it is a conscious decision", you know the rap. It is someone else's turn to pass the message now. | |
Apr 27, 2021 at 6:58 | answer | added | xtofl | timeline score: 0 | |
Apr 21, 2017 at 13:05 | history | tweeted | twitter.com/StackSoftEng/status/855407205029482496 | ||
Mar 4, 2017 at 17:41 | vote | accept | Brian H. | ||
Mar 4, 2017 at 16:25 | answer | added | user949300 | timeline score: 1 | |
Mar 4, 2017 at 16:03 | comment | added | user949300 | @Doc Brown, you certainly found important principals that this clearly violates. But OPs collaborators dont seem to care about them. By "concrete example" I mean code examples of possible bugs or issues that might be more convincing. | |
Mar 4, 2017 at 9:48 | review | Close votes | |||
Mar 9, 2017 at 3:00 | |||||
Mar 4, 2017 at 9:17 | answer | added | JacquesB | timeline score: 1 | |
Mar 4, 2017 at 8:34 | comment | added | Doc Brown | @user949300: finding concrete flaws took me a minute, see my answer. | |
Mar 4, 2017 at 8:32 | answer | added | Doc Brown | timeline score: 22 | |
Mar 4, 2017 at 8:19 | answer | added | Zdeněk Jelínek | timeline score: 3 | |
Mar 4, 2017 at 8:12 | comment | added | paparazzo | Just create a constructor for Card that will take i and j. If you need an argument for why then I feel for you. | |
Mar 4, 2017 at 8:11 | history | edited | Brian H. | CC BY-SA 3.0 |
added 710 characters in body
|
Mar 4, 2017 at 7:50 | comment | added | Brian H. |
@user949300 I agree that enums would be preferable. The issue is that in Java they are not extensible. The goal of the Suit class was to get something that functioned similar to an enumeration, but with extensible values. While I agree that your example exposes a weakness, I don't think it's specific to this weird constructor use. You would have the same issues with a static add() method
|
|
Mar 4, 2017 at 7:15 | comment | added | user949300 |
Its an icky pattern, but finding concrete flaws takes some effort. Here's one: what happens if you call new Suit("clubs", 0); new Suit("clubs", 1); new Suit("hearts", 0); new Suit("typo", 3); You should be using enums and far less global statics.
|
|
Mar 4, 2017 at 7:14 | answer | added | Philip Kendall | timeline score: 7 | |
Mar 4, 2017 at 4:56 | history | edited | Brian H. | CC BY-SA 3.0 |
edited body
|
Mar 4, 2017 at 4:35 | review | First posts | |||
Mar 7, 2017 at 8:39 | |||||
Mar 4, 2017 at 4:30 | history | asked | Brian H. | CC BY-SA 3.0 |