Linked Questions

2 votes
4 answers

Explanation needed, for “Ask, don't tell” approach? [duplicate]

I'm taking a course on design patterns in software engineering and here I'm trying to understand the good and the bad way of design relating to "coupling" and "cohesion". I could not understand the ...
the_naive's user avatar
  • 143
91 votes
10 answers

How do you avoid getters and setters?

I'm having something of a hard time with designing classes in an oo way. I've read that objects expose their behavior, not their data; therefore, rather than using getter/setters to modify data, the ...
IntelliData's user avatar
43 votes
12 answers

Must a programmer learn text editors like Emacs and Vim? How important are they? [duplicate]

I have been writing code so far in conventional text editors that come with the OS so far or use an IDE in some cases. I know there are some advanced text editors like Emacs and Vim available solely ...
user avatar
36 votes
8 answers

Should an object's capabilities be identified exclusively by the interfaces it implements?

C#'s is operator and Java's instanceof operator allow you to branch on the interface (or, more uncouthly, its base class) an object instance has implemented. Is it appropriate to use this feature for ...
TheCatWhisperer's user avatar
14 votes
5 answers

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
5 votes
4 answers

Are "need to call objects in parent object" and "avoid circular dependency" reasons to avoid "Tell, don't ask"?

According to Explanation on how "Tell, Don't Ask" is considered good OO, I know I should avoid get the state of an object and then decides the actions to take to that object, eg: Bad: ...
wcminipgasker2023's user avatar
12 votes
5 answers

Is it a bad idea to use getters/setters and/or properties at all? [duplicate]

I am perplexed by comments under this answer: A user is arguing there against the use of getters/setters and properties. He maintains ...
gaazkam's user avatar
  • 4,459
7 votes
6 answers

How to represent a long if-else tree in a concise manner

Long story short, I've inherited a Java piece of code made of methods like this one: @Override public Action decide() { if (equalz(in.a, "LOC")) {//10 if(( //20 equalz(...
Luigi Cortese's user avatar
7 votes
3 answers

Should unit tests always overlap

This is a test design question. I have a class 'handler' that accepts a 'validator' that checks some business logic on what's passed to the handler. I made the unit tests for the validator and now I'...
Zalomon's user avatar
  • 1,200
3 votes
1 answer

How do I use polymorphism instead of instanceof?

I'm trying to make an abstract board game. In the game, a player can choose to make multiple actions within one turn such as placing, moving, or rotating a piece. I'm not sure if whether or not my ...
Michael Newgate's user avatar
3 votes
2 answers

OOP CLI menu structure organization?

This problem has kept me from pursuing a project I'm working on because it influences the entire structure of the application. This question has been briefly touched on here, but I feel that it wasn't ...
Jared's user avatar
  • 493
0 votes
2 answers

Is it bad to use checked exceptions as API response?

Consider the following code: public class User { private String password; public void changePassword( String oldPassword, String newPassword) throws ...
George Z.'s user avatar
  • 705
2 votes
1 answer

How to verify that every object responsible for Itself

I wonder if I have multiple objects and how to list their responsibilities where every Object Must be Responsible for Itself for example: If I have three objects: Employee,Schedule,Shift. and ...
Anyname Donotcare's user avatar
1 vote
2 answers

Explicitness, verbosity and their counterpart - when to prefer which?

I'am the only one in my team who advocates for adding a little implicitness in favor of codebase reduction and decreasing repetition. Yet I don't want to be a biased 'Bad apple' playing against ...
Pavel Voronin's user avatar
1 vote
1 answer

How to decide if object should request or receive data?

Deciding whether an object should request data (by calling a function) or receive data (by having a function called from another object) is probably dependent on the exact situation. So how do I ...
Simon Verbeke's user avatar