Tag Info

New answers tagged

0

A concrete way can be done, based on what you said - that high cohesion leads single responsibility you can measure cohesion. A maximal cohesive class has all the fields used in all the methods. While a maximal cohesive class is not always possible nor desirable to have it's still best to reach to this. Having this class design goal it's pretty easy to ...


0

Just for the sake of discussion, I will bring up a class from JUCE called AudioSampleBuffer. Now this class exists to hold a snippet (or perhaps a rather long snippet) of audio. It knows the number of channels, the number of samples (per channel), seems to be committed to 32-bit IEEE float rather than having a variable numeric representation or wordsize ...


1

"SRP says methods should do just one thing". True. Constructors should do just one thing, and that is to put the object into a usable state. If just storing the dependencies doesn't put the object into a usable state, then the constructor isn't doing it's job. Did you read anywhere that "constructors with dependency injection should only set the ...


0

"It has some initialization that used to be done in the constructor but it seems that this is generally frowned-on in the DI world" - that's not exactly true. DI is just about providing dependencies externally not creating them within an object. So first thing fo you is to identify, within your singleton, what are it's dependencies and which are other ...


0

Not sure what language you are using, so I'm using pseudo-C# as example. You can create an IInitializes interface, which you then call after the instances are created. public interface IInitializes { void Initialize(); } public class PreviousSingleton : IPreviousSingleton, IInitializes { IDependency dep; public PreviousSingleton(IDependency ...


5

The way you're showing it now ("I instantiate the BallEntity this way"), it is being done by the implementation (code) that calls the constructor to create BallEntity. To be clear, the point is that the way you're showing it, everywhere that you create a BallEntity (whether in separate classes or multiple places within the same class), you're re-specifying ...


0

I would first break it down into a number of classes with their own SINGLE responsibilities. You would need to apply GRASP principals here first. GRASP Secondly, I would look into strategy design pattern. Strategy Design Pattern


1

ESB: Reliable delivery of a message is the responsibility of the transport. Successful delivery can mean very different things depending on context, see Quality of Service (QoS) 1, 2, 3. An ESB in a Service Oriented Architecture is normally responsible for routing and transformation as well as value add options such as monitoring, auditing etc. RESTful ...


1

It depends. The point of a message passing architecture is that the sender doesn't care who receives the message, and while this means a fire-and-forget approach works very well, it isn't suitable for some situations where either guaranteed delivery is required, or a acknowledgement is received. Fortunately the latter approach is very easy - the receiver ...


1

You could create list of classes responsible for each operation, where and when it makes sense for example, public abstract class MainActivity extends SingleFragmentToolBarActivity<T> implements Drawer.OnDrawerItemClickListener { .... private void setUpNavigationDrawer(Bundle savedInstanceState) { NavigationDrawer drawer = new ...



Top 50 recent answers are included