All Questions
71 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 ...
14
votes
5
answers
5k
views
How to "Tell, don't ask" when 2 objects involves in the condition and the decision at the same time?
According to Explanation on how "Tell, Don't Ask" is considered good OO, I know the following is bad:
if(a.isX){
a.doY();
}
public class A{
public boolean isX;
public void ...
0
votes
0
answers
98
views
By creating an architecture, it is better to have many classes that handles different scenarios, or a single one that handles all? [duplicate]
During my limited professional experience, I have been involved in microservices projects with a common structure:
The Controller takes a request and validates it using the jakarta.validation....
0
votes
1
answer
1k
views
Pattern to convert different types of similar unchangeable objects to the same object
I have an existing system that inserts books into a library database, and I want to generalize it to include other media.
The other media is similar, but not exactly the same, and all media are third ...
0
votes
3
answers
3k
views
How to handle a new method in the interface that is not applicable for all classes?
I am faced with an interesting OOD problem: I have an interface with 3 methods:
interface TestInterface {
String action1();
String action2();
String action3();
}
and 3 classes that ...
3
votes
4
answers
1k
views
Should I implement one interface with two methods or two interfaces?
NOTE: This question is reposted from SO because it violates community guidelines for being opinion-based.
I have two classes that are similar in nature but they have different functional signatures. I ...
1
vote
2
answers
385
views
Are experienced developers and software architects able to describe an entire software application in terms of design patterns?
Do experienced developers and software architects see entire application in terms of design patterns?
In other words experienced developers and software architects able to describe an entire software ...
4
votes
7
answers
2k
views
When to use a class with a constructor vs using a method returning an object
I've been working in a rather large codebase filled to the brim with small classes such as
class Person
{
public string name;
public int age;
public int height;
}
As a mainly front-end ...
9
votes
2
answers
2k
views
Does OOP overemphasize the importance of noun and thus put action/verb in the less importance position ? [closed]
Steve yegge wrote an article called "Execution in the Kingdom of Nouns" back in 2006, 14 years later I still find the points he made valid. For example, "Action is what gives life its ...
1
vote
3
answers
757
views
Design with subclasses being aggregates of classes implementing interfaces
I have modelled a class structure, where subclasses Rectangle and Circle inherit from an abstract superclass Figure. All subclasses share an interface IGeometry that provides for getArea() and ...
0
votes
1
answer
510
views
Extension of classes - Where to put behaviour - How much direct-access is allowed
At this point i would exclude the inheritance....
So the question is about more like extend into a seperate class or into the class which should be extended, both play in the composition-league.
So ...
1
vote
3
answers
684
views
Best way to Model Classes associated with other Classes?
I'm trying to make a sports stats app in Java/Android + Realm.
I have the following classes:
Season
Player
Matches
I would like the Season to contain a "list" of all the players that played that ...
3
votes
4
answers
2k
views
De-coupling business logic from POJO de-serialization design pattern
I've a JSON file which I'm trying to de-serialize into POJOs.
public abstract BaseClass {
private String baseClassField;
abstract String execute();
}
ClassA extends BaseClass
public ClassA ...
1
vote
1
answer
476
views
Design Chess - Object Oriented Design
I am trying to design online chess game(figuring out required classes). Need some suggestion on choosing better option to validate the move. So, lets say, I have below class
Option 1 :
My ...
-2
votes
1
answer
1k
views
Pass ID or Object which has irrelavant details as RequestBody in Rest Call?
Situation: I am designing a REST API that needs one or more, potentially large objects to do it's work
I am facing a decision to either
Pass the large object by reference and have the API retrieve ...