Tagged Questions
45
votes
4answers
1k views
Why were Java collections implemented with “optional methods” in the interface?
During my first implementation extending the Java collection framework, I was quite surprised to see that the collection interface contains methods declared as optional. The implementer is expected ...
21
votes
11answers
884 views
Choose code design effort or laziness in Bank world
I've worked for two years in a great Investment Bank.
I made some technical projects with the desire of creating code the most optimized, respecting the adapted good design patterns, SOLID principle, ...
18
votes
7answers
3k views
Why avoid Java Inheritance “Extends”
Good day!
Jame Gosling said “You should avoid implementation inheritance
whenever possible.” and instead, use interface inheritance.
But why? How can we avoid inheriting the structure of an object ...
16
votes
5answers
644 views
Do ORMs enable the creation of rich domain models?
After using Hibernate on most of my projects for about 8 years, I've landed on a company that discourages its use and wants applications to only interact with the DB through stored procedures.
After ...
13
votes
3answers
486 views
Does the state Pattern violate Liskov Substitution Principle?
This image is taken from Applying Domain-Driven Design and Patterns: With Examples in C# and .NET
This is the class diagram for the State Pattern where a SalesOrder can have different states during ...
12
votes
3answers
4k views
Which is a better practice - helper methods as instance or static?
This question is subjective but I was just curious how most programmers approach this. The sample below is in pseudo-C# but this should apply to Java, C++, and other OOP languages as well.
Anyway, ...
12
votes
5answers
2k views
What is the difference between “data hiding” and “encapsulation”?
I'm reading "Java concurrency in practice" and there is said: "Fortunately, the same object-oriented techniques that help you write well-organized, maintainable classes - such as encapsulation and ...
11
votes
2answers
830 views
Advantages and disadvantages of structuring all code via classes and compiling to classes (like Java)
Edit: my language allows for multiple inheritance, unlike Java.
I've started designing and developing my own programming language for educational, recreational, and potentially useful purposes.
At ...
9
votes
6answers
483 views
Interpretation of DRY principle
Right now I'm struggling with this concept of DRY (Don't Repeat Yourself) in my coding. I'm creating this function in which I'm fearing it's becoming too complex but I'm trying to follow the DRY ...
9
votes
6answers
2k views
Are Java's public fields just a tragic historical design flaw at this point?
It seems to be Java orthodoxy at this point that one should basically never use public fields for object state. (I don't necessarily agree, but that's not relevant to my question.) Given that, would ...
9
votes
6answers
6k views
Difference between a service class and a Helper class
I would like to know what differentiates a Service class from a utility class or a helper class?
A class only with underlying methods calls the dao's is a service? Doesn't the usage of Helper ...
9
votes
8answers
472 views
Past If statements Arrays, loops… Now what?
I gave up on programming a little over a year ago when I kept hitting this wall. I am revisiting the subject because I want to create basic Android application. But I feel that my limited knowledge ...
9
votes
5answers
481 views
OOP :What are some of the situations in which class based design is better than interface based one?
I was reading JDOM's website.
Why is the JDOM API defined in terms of concrete classes rather than interfaces?
Jason Hunter summarizes the arguments against an interface-based API for JDOM:
...
7
votes
6answers
800 views
Object-Oriented Class Design
I was wondering about good object oriented class design. In particular, I have a hard time deciding between these options:
static vs instance method
method with no parameters or return value vs ...
6
votes
4answers
270 views
Applying DRY to an inheritance hierarchy
I'm working on refactoring a legacy application where I implemented the State pattern successfully as shown in the following diagram:
As you see there is a common behavior between the 3 states, so ...