Skip to main content

All Questions

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 ...
wcminipgasker2023's user avatar
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 ...
wcminipgasker2023's user avatar
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....
Paul Marcelin Bejan's user avatar
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 ...
Tinker's user avatar
  • 155
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 ...
Zed's user avatar
  • 117
4 votes
6 answers
2k views

The ID of an object is null at start. Does that make the object state invalid and violate encapsulation?

This question is related to How should an `Employee` class be designed? In the above question, to uniquely identify an employee, each Employee object has an id field as shown below class Employee { ...
Susantha7's user avatar
  • 406
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 ...
Kee's user avatar
  • 13
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 ...
Dioxin's user avatar
  • 953
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 ...
FreshOuttaTheBag's user avatar
9 votes
2 answers
40k views

Are Spring beans declared as static a poor design choice?

The question is pretty straightforward, I'll try to explain why I want some explanations. (All of this is my 1½-year junior Java developer opinion, which may be more than incomplete. Which is why I ...
Yassine Badache's user avatar
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 ...
Qiulang 邱朗's user avatar
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 ...
user2330678's user avatar
6 votes
2 answers
3k views

Trouble with circular dependency in state machine design

I am trying to develop the structure for a basic state machine that can also take in input and produce output. I've hit a bit of a mental block in trying to figure out how to model the relationship ...
Jordan's user avatar
  • 63
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 ...
musicalears's user avatar
5 votes
1 answer
1k views

Why do we implement the Command design pattern like this?

I trying to learn the Command design pattern, I already know how it works and where it is used, but I'm a little bit confused about the implementation. So I know we need to set the context by ...
Wojtek Wencel's user avatar

15 30 50 per page
1
2 3 4 5