All Questions
5 questions
7
votes
2
answers
421
views
How should separated methods be used?
Among other things, the CQRS has a rule that each of the methods has one responsibility. So we can't have this in the model:
public class Store {
public Item getOrCreateItem(int id)
{
...
6
votes
7
answers
7k
views
How to avoid repeating "a==b" when comparing "condition a" and then "condition b" and then...?
For example, I have an object:
public class Obj{
public int a;
public float b;
public String c;
}
I need to find best "Obj": largest a and then largest b and then longest c:
int ...
2
votes
1
answer
846
views
Better way to implement a feature with turn on/off based on a flag
I'm trying to implement a feature with option to turn it on/off based on a flag. I'm doing it in the following way which I feel like a overkill,
public interface Feature {
public interface ...
2
votes
2
answers
971
views
Design pattern for static fields of a subclass
I'm creating a library, and I want there to be an abstract class called Optimizer. The user should be able to choose from a set of predefined Optimizers and if desired, use fluent methods to change ...
0
votes
2
answers
735
views
Question on refactoring and code design
Suppose, I have a class with a constant static final field. Then I want in certain situations that field to be different. It still can be final, because it should be initialized in constructor. My ...