This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!

Beeimbolo Paul

+ Follow
since Dec 01, 2018
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Beeimbolo Paul

Take a look at the method toCharArray() on the String class as I think it will help greatly simplify what you are doing.
2 years ago
Why is it so important you don't expose getters?

I prefer Joshua Blochs stance.. getters are fine but if you return something that could be mutated make an immutable copy.

At any rate why does the product object need an update method at at?

Won't this product data be backed by a database table or similar? Or is this not a Web application?
2 years ago
Why do you need to call toArray(), can't you just call size ()?

I might be wrong but the two times you do call this is it not creating a new array copying your arraylist and then you check the size and do nothing with the array?

I am not entirely sure what it is you're trying to do but you can loop a range like this.

IntStream.range(start, end).forEach(
i -> {
       // some player stuff

I typed this on my phone so apologies if syntax isn't quite right!
2 years ago
You could get a spring boot app to do this up and running in minutes and you wouldn't need to install tomcat.

2 years ago
Here is an article on how to autowire it:

The formatting is off on my example but you get the general idea, anyway hope it helps!
2 years ago
I thought you could just do that with yml?

2 years ago
I wonder if it is because your are component scanning your configuration package to try to autowire, I havent done that before. In the example below the vendor adapter is just created inside the configuration for the entitymanager factory.

I also noticed I am using spring-orm dependency as well (not sure if I have missed this, or you just dont need it?)

2 years ago

Beeimbolo Paul wrote:Can I see what dependencies you have listed in your pom file please?

And your spring configuration class, the one that is creating the JPA beans.
2 years ago
Can I see what dependencies you have listed in your pom file please?
2 years ago
I guess either, what I am trying to say is that I use variables when it makes sense to, and if that means code is easier to read then I would opt for it.

I don't work on systems with low memory requirements so declaring variables isn't any issue. I just use them when I need to and don't specifically try to go out of my way to write code that avoids using them.

On the same note I don't use them when there is no need, for example to hold the result of a call that I then return immediately.

As one of the posts above describes, it's context specific.
2 years ago
I think a good rule of thumb is to use a variable when you need to and that's dependent on what you're working on but if you require multiple calls like in your example I'd prefer to make a single call and assign that result to a variable, it's cleaner to me.

As a real life example the system I work on right now has very stringent code quality checks performed both locally for maven builds and as part of a jenkins build, and also the jenkins job to merge features to develop.

One sonar enforced build breaking rule is that you cannot have multiple return statements in any one method. So in this instance its considered better practice to assign to a single variable which is also the return variable.

I personally find code easier to read when variables are used over lots of nested method calls.
2 years ago
Are you using maven? You can use cargo and start tomcat and your app by running your integration tests against your running application.

You should be doing something like this anyway. Are you writing integration tests?

2 years ago
I would use springboot, you can get a Web app up and running in minutes using the initializr and you don't need to install tomcat.

Writing servlets by hand is OK for learning but you wont find many (if any) companies who are doing this anymore, only legacy systems.
2 years ago
You could use environment variables if you don't want to put passwords into properties files?
2 years ago
Set up an AWS account and you get free tier access for a year.

You can demo it there. If you use terraform to create your environment then as soon as your demo is over you can just destroy all of your infrastructure.
2 years ago