This is probably because setSiteName does another process that the coder wanted to run, which can only be run from that method or inside the object and didn't want to change the value.
While in your case this may not have been the issue, it is a genuine and a bad problem of object systems in general. This is particularly common in GUI applications, where it is common to describe what happens to one graphical element when another one is changed by making some sort of "binding" between setters / getters of different properties. In situations like those, it's very common to end up with this code, or something that accomplishes the same thing, but through some third-party proxy to perform some sort of an update to the complicated interface.
I've not done GUI since WinForms and Flex were around, but it seemed to be pretty universal at the time.
Also, you are definitely not in a position to tell someone how to OOP. After all, you are writing in Java, where OOP is kind somewhere between... bad and really bad. So, please. Keep that bullshit to yourself.
429
u/Bad_Decisions_Maker Jan 30 '22
This is like a power cord plugged into itself
109
u/thebritisharecome Jan 30 '22
This is probably because setSiteName does another process that the coder wanted to run, which can only be run from that method or inside the object and didn't want to change the value.
21
u/Snoodlewonker Jan 30 '22
Its like asking yourself a question, that you already know the answer to!
69
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 30 '22
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
4
u/Achereto Jan 31 '22
You should definitely check whether siteName is equal to `webStatusForm.getSiteName()` afterward, just to be sure.
2
u/Paul_Robert_ Jan 31 '22
When you get paid by the line :P
32
u/E_MC_2__ Jan 30 '22
we made the floor out of floor
26
u/StrikingChallenge389 Jan 30 '22
The code equivalent of mashing Ctrl+C and V
14
u/[deleted] Jan 30 '22
yep, the self-contained statement
3
u/[deleted] Jan 31 '22
Using getters and setters wherever possible is OOP 101. If the value is pre declared this is not bad code
4
u/[deleted] Jan 30 '22
Somehow this prevents a race condition from happening or some shit
2
u/contactlite Jan 30 '22
Bless your heart
2
u/RFC793 Jan 30 '22
Possibly the result of a bulk refactor? Maybe siteName originally came from another object?
2
u/kewlness Jan 30 '22
This is what we call a `closure` right?
2
u/[deleted] Jan 31 '22
Camel Case Supremacy 🗿
1
u/sneakykenny Jan 31 '22
Remove the unused variable warning be like
1
u/yard2010 Jan 31 '22
Plot twist: this is the body of the getter
1
u/[deleted] Jan 31 '22
(Staring at yourself in the mirror while shaving:)
Remember, your name is John Smith!
1
u/sigmaclientwastaken evil Jan 31 '22
i dont see whats wrong
1
u/SanianCreations Jan 31 '22
I could see this happening when the setter has some side-effect that cannot be activated through other means.
0
u/iamafraazhussain Jan 31 '22