Reputation
9,615
Top tag
Next privilege 10,000 Rep.
Access moderator tools
Badges
9 42 95
Impact
~509k people reached

Jan
18
comment Shallow or deep equal, which one is idiomatic in Java?
Thank you both: you are probably right: I should split the class into two classes, each with its own equals implementation.
Jan
18
comment Shallow or deep equal, which one is idiomatic in Java?
The point is that, according to my requirements, I need to implement both, and I was wondering which one I should implement by overriding equals and which one I should implement as a separate method (e.g. match, as suggested by superM). I thought that there might be some general recommendations, e.g. a deep implementation of equals implies a corresponding deep implementation of hashCode, which might become quite expensive.
Jan
18
comment Shallow or deep equal, which one is idiomatic in Java?
@DonalFellows: Because they are not part of my aggregation hierarchy. A node of type A can have attributes of type int, float, String, etc, and sub-nodes of type B. By shallow I mean looking at the attributes of a node, by deep I mean looking at the attributes of a node, and at its sub-nodes, recursively. The String class is not part of my domain model.
Jan
18
asked Shallow or deep equal, which one is idiomatic in Java?
Jan
17
reviewed Leave Open Lisp/Clojure: Removing unnecessary parentheses through conventions
Jan
17
reviewed Leave Open Method vs Function vs Procedure
Jan
17
reviewed Leave Open Dynamically vs Statically typed languages studies
Jan
15
reviewed Close Do code style guides increase productivity?
Jan
15
reviewed Close How to create a “cult of quality”
Jan
15
awarded  Popular Question
Jan
14
accepted Do any object-oriented programming languages support “collective constructors”?
Jan
14
comment Do any object-oriented programming languages support “collective constructors”?
I find the idea of a builder pattern in combination with freezable object very good. It is not exactly what I had in mind but it solves my problem without introducing a new ad-hoc concept, which is IMO good.
Jan
13
comment Do any object-oriented programming languages support “collective constructors”?
@Telastyn: I am not sure I understand your scenario completely. My point is that sometimes I would like to build (and freeze) a certain object configuration, and normally the code for doing this is spread over the constructors of the individual objects (and possibly an extra factory method supervising the whole). I would like to have the whole operation defined in one place, but certain things (like setting an immutable reference) can only be done in a constructor. So I am kind of stuck.
Jan
13
comment Do any object-oriented programming languages support “collective constructors”?
@JensG: I thought about that, but a factory has some limitations. For example, if an object contains an immutable reference, you cannot set it in a factory: you can only set it in the constructor. I am considering the Java semantics here, but I think this can be a general problem.
Jan
13
comment Do any object-oriented programming languages support “collective constructors”?
Can the voter please explain the close vote? I am asking if there exists a programming language with a very specific feature. The question does not seem to be off-topic or poorly formulated to me but I am open for feedback.
Jan
13
asked Do any object-oriented programming languages support “collective constructors”?
Jan
13
comment Is it sufficient to use acceptance and integration tests instead of unit test?
I agree with you: I am a bit skeptical when I see TDD applied blindly with the assumption that it will automatically produce good design. Furthermore, sometimes TDD gets in the way if the design is not clear yet: I am forced to test the details before I have an overview of what I am doing. So, if I understand correctly, we agree. I think that (1) unit testing helps to verify a design but design is a separate activity, and (2) TDD is not always the best solution because you need to organize your ideas before starting to write tests and TDD can slow you down in this.
Jan
13
comment Is it sufficient to use acceptance and integration tests instead of unit test?
As Doc Brown has pointed out, unit tests only work well if you have well-designed code. And sometimes you have to write some code as a proof of concept for your design. Writing tests in this phase just comes in your way. At least this is what I have experienced several times.
Jan
13
comment Is it sufficient to use acceptance and integration tests instead of unit test?
@Robbie Dee: I agree that TDD can disrupt the natural development flow, not because I'd like to save time and meet a deadline, but because it forces me to write tests for code whose structure is still not clear to me. I become very frustrated when I write a test, implement a function, and then discover that I need a different function and have to throw away the test as well. So, instead of helping me understand my code, writing tests often interrupts my flow of thought and forces me to bother about many details before I have an overall picture of the code I want to write.
Jan
13
comment Is it sufficient to use acceptance and integration tests instead of unit test?
"This means, when the components already are designed well.": I agree with you, but how can the components be already designed if you write the tests before writing the code, and the code is the design? At least this is how I have understood TDD.