All Questions
7 questions
6
votes
4
answers
1k
views
How to avoid init methods when 2 objects need the reference of each other?
According to https://softwareengineering.stackexchange.com/a/334994/432039, I know init is a code smell and should be avoided, and one of the solutions is to use a builder to hold the state first ...
0
votes
3
answers
354
views
How to refactor "init()" into "physically make them two separate classes"?
According to https://softwareengineering.stackexchange.com/a/334994/432039, I know "init()" method is a code smell, and "physically make them two separate classes" is a way to ...
1
vote
1
answer
258
views
Why is using an internal attribute to filter objects considered OK, but when I use a map to filter based on attributes, it's considered a code smell?
A long time ago I asked about using an enum to essentially use as a poor version of instanceof to make decisions about an object.
As stated in this answer:
When your weapon types enum just mirrors ...
-1
votes
1
answer
139
views
Have an object communicate with another object
I asked similar question earlier this morning, and for whatever reason, I'm not getting a complete answer to my question. I'll ask it a different way.
I was attempting to understand Eric Lippert's ...
2
votes
2
answers
186
views
Using a Collection with Attributes to Check and Make Decisions
I was reading on this SESE page about using a variable to indicate the object type, more specifically, an enum.
The accepted answer states:
When your weapon types enum just mirrors the class ...
31
votes
9
answers
31k
views
Are init() methods a code smell?
Is there any purpose for declaring an init() method for a type?
I'm not asking whether we should prefer init() over a constructor or how to avoid declaring init().
I'm asking if there is any ...
47
votes
10
answers
28k
views
Is there any reason to use "plain old data" classes?
In legacy code I occasionally see classes that are nothing but wrappers for data. something like:
class Bottle {
int height;
int diameter;
Cap capType;
getters/setters, maybe a ...