Linked Questions

17 votes
2 answers
31k views

I understand the concept and can use both the Factory Pattern and Dependency Injection, however they seem a little at odds with each other conceptually. Is it a case of using one over the other? Or ...
Samuel Hawksby-Robinson's user avatar
2 votes
5 answers
3k views

Check this out: public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, ...
user1806244's user avatar
-3 votes
1 answer
116 views

I have a small project that has 6 service classes and a main class. Since they are service classes and does not store any state in it, I declared one static method in each one: class Main calls A....
Alperen Üretmen's user avatar
20 votes
5 answers
7k views

There are plenty of reasons why globals are evil in OOP. If the number or size of the objects needing sharing is too large to be efficiently passed around in function parameters, usually everyone ...
vsz's user avatar
  • 1,506
23 votes
5 answers
18k views

I consider Joshua Bloch's Effective Java the best book on the language that I read. However, I started to wonder about something One of the things he suggested was to prefer public static factory ...
demavi's user avatar
  • 347
17 votes
4 answers
17k views

In Clean Code, it is written that "the ideal number of arguments for a function is zero". The reasons why are explained and make sense. What I'm after is techniques to refactor methods with 4 or more ...
Neil Barnwell's user avatar
13 votes
4 answers
2k views

I have an interface called IContext. For the purposes of this it doesn't really matter what's it does except the following: T GetService<T>(); What this method does is look at the current DI ...
LiverpoolsNumber9's user avatar
4 votes
4 answers
11k views

These are two classes, the first one I inject an instance of type IEngine while the second one I inject owner's name, tickets and engine. Version 1: public class Car { public Car(IEngine ...
Anonymous's user avatar
  • 2,049
8 votes
5 answers
3k views

I've a decent amount of OOP with various languages but am pretty new to Java. I'm reading through a lot of tutorials where large numbers of objects are created within the code of a class, and I'm ...
GordonM's user avatar
  • 6,515
5 votes
3 answers
18k views

I have recently taken a project with another developer, and he has a certain way of initializing his references. class Player { private: Console &console; Armor &armor1, &...
Bugster's user avatar
  • 4,043
2 votes
3 answers
874 views

I have an application where I'm using pure DI to construct my object graph. I would like to use a factory so I can create and destroy instances of a certain class at run time. The trouble is that ...
Rob L's user avatar
  • 106
3 votes
1 answer
305 views

I have an application with dependency injection that consumes a REST API. The API calls are abstracted into entity-specific repositories. Some of the repositories are: HttpNotebookRepository, ...
Amal K's user avatar
  • 111
0 votes
1 answer
335 views

Often I want to open a new window from within some view. I see opening a window as view logic. So I don't want code in my viewmodel that creates/opens/changes Windows or anything else that interacts ...
user2190492's user avatar
1 vote
1 answer
139 views

Consider the construction of the FixAcceptor type below. The code snippet is part of a unit test. var logSource = LogSource.OnMessage | LogSource.Event; var stateStore = new StateStore(); var ...
Matthias Güntert's user avatar
2 votes
0 answers
230 views

Project description: I have a nodejs project where I try to build a bluetooth mesh like network, each node consists roughly of 4 parts the frontend part, the message broker, a bluetooth client and a ...
MADforFUNandHappy's user avatar