New answers tagged

0

How do I prove or disprove “god” objects are wrong? You Cannot. This kind of conjecture is not amenable to mathematical proof, and mathematical proof is the only kind of proof that is sound. Even if you try to replace the emotive word "wrong" with quantifiable measures of the effects of using god objects, you will find that: the available measures ...


2

In Java, enums are designed to be more than just constants. Enum values are objects (like one you could instanciate from any standard class) but with a few restrictions: Instances of an enum are restricted by yourself: when you write enum Number {ONE, TWO, THREE;} you explicitly say that theses 3 instances are the only one allowed to live Java takes care ...


1

It seems as if you're thinking of "values" in a constrained way (perhaps applying a concept from other languages). What if you expanded your idea of the kinds of values that can be enumerated? That opens a great range of possible uses. Your design wisdom will keep you from doing horrible things with that awesome power. Try this: Think of an enum as ...


5

Perhaps it's because I used C/C++ in a previous life but I would argue strongly for keeping the enums simple. In those languages an enum was a glorified integer only. In Java, as you say, they are really a true object. But I feel that the spirt of an enum is not to have a ton of code in there - an enumeration is a complete, ordered listing of all the ...


0

I think this fulfills SRP by virtue of its one public method public Data getData(); How it does this (by collaboration between a cache and a repository) doesn't seem unreasonable. Neither are exposed publicly via the CacheRepository interface. You might argue that calling it a CacheRepository in some sense exposes its functionality. I wouldn't but would ...


4

You improve your life by using common sense. "Single responsibility" means responsibility for one related set of things. Like the caretaker at a school has the single responsibility for taking care of the school, which consists of gazillions of little things. Do you see anything bad with this cache apart from your perceived violation of a rule? This ...



Top 50 recent answers are included