Tag Info

New answers tagged

5

If you need to ask the question, you don't need to know the answer. If you had a profiler, profiled your code, and found this to be a hotspot, you could trivially find out the answer yourself by simply changing the code and profiling again. Since you haven't done that, we can readily deduce that in fact, you have no such hotspot and no such profiler, and ...


0

If you use the terms used in IoC (which is a fancy way to perform initialisation), you have Constructor Initialisation or Property Initialisation. There is a 3rd way to initialise a class through interfaces. Martin Fowler uses these terms There are three main styles of dependency injection. The names I'm using for them are Constructor Injection, ...


1

Let's tackle this: Would it be most appropriate to return a double value as I've mentioned, or provide public multiply(), add(), etc. methods? Should said class know how to multiply and add? Sounds like you are building a calculator implementation... I would say it really depends on which part of the calculator you are building this for. If this is the ...


5

Is there any documented preference, in Java, for either of these conventions? The preference is that the end user has no idea what the backing primitive is for your type. This is encapsulation at its essence. Now, if your object exposes an interface to get a double (regardless of what the backing datatype is), either because you're serializing your ...


0

Put them in a separate module. Assuming your solution is not more bloated than needing you haven't got too many options. You've already split up the functions in different sub functions so the question is where you should put it: Put them in a module with only one "public" function. Put them in a class with only one "public" (static) function. Nest them ...


1

If libcommon.h cannot be compiled without some_other.h, then anyone who wants to compile a call to doSomething1() is going to have to #include some_other.h as well as libcommon.h, otherwise the compiler simply doesn't have enough information to do its job. There's no magical way around that. As others have pointed out, when this dependency is correct you ...


1

Yes, the compiler has to be able to reach all files referenced int he project, including headers for other modules you may use. There are 2 techniques to achieve this: specify an Include path to the complier, passing in INCLUDE= style statements on the command line/makefile for each directory that contains relevant headers. copy all headers into a single ...



Top 50 recent answers are included