Subscribe: Eclipse Zone - Community for Eclipse users and developers
http://www.eclipsezone.com/rss/rssmessages.jspa?threadID=52193
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
application  array assertequals  array  assertequals rank  developer  edition  effective java  framework  java  mid  rank array  rank  world 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Eclipse Zone - Community for Eclipse users and developers

DZone Java Zone



Recent posts in Java on DZone.com



 



This Week in Spring: Kafka, Spring Cloud, and Testing

Fri, 19 Jan 2018 14:59:47 GMT

Aloha! This week I’m in sunny Honolulu for the first annual LavaOne conference. If you’re not here, you should be! The show is amazing, enjoys 50% female to male audience attendance, the speakers are world-class (well, except yours truly, but don’t tell them that..), and the location is pretty hard to beat!

That said, nothing gives me more pleasure than saddling up to a table with a laptop, some green tea, sunglasses, and sunscreen and checking in on the community. This week’s been a heckuva week indeed! Lot’s of great stuff so let’s get to it!




9 Things Java Programmers Should Learn in 2018

Fri, 19 Jan 2018 08:01:01 GMT

First of all, I wish you a very happy new year, guys. It's that time of year when we start afresh, make plans, set goals, and make resolutions for the new year.

Being a Java developer and the author of a Java blog, I frequently receive requests from Java programmers from all over the world asking how they can improve themselves.




Why You Should Take a Look at Kotlin's Standard Library

Fri, 19 Jan 2018 05:01:01 GMT

As we add support for Java deployments at Octopus, more integration code is being written in Kotlin. As a longtime Java developer, I took the opportunity to learn some of the improvements that the Kotlin language designers added to their language over Java.

About the same time, I completed Dave Fancher's Functional Programming with C# course on Pluralsight. I enjoyed the course because it provides some clear and practical advice on how to approach function programming in C#. In it, Dave provides two extension methods, Map and Tee, which allow you to transform objects and pass them onto other mutating methods, along with examples on how and why you would use them.




Java Quiz 9: Demonstrating Multilevel Inheritance

Thu, 18 Jan 2018 14:02:14 GMT

Before we start with this week's quiz, here is the answer to Java Quiz 8: Upcasting and Downcasting Objects.

By upcasting objects, the overridden variable depends on the type of the object reference vc, but the overridden methods depend on the type of the object that was created. By downcasting objects, both variables and methods depend on the type of the object reference car.




Docker and Java: Why My App Is OOMKilled

Thu, 18 Jan 2018 08:01:01 GMT

Those who have already run a Java application inside Docker have probably come across the problem of the JVM incorrectly detecting the available memory when running inside of the container. The JVM sees the available memory of the machine instead of the memory available only to the Docker container. This can lead to cases where applications running inside the container is killed when tries to use more memory beyond the limits of the Docker container.

The JVM incorrectly detecting the available memory has to do with the fact that the Linux tools/libs created for returning system resource information (e.g. /proc/meminfo/proc/vmstat) were created before cgroups even existed. These will return resource information of the host (physical or virtual machine).




Play Zork, Learn OAuth

Wed, 17 Jan 2018 22:57:38 GMT

In the early '80s, some of the best “video” games were text-based adventures. These games would print out descriptive text of your surroundings and you would interact with the game using simple, but natural language commands like: “go north” or “take sword”. Fast forward some 30 years and a specification for an authorization framework called OAuth 2.0 was published. This framework allows an application to receive a token from an external party (like Okta) that indicates a user is authorized to use the application. What do these two things have in common? Absolutely nothing. But, I thought it would be fun to mash them together to demonstrate how OAuth works by playing a text-based game.

Infocom was a popular producer of text-based games and they standardized a file format and interpreter for them called zMachine. There’s a great zMachine interpreter written in Java. I incorporated this into a Spring Boot/Spring Security application that interacts with Okta for OAuth so that you can play Zork — one of the most iconic of these games. The application is available on the Okta Developer GitHub account.




Classification of Development Frameworks for Enterprise Apps

Wed, 17 Jan 2018 21:01:01 GMT

If you Google "best Java framework", most probably, you will stumble on this article, which gives a great overview of the landscape in the Java Enterprise world. However, from my point of view, it lacks a very important thing — classification of the mentioned frameworks. Let's have a look at another angle at this ecosystem and go beyond the Java world.

Picking the best framework for developing an application (or another framework), means trying to find the best trade-off between the following criteria:




Java 8: Oogway's Advice on Optional

Wed, 17 Jan 2018 17:01:03 GMT

While Po was reading about Java 8 Optionals, a few questions popped into mind. Why was it added to Java? How does it save us from the almighty villain the null pointer exception?

So, he goes to Master Shifu, but the irony is that Shify was also unsure of how Optional will save the Java villagers from NPEs. But Oogway foretold their arrival, so they went to Oogway for advice on Optionals.




Would You Use JSF for Your Next Project?

Wed, 17 Jan 2018 11:01:01 GMT

There was an excellent StackOverflow blog post last week about the “Brutal Lifecycle of JavaScript Frameworks”. The article was about the speed at which JavaScript UI frameworks (Angular, Jquery, and React) come into and fall out of fashion. The key metric for this post is questions per month on the framework, which is a reasonable metric to demonstrate these trends. Downloads would have been interesting too.

It got me thinking: Where are we with JSF? And my starting point was to superimpose JSF on top of the JavaScript data.
(image)




How to Add JARs to a JetBrains MPS Project

Wed, 17 Jan 2018 08:01:01 GMT

JetBrains MPS is a wonderful tool to create DSLs. We love it and use it regularly in our consultancy work, and we have written about JetBrains MPS before.

Being a projectional editor, it allows you to easily create DSLs that can be used through a graphical interface or things like mathematical formulas, though all this power requires a bit of preparatory work.




Using Google's Protocol Buffers With Java

Wed, 17 Jan 2018 05:01:01 GMT

Effective Java, Third Edition was recently released, and I have been interested in identifying the updates to this classic Java development book, whose last edition only covered through Java 6. There are obviously completely new items in this edition that are closely related to Java 7, Java 8, and Java 9 such as Items 42 through 48 in Chapter 7 ("Lambdas and Streams"), Item 9 ("Prefer try-with-resources to try-finally"), and Item 55 ("Return optionals judiciously"). I was (very slightly) surprised to realize that the third edition of Effective Java had a new item not specifically driven by the new versions of Java, but that was instead was driven by developments in the software development world independent of the versions of Java. That item, Item 85 ("Prefer alternatives to Java Serialization") is what motivated me to write this introductory post on using Google's Protocol Buffers with Java.

In Item 85 of Effective Java, Third Edition, Josh Bloch emphasizes in bold text the following two assertions related to Java serialization:




Rust for Java Devs: Creating Variables

Tue, 16 Jan 2018 21:01:01 GMT

I’m going to do something different today and write about Rust instead of Java. This is something that I want to give a try, and if it all goes well, I will continue writing some posts about Rust in the future.

I will be writing about learning Rust from the perspective of a Java developer by making comparisons where appropriate to help you (and me) understand what is going on. These will most likely be shorter posts and, honestly, might not even contain that much information — but hopefully, someone finds these sort of posts helpful and makes it all worth it.




Effective Java 3rd Edition: A Must-Read for Every Developer

Tue, 16 Jan 2018 17:01:02 GMT

Jos(image) hua Bloch finally updated his popular book Effective Java for Java 7, 8, and 9. The previous edition was one of the most popular books among professional Java developers, and I couldn’t wait to finally read the updated 3rd edition.

I got this book two weeks ago, and it more than fulfilled my expectations. It is packed with best practices and detailed descriptions of the finer details of the Java language. Every developer should at least read the chapters about generics and lambdas.




Closures in Scala [Video]

Tue, 16 Jan 2018 11:01:01 GMT

Before we begin discussing closures in Scala, let us have a quick look at a function. The function literal bill below accepts only one input parameter: netBill. However, the function calculates the final bill by adding a service charge to netBill.

val bill = (netBill: Double) => netBill*(1 + serviceCharge/100)





An Introduction to Hollow JARs

Tue, 16 Jan 2018 08:01:01 GMT

I have written in the past about the difference between an application server and an UberJAR. The short version of that story is that an application server is an environment that hosts multiple Java EE applications side by side, while an UberJAR is a self-contained executable JAR file that launches and hosts a single application.

There is another style of JAR file that sits in-between these two styles called a Hollow JAR.




Application Design the Java 9 Way

Tue, 16 Jan 2018 05:01:01 GMT

Java 8 brought many great improvements to the language. Java 9 enhanced them further! A major paradigm shift now needs to occur. The tools that Java 8 and 9 provide for application design are immensely improved. Java 8 allows static methods on interfaces. Java 9 provides a level of organization above the package: the module. Putting these two techniques together results in better designs and stronger object-oriented guarantees.

Interfaces Rule!

It feels like interfaces passed out of favor in the Java world. There was a time when classes not implementing interfaces were considered suspicious and discussed in code review. Now, major IDEs provide class templates that automatically declare classes public and don't provide or expect an "implements" clause.




JUnit4, JUnit5, and Spock: A Comparison

Mon, 15 Jan 2018 21:01:01 GMT

Recently, I gave a talk in my local Java User Group about unit testing. Some of the content of the talk was about some popular libraries you can use in your Java project. I’ve reviewed JUnit4, JUnit5, and the Spock framework. Many of the attendees were quite surprised with the differences. In this post, I will summarize asserts, parametrized tests, and mocking.

I always like to demonstrate the concepts with examples and live coding, so I chose a simple algorithm: a Fibonacci number calculator. If you don’t know it, it’s just to generate numbers that are the sum of the two previous ones in the series: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377.




Java Annotated Monthly: January 2018

Mon, 15 Jan 2018 17:01:01 GMT

Hopefully, everyone has recovered from the holidays. November is probably one of the craziest months, a sharp contrast to late December and early January, which are some of the quietest ones, at least in my experience. People are wrapping up the year’s results, making plans for the year ahead, and of course, enjoying the holidays. If you had holidays like we did, this January digest might be helpful for updating you on what has happened in the community during the last month. If not, I hope you find the news and articles interesting anyway.

If you missed all the champagne and watched the blogs and social accounts closer than we did, please feel free to share the missing news in the comments. Since Trisha, your regular host, is still on maternity leave; I will do my best to fill in for her.




Kotlin: Tail Recursion Optimization

Mon, 15 Jan 2018 11:01:01 GMT

The Kotlin compiler optimizes tail recursive calls — with a few catches. Consider a ranking function to search for the index of an element in a sorted array, implemented the following way using tail recursion (and a test for it):

fun rank(k: Int, arr: Array): Int {
    tailrec fun rank(low: Int, high: Int): Int {
        if (low > high) {
            return -1
        }
        val mid = (low + high) / 2
 
        return when {
            (k < arr[mid]) -> rank(low, mid)
            (k > arr[mid]) -> rank(mid + 1, high)
            else -> mid
        }
    }
 
    return rank(0, arr.size - 1)
}
 
@Test
fun rankTest() {
    val array = arrayOf(2, 4, 6, 9, 10, 11, 16, 17, 19, 20, 25)
    assertEquals(-1, rank(100, array))
    assertEquals(0, rank(2, array))
    assertEquals(2, rank(6, array))
    assertEquals(5, rank(11, array))
    assertEquals(10, rank(25, array))
}





Spring, Reactor, and ElasticSearch: Benchmarking With Fake Test Data

Mon, 15 Jan 2018 08:01:01 GMT

In the previous article, we created a simple adapter from ElasticSearch's API to Reactor's Mono, which looks like this:

import reactor.core.publisher.Mono;

private Mono indexDoc(Doc doc) {
    //...
}