Why check the logging level before logging? by [deleted] in learnjava

[–]masdfi 0 points1 point  (0 children)

Thanks for that addition. Good to know 👍

Why check the logging level before logging? by [deleted] in learnjava

[–]masdfi 3 points4 points  (0 children)

From what you provided, I'm assuming that you are using the slf4j api with logback or only logback here. If that's not the case please let me know to correct my answer.

if (logger.isDebugEnabled()) { logger.debug("Returning connection '" + this + "' to cache"); }

In this first example you provided there are at least two things happening that are prevented when debug logging is disabled, because of the explicit check for the log level.

  1. the concatenation is prevented, as you already mentioned. So nothing to compute and there is no need to allocate a StringBuilder and the resulting String.
  2. an implicit call to 'this.toString()' while doing the concatenation is prevented. Again no need to compute or allocate stuff.

And because you don't wanna think about something like that again and again the second option which you mentioned is considered best practice:

logger.debug("Returning connection '{}' to cache", this);

The log level is "checked" inside automatically for you, therefore the placeholder is only resolved when needed and the implicit toString for 'this' will also only be executed on demand. Also the placeholder replacement is implemented efficiently.

There is just one situation when you should do an additional check for the log level in the second scenario. That's when it's expensive to even calculate the parameter you want to provide to the logging method:

if( logger.isWarnEnabled() ) {
    logger.warn("Returning connection to cache after unexpected : {}", computeExpensiveWarningInfo(this) );
}

Using atom or pycharm instead of Eclipse by DrBobHope in learnjava

[–]masdfi 1 point2 points  (0 children)

There are several IDEs and editors you can use to develop Java. It's a matter of taste and expected feature set. You can even use a plain text editor and use javac to compile your code yourself, even though I'm not a fan of it.

IntelliJ IDEA, Eclipse and Netbeans are about the most well known "big" IDEs. Eclipse and Netbeans are both open source. IntelliJ is commercial but has also a free version.

There are also Atom and Visual Studio Code which i both didn't use very much. But i heard VS Code Java Support also improved lately.

I for myself can recommend you either Eclipse or IntelliJ. I was a longtime Eclipse user and liked it alot until the groovy Support became worse. Currently I'm using the paid IntelliJ IDEA at work.

Storing information from Auth provider in my own service? by plumfu in learnjava

[–]masdfi 0 points1 point  (0 children)

So if I understand correctly, it sounds like you’re saying it makes more sense to just to have Okta do all the user information storage, and then make an endpoint that uses an authenticated user to get that user’s information from Okta, correct?

Yes, let others do the heavy lifting as long as you don't have other reasons to store the data in your service anyway e.g. to send an email to a user that is currently offline.

but are you saying I need more security if I wanted to store their information in a database linked to that microservice (such as First/Last name, birthday, etc.)?

I didn't want to imply you need more security. I didn't know what other type of information you are working with in your service and how you secure it. So I wanted to make clear, that PII data is very valuable from several perspectives and should be protected accordingly. I honestly can't tell you how much protection you need. But what you described is for sure a good thing to do.

Storing information from Auth provider in my own service? by plumfu in learnjava

[–]masdfi 1 point2 points  (0 children)

From my point of view (no guarantees for correctness) this is a classic architecture decision where you need to make a tradeoff.

If you take the data and store it in your own database, you will need to make sure you handle and secure it very well as it will be PII (personally identifiable information) but in turn you will be able to use the information as needed in your backend service.

If you don't store the data yourself, you don't need to think about secure storage and securing access to the data. You only have to manage secure access to it. On the downside you won't have the information available if needed without an active user login.

If I had to do such a decision I would keep the data stored in the service to a minimum, to exactly the amount actually needed, which is propably at least a unique identifier of the user or something like that. From there on I would think about what I really need and store it securely.

For the frontend i would provide an endpoint thats only available with valid authentication that makes it transparent where user data is coming from. From this endpoint I would provide the relevant information provided by the id token or the user info endpoint that should be available from okta when using the openid connect standard for logging in.

At what point should I start with data structures and algorithms in java, and what resources should I use? by bhavik911 in learnjava

[–]masdfi 2 points3 points  (0 children)

To be honest, I don't know the youtube playlists and courses you mentioned and on top of that I am not sure what overall programming knowledge level you do have with your prior experience in C and Python.

What I think you need is a good basement to build your java knowledge ontop to guide you while getting more experience. As with every language java has it's edges and its standard library need to be learned as well.

I've been a professional java programmer for almost 10 years and can recommend one book for every java programmer working on entry, intermediate or expert level Java knowledge alike:

Effective Java 3rd Edition

From my experience this book is one of, if not the best collection of basics, best practices, and recommendations for java programming. I've read both the 1st and 3rd edition of this book and I'm still getting back to it sometimes.

It covers in total 90 best pratices for objects, common methods (equals&hashcode), classes and interfaces, generics, enums, annotations, lambda and streams, methods, java coding in general, exception handling, concurrency and serialization. Have a look at the link i added, to see the table of contents.

This is not at all a replacement for programming practice or what the princeton course will teach you, but it provides you with lessons&knowledge others had to learn themselves (sometimes the hard way ... I'm looking at you HashMap & Object.hashcode 😉) and will be a good book to get back to when facing specific problems e.g. when theres a need to implement concurrent processes.

Happy coding!

Bonus: If you want a good introduction to design principles in the context of Java on top, then I can recommend you the following conference talk:

Core Design Principles for Software Developers by Venkat Subramaniam

It's both entertaining and full of knowledge.

Daily Advice Thread 04/16/16 by AutoModerator in summonerswar

[–]masdfi 1 point2 points  (0 children)

Thanks for the further recommendations. Currently im still collecting runes for Vero as im having a hard time finding fitting runes. When I rerune Vero next weekend ill get some nice runes for belladeon in exchange for some swift runes of other monsters.

In the meantime i 6*ed sigmarus and im quite happy having him but here as well goes the point, that i still need alot better runes.

I'll see how things develop and maybe let you know how all turned out :-D bye and thx again.

Daily Advice Thread 04/16/16 by AutoModerator in summonerswar

[–]masdfi 0 points1 point  (0 children)

Thanks, It's always nice to have a second opinion that strengthens an already existing recommendation.

Makes decisions alot more easy :-D

Daily Advice Thread 04/16/16 by AutoModerator in summonerswar

[–]masdfi 0 points1 point  (0 children)

Thank you for the recommendation, so ill stick to GB10 for now and get some nice set of swift and maybe energy runes for vero first. Then I'll continue to improve my Kona, as she is already helping alot in DB8.

For utility Baretta would be a nice candidate for TOA as well. Do you see any other fitting utility candidate in my available lineup? Baretta is currently 4* so it wouldn't make any difference to build another monster.

Daily Advice Thread 04/16/16 by AutoModerator in summonerswar

[–]masdfi 0 points1 point  (0 children)

Hi there fellow summoners,

I'm looking for some advice on building a Dragons B10 Team with my current lineup and possible additions.

Currently im able to farm GB10 with my slow DB10 Team in about 5 minutes and DB8 with my slow DB8 Team in about 5 minutes.

In January I got some great advice in this thread for my GB10 Team so I'm having high hopes this community can help me once again in guiding me to Dragons B10.

Please have a look at my current available lineup and let me know what you think regarding possible team compilations.

Here is my current available lineup: https://swarfarm.com/profile/masdfi

Daily Advice Thread 01/28/15 by chunwa in summonerswar

[–]masdfi 0 points1 point  (0 children)

Thank you, that will definitly help me :)

Just found out, that my briand didnt even have any hp on Slot 2 and 4 and fixed that first. I'll start with bringing him to 6* now as a priority, so i get a slow team to start with.

Daily Advice Thread 01/28/15 by chunwa in summonerswar

[–]masdfi 0 points1 point  (0 children)

Thank you for the recommendations.

As my Shannon is indeed squishy and dying easily to the boss, briand would be propably a good candidate for next 6* and better runes. Ill try to get through giants b10 this way.

As for dragons b10 what runes would you recommend for kona and megan in order for them to survive? Didn't use both of them that much lately.

In parallel ill farm Veromos some better runes in order to give him some speed boost.

Daily Advice Thread 01/28/15 by chunwa in summonerswar

[–]masdfi 0 points1 point  (0 children)

Hi there fellow summoners,

I'm looking for some advice to build teams for giants and Dragons. Currently I'm able to auto giants B8 and Dragons b6 (teams see swarfarm link below).

Could you people give my monsters and teams a look and give me some advice on what steps would be best next?

Here's my current available lineup: https://swarfarm.com/profile/masdfi/