New answers tagged java
0
votes
Spring/Java multiple shared modules for different databases
What you are saying can be done, from a technical perspective.
However, I would urge you to consider why you are decoupling your micro services when there is so much shared logic (as you mentioned) ...
0
votes
What is the better way to escape from too many if/else-if from the following code snippet?
The switch statement with nine cases is simple, obvious, doesn’t require any extra code, and is easily extended. Note how all the answers actually avoided writing nine cases down. So they are more ...
6
votes
Accepted
When the stack frames become computationally expensive
There are two questions here:
What is the cost of function call?
Is inlining a function worth it?
So first of all a function call costs. Saving registers, setting up frame, two jumps, loading ...
-1
votes
When the stack frames become computationally expensive
function call overhead
When you speak of stack frames that are "computationally expensive"
you're really talking about the expense incurred to save state,
transmit arguments, receive result, ...
0
votes
How do I cleanly keep track of the type of various objects implementing a common interface without reflection?
Third time is the charm ...
There are possibly other design changes to consider here but I can only make some guesses about that. I'm just going to focus on what you've shown and assume the approach ...
1
vote
How to maintain dependencies shared among microservices?
Put all your code - services+libraries - in a monorepo
You've hit the classical problems with micro services. A better way would be to manage your project as a monorepo - a single repo, but managed ...
2
votes
How to maintain dependencies shared among microservices?
I think there are two main ways to think about this and how to deal with it.
One is that when you have a shared library in your code base, you need to really think about managing it the way an open-...
4
votes
How to maintain dependencies shared among microservices?
TL;DR: Change the signature and don't upgrade until ready.
I am, actually, in a similar situation at work, and it's an architecture I chose. In order to protect IP, our codebases are organized in the ...
8
votes
How to maintain dependencies shared among microservices?
There really is no easy way to resolve this. The microservices are coupled at a much deeper layer than they should be. Reducing the maintenance cost means properly decoupling these things so that ...
29
votes
How to maintain dependencies shared among microservices?
Combine the dependency and the cluster of micro-services into one monolith.
Adopting microservices should be about enabling independent development and deployment of individual parts, reducing ...
18
votes
How to maintain dependencies shared among microservices?
Exported methods should be part of a stable API, which means that you never change the signature of a method once it is published, unless you create a new major version of the library.
If you use the ...
0
votes
How do I cleanly keep track of the type of various objects implementing a common interface without reflection?
If you basically need a marker interface, but you cannot use it due to limitations in your chosen framework, just step back a bit and rethink.
As far as I understand your setup, you have some kind of ...
0
votes
Multithreaded processing of single REST requests
By now virtual threads are available. Assuming the other service can handle the traffic and you clarified that a bulk request endpoint is not possible / won't be added on the lower level service then ...
3
votes
What's the value in exposing the dependencies you used for your tests?
When I checkout the source code of a project and I want to compile and test it, this tells maven that it needs to pull munit_2.13 to run the test stage. Without the dependency the test likely would ...
1
vote
How do I cleanly keep track of the type of various objects implementing a common interface without reflection?
Ok, here is a solution that is cringe as heck, is performant and is nauseously flexible. It is taken from C++ locale facet framework.
It basically introduces its own enum-like type metadata table.
...
2
votes
How do I cleanly keep track of the type of various objects implementing a common interface without reflection?
Another way you can go about this if you, (per DocBrown) want to avoid reflection and want InventoryItem to be agnostic of Powerup, you can try something like this. NOTE: I don't really like this ...
1
vote
How do I cleanly keep track of the type of various objects implementing a common interface without reflection?
I think you could flesh out your question a bit around some of the interfaces and classes you mention, but I think have enough of a picture to suggest another option which would fit into your current ...
0
votes
How do I cleanly keep track of the type of various objects implementing a common interface without reflection?
Avoid reflection altogether, use objects instead of relational model.
class Type ....
interface InventoryStack {
Type type();
void use();
int count();
bool isPowerUp();
)
class Inventory {...
-2
votes
How do I cleanly keep track of the type of various objects implementing a common interface without reflection?
I'm very confused by use of getClass() for stuff that is usually done via Visitor while at the same time worrying about other uses of reflection. But if the design is set in stone, and the only ...
-2
votes
How to calculate percentile in Java without using Library
In kotlin :
// The q-th quantile represents the value below
// which q percent of the data falls.
fun numpy_quantile(data: IntArray, quantile: Double): Int {
require (quantile in 0.0..1.0)
val ...
3
votes
Accepted
What's the value in exposing the dependencies you used for your tests?
There is absolutely no value. Indeed information not used in runtime is actively detrimental after deployment.
However, Maven is a very old and simple tool. It does not do any processing of POM file ...
2
votes
Multithreaded processing of single REST requests
It feels wrong two spin up additional threads for each incoming request.
Yes, it is wrong. Not only inefficient, but also a security concern: you open your server to hard DOS attacks. And it doesn't ...
0
votes
Multithreaded processing of single REST requests
You can use parallel stream.Simple yet efficient approach for the use case. However,you need to have rough estimates of how many max users you are expecting.If they are huge, opt for completablefuture ...
3
votes
How to avoid init methods when 2 objects need the reference of each other?
Another option to consider is whether MyLabel needs to exist outside of MyView at all. Sometimes it is best to simply create the object where it is needed.
public class MyView {
private final ...
-1
votes
How to avoid init methods when 2 objects need the reference of each other?
Just ignore what you heard about “code smells”.
Just create a subclass of View. And give it an init method that creates a complete instance: Init the baseclass, create all the subviews, make them ...
8
votes
How to avoid init methods when 2 objects need the reference of each other?
However, how to eliminate init when 2 objects need to reference to each other? For example, there are 2 UI Views: MyView and MyLabel, which MyView has a child view MyLabel, but MyLabel also needs to ...
Top 50 recent answers are included
Related Tags
java × 4950design-patterns × 503
design × 493
object-oriented × 483
object-oriented-design × 242
architecture × 201
c# × 175
spring × 156
c++ × 153
interfaces × 151
exceptions × 146
programming-practices × 135
multithreading × 123
android × 123
unit-testing × 114
rest × 110
algorithms × 108
coding-style × 105
inheritance × 98
java-ee × 91
performance × 90
api-design × 83
programming-languages × 82
database × 81
testing × 79