Hot answers tagged

8

Question- If are storing passwords in encrypted format in DB and in future when user login into our website how will we perform authentication? You never, ever store passwords encrypted. Never. Under no circumstance. Ever. Do not store passwords encrypted. Do not even consider it, not even as an exercise. You should only store passwords salted, possibly ...


6

I don't know whether the interviewer asked something wrong on purpose to see whether you would correct him or he was just simply wrong. But when you used a hash function if someone breaks into the system and find out the hash function then they cannot access the customers' passwords. Encryption is a reversible encoding hashing is not reversible. The first ...


3

It depends entirely on what your Ops setup is. Many organizations have an established operations department with procedures and ways of doing things, and they have their app servers and know how to administrate them. In that scenario, it makes sense to simply produce a WAR and let them deal with it instead of establishing new procedures for Spring Boot JARs.


3

What you're maybe looking for is simply "async programming" or non-blocking programming. The default tool to use in Java for that is CompletableFuture, unless you are using a different tool explicitly (like reactive libraries, or akka, etc.) Technically that boils down to: Converting all network calls to return CompletableFuture, for those that do ...


3

This is still a good idea in my view. The point of running microservices is not to keep their code-bases unrelated - on the contrary, reuse remains a good and valuable thing. Rather, the point is that running one service doesn't affect the other: they can be restarted, updated, debugged, duplicated etc. independently of each other. Neither the goal of ...


3

No...... but its not exactly "safe" either. The risk you are running here is that your shared library is not generic enough. It isn't a complete solution to whatever it does that will never require changing, it just code sharing what happens to be duplicate boiler plate across your projects. For example if I add say NewtonSofts Json.net library to ...


2

Short Answer Don't use JPA locking to implement this. It's insufficient to deliver a good experience in the style you defined. Record check-out information about the widgets instead. Why? Some aspects of your desired user experience ("idea/flow") do not fit well with JPA or database locking methods. "While a widget is locked it will not ...


2

In the case of repositories or other data access classes, interfaces usually exist to make testing easier. If your repository implements an interface, and your application consumes the repository as an interface rather than concrete implementation, then it is easier to isolate parts of your application that require data access. Your unit tests can mock the ...


2

Is it an anti-pattern to extract common configuration code as a library and reuse it across microservices? Not inherently. It's perfectly fine to make things that are reused reusable, which is effectively what you are doing. However... And I can see that this part would be copy-pasted everywhere. This by itself it not sufficient justification for making ...


1

This is an answer based on a theoretical standpoint. What you are designing is non-standard. Non-standard security is always a risk. And you have to decide what your risk appetite is. If you have a problem in your implementation, you are running the risk that your all users might be exposed or user data etc. Are you willing to take that risk? That is your ...


1

Classing example of orchestration flow. Orchestration flow most of the time utilizes Command pattern very well along with Aggregator. But like in the link @gnat provided, Patterns are prescribed solution to a specific software design problem. Identifying problem is most important in choice of design pattern.


1

Is it there a way to define those REST points with an application profile? If yes, I would suggest to define an application.properties or application.yml where those endpoints are stored as environment variables and you define those variables in your actual environment. This approach has as bonus the fact that you can also run your application in Containers ...


1

wouldn't any project that can acess the MyRepository interface also already be injecting the implementation class? It helps if the interface is not in the same package as the implementation :D In Figure 2 in the image above, Object B depends on the { Object A + Interface A } combo (Package A). This is called dependency inversion. Instead of thinking of it ...


1

Should I create the databases beforehand... I think so. In my opinion, database settings, users, grants and some of the index should be DB scripts that we can execute anywhere and anytime to re-create or fix the database. My reasons to believe it are two. First, the user creating and setting up the DB has too many privileges as for us to set it as the ...


1

If mixing the event publishing code with your other code is an issue for you, it might be an option to apply the decorator pattern. Instead of directly calling your implementation of the UserService, call another one which has the same signature but which is solely there to first forward the call to UserService and secondly publish the event(s). By doing so ...


1

The first scenario seems a good approach. By default, the method getCar should just return the Car object without the Engine (as it is set to be fetched lazily). If the controller needs the Car and the Engine, an option is to provide an additional method CarService#getCarWithEngine. Such a method, will explicitly load and return the Car with the Engine (see ...


1

Sprout and Split You've got Sprouting down pat. You've already moved business logic into its own functions. Hopefully while you were doing this you were deduplicating and generalising the code too. The next trick is to split this class into two or more classes. Your friend put it as making a Helper class, I find that terminology unhelpful. Its like a class ...


1

If the count of the inserts/updates is the only thing you need, quick (and possibly dirty) solution might be to keep using saveAll method and selecting the count of the entities in the database before and after the saveAll call -- all wrapped in a transaction of course. Knowing the size of the collection passed to saveAll you can calculate how many entities ...


Only top voted, non community-wiki answers of a minimum length are eligible