PHPnews.io

Overview for 'java'

Logging in Unit Tests, a Bad Practice

Written by Yegor Bugayenko / Original link on Aug. 11, 2021

Logging is an inevitable part of debugging. Well, at least in modern high-level programming languages and architectures. It wasn’t thirty years ago, in Assembly, but it is now. Sometimes we trace variables, but rarely. More often we just print them to console. Moreover, we don’t just print them usi…


Prestructors

Written by Yegor Bugayenko / Original link on Aug. 4, 2021

Making constructors pre-process the arguments before encapsulating them seems to be bad practice. However, very often it’s necessary to do exactly that: perform some manipulations with the objects provided as arguments and only then assign them to the attributes of the constructed object. For this…


Using jenv to select Java version on macOS

Written by Rob Allen / Original link on Dec. 2, 2020

When working on OpenWhisk, I discovered that it needed a different Java to the one I had installed. Looking around the Internet, I discovered jenv which shouldn't have surprised me as I use pyenv and I'm aware of rbenv too. As I use Homebrew, these are the commands I used. Firstly install jenv, the…


Prefixed Naming

Written by Yegor Bugayenko / Original link on Mar. 3, 2020

If you look at the source code of Takes or Cactoos for the first time, you most probably, like many others, will be triggered by the naming convention, which implies that most class names have two-letter prefixes: BkSafe, RqFake, RsWithStatus, TkGzip, and so on. To be honest, I haven’t seen a singl…


Fat vs. Skinny Design

Written by Yegor Bugayenko / Original link on Feb. 19, 2020

It seems that type/class hierarchies in OOP may be designed in two extreme ways: either with full encapsulation of data in mind; or with just a few interfaces making raw data visible, and letting classes deal with it, parse it, and turn it into smaller data elements. You may be surprised, but I’m…


Date/Time Printing Can Be Elegant Too

Written by Yegor Bugayenko / Original link on Sep. 26, 2019

I owe my pretty high StackOverflow reputation to this question in particular, which I asked a few years ago: How do you print an ISO 8601 date in Java? It managed to collect a lot of upvotes since then and 20+ answers, including my own one. Seriously, why didn’t Java, such a rich ecosystem, have a…