Linked Questions

1 vote
2 answers
776 views

So been doing a lot of reading/research into clean code/design, OOAD, refactoring, TDD, etc. Just trying to improve my designs to be easier to extend and maintain. One thing that is come up quite ...
keelerjr12's user avatar
  • 1,273
1 vote
0 answers
516 views

I've recently read this blog post regarding what a constructor should do and I am also reading Eric Evans' book on Domain Driven Design. Both the blog post and the book state that a constructor ...
Ciprian Vilcan's user avatar
1 vote
2 answers
517 views

A typical introductory example to OOP, classes, and constructors is object Car, with properties such as float fuel, bool is_engine_running, etc etc, and a class and constructor definition might be as ...
SRSR333's user avatar
  • 335
2 votes
0 answers
37 views

I was wondering what the purpose of separating the instantiation logic and the data loading logic of a class that loads data into memory if the class is a one time use. Here is an example of what I ...
tt9's user avatar
  • 631
51 votes
15 answers
9k views

Let me preface this by saying this is not my code nor my coworkers' code. Years ago when our company was smaller, we had some projects we needed done that we did not have the capacity for, so they ...
Kane's user avatar
  • 603
33 votes
1 answer
9k views

Is the "Builder" pattern restricted to addressing the "telescoping constructor" anti-pattern, or can it be said to also address the more general problem of complicated creation of immutable objects? ...
Mike Nakis's user avatar
  • 32.8k
11 votes
4 answers
8k views

Consider the following approach to validation of an API class (POJO or what have you, I mean a class which just acts as a container for some properties), we make all constructors private to the API ...
JustSomeGuy's user avatar
5 votes
7 answers
982 views

In any programming task, my preference is to write fail-fast code. That doesn't seem to be too controversial. However, I've also seen many developers say that constructors should do as little as ...
Alan Shearer's user avatar
2 votes
5 answers
659 views

It recently came to my attention that its best practice to avoid database calls in constructors. I feel like this means you end up repeating unnecessary code, thus the code is less DRY? For example, ...
pooteeweet's user avatar
1 vote
3 answers
831 views

Suppose I have the following List to hold a list of fruits. Example: def fruits = ["Apple", "Orange", "Grapes"] def fruitsBowl = ["Apple", "Grapes", "Orange"] // Will print false println(fruits....
user avatar
0 votes
2 answers
2k views

I know that we usually inject the dependencies by instantiating them in the constructor of the class we are injecting to. However, in my own experience, I just pass the class of the dependency as a ...
Fatima's user avatar
  • 209
0 votes
4 answers
272 views

So I want to inject an Application Client, say a Rest Api client, in my code. In order to create this client I need to go over the network to get it's user and password that is in a HTTP Vault. This ...
Vinicius Scheidegger's user avatar
-1 votes
1 answer
119 views

This is very closely linked to the question Legitimate "real work" in a constructor? but not quite the same. I am interested in having feedback on whether this is acceptable or has any risks....
shelbypereira's user avatar