Java Lobby Announcements

Subscribe to Java Lobby Announcements feed
Recent posts in Java on DZone.com
Updated: 6 min 13 sec ago

Mutator Methods Are Fine, but "get" and "set" Don't Communicate Intent

Thu, 2016-03-10 12:31
A few days ago I tried to help you with making a decision when you should use a constructor and when a setter.

In one of the paragraph I wrote:

I don’t like setters. Why? Because those methods in some way break encapsulation.

Categories: Java

Abstract Factory or Factory Method?

Thu, 2016-03-10 09:01

Today I would like to tell you about Factory Method Pattern and Abstract Factory Pattern. The purpose of the article is to help you recognize places where one of them should be used. 

What Will We Talk About?Those patterns are one of the Creational Patterns and as the name suggest their main responsibility is creating the objects. However, we are using them in different situations.

In Wikipedia you can find the following definitions:

Categories: Java

Java Will Get Local Variable Type Inference

Thu, 2016-03-10 07:11
The Proposal

A new JEP has been proposed by Brian Goetz that would simplify the writing of Java applications. The proposal is to introduce Local Variable Type Inference, a feature that exists in many other languages today. With this new proposed feature we could write code like:

var list = new ArrayList<String>(); // infers ArrayList<string> var stream = list.stream(); // infers Stream<String>

According to the proposal, the local variable will be inferred to its most specific type. So, in the example above, the variable  list will be of type ArrayList<String> and not just List<String> or Collection<String> . This makes sense, and if we want to demote our objects, we simply have to declare them as we always did.

Categories: Java

Is Open Source Eating the World?

Thu, 2016-03-10 07:01

Thanks to Dominic Alves for the base image! CC BY 2.0

The phrase, “Software is eating the world,” first showed up in 2011. In 2015, open source took its rightful seat at the table.

Categories: Java

Costs and Benefits of Comments

Thu, 2016-03-10 04:01

As with most things in software development the ultimate currency for comments is time. How much do we have to invest and how much do they save us? Or in other words:

What are the costs and benefits of comments?

Categories: Java

JavaServer Faces 2.3 Quick Reference

Wed, 2016-03-09 18:15
Introduction

JSR 372 is currently in the Early Draft Review stage. The JSF 2.3 spec is not complete and will likely change significantly before finalization. In the meantime, here's a pragmatic deep-dive into JSF 2.3 in its current state.

For more resources, see JavaServer Faces 2.3 Tutorial and JSF 2.3 Repository Examples.

Categories: Java

@Autowired and Optional Dependencies

Wed, 2016-03-09 14:31
@Autowired annotation makes our lives easier. It also can result in a decreased amount of code if we are using it on properties of the class. We need neither constructors nor setter methods. It looks great at first glance, but the benefits rarely come without cost. Today I want to make you aware of the costs that have to be paid.@Autowired(required=false)@Autowired annotation by default has an element "required" set to true, which means that the annotated dependency is required. However, we can turn off the default behavior and make the dependency optional as follows:@Autowired(required=false) private Dependency dependency;It can be useful, and since not all dependencies are always required, introducing this possibility was reasonable.

So what’s the problem with dependencies annotated in this way? Let’s look at the code:

class SomeClass { @Autowired private DependencyA dependencyA; @Autowired private DependencyB dependencyB; @Autowired(required=false) private DependencyC dependencyC; @Autowired(required=false) private DependencyD dependencyD; }We can create an instance of the SomeClass with following dependencies (all combinations are allowed):
  • DependencyA, DependencyB
  • DependencyA, DependencyB, DependencyC
  • DependencyA, DependencyB, DependencyD
  • DependencyA, DependencyB, DependencyC, DependencyD
And this is all great, but are you sure that all of those combinations are really useable and correct? What if the author of the class thought only about 1 and 4?Optional Dependencies - Do it Right!If we are considering an example presented in the previous paragraph, there are two possible answers to the following question:
  • All combinations are possible.
  • Only a subset of the combinations is possible.
In the case when all combinations are possible, I would leave the code as it is. If there is nothing that can go wrong and each state of the object is correct, then our code is descriptive enough. It clearly allows for anything so we can assume that anything that we will do will result in the creation of an object that we may work with.

What about the second point - a subset of the combinations? Let’s assume that only creating an object in either state 1 or state 4 is valid. Leaving the code as it is can result in the wrong usage of the object. We are allowing for the creation an object in invalid states (2 and 3). What can we do about this?

Categories: Java

Enjoying Java and Being More Productive With IntelliJ IDEA

Wed, 2016-03-09 12:31

Every time I visit a Java conference or a meetup and talk to people unfamiliar with IntelliJ IDEA, I get similar questions again and again: “What’s so special about IntelliJ IDEA? What does IntelliJ IDEA has that other Java IDEs don’t?” In response, I usually simply demo a few of its features and then just watch their jaws dropping.

But you know, repeating this over and over is a bit counter-productive, so I’ve written this guide to sum up everything you need to know why IntelliJ IDEA is hailed as the most intelligent and user-friendly Java IDE, which can and will make you a more productive developer.

Categories: Java

Core Container Refinements in Spring Framework 4.3

Wed, 2016-03-09 09:01

Spring Framework 4.3.RC1 is around the corner and brings nice core container refinements which we are going to explore in this post…

Implicit Constructor Injection for Single-Constructor Scenarios

Consider the following service class:

Categories: Java

Binding Strategies for JAX-RS Filters and Interceptors

Wed, 2016-03-09 04:01

JAX-RS 2.0 defines multiple ways that server-side filters and interceptors can be bound to their target components.

  • Global Binding
  • Named Binding
  • Dynamic Binding
Global Binding

By default, JAX-RS filters and interceptors are bound to all the methods of resource classes in an application. That is, both request (pre and post) and response filters will be invoked whenever any resource method is invoked in response to an HTTP request by the client. This convention can be overridden using named binding or dynamic binding.

Categories: Java

Trailblazing Women in Science and Technology Who Inspired Us

Tue, 2016-03-08 22:58

In honor of International Women’s Day, we asked several of our women engineers here at New Relic to name the women scientists, engineers, and trailblazers who motivated them to pursue a career in technology. They chose inspirational figures from the fields of medicine, computing, astrophysics, and more—some well known and others worth learning more about.

Elizabeth Blackwell, Medical Pioneer

(chosen by Belinda Runkle, senior director of engineering)

Categories: Java

Hey Java Developers! Microsoft Would Like a Word With You

Tue, 2016-03-08 19:51

As someone who ran a fairly visible Java Users Group for 15 years, I receive lots of inquiries from potential speakers. About a month ago I received a message from a program manager at Microsoft requesting to come present on Microsoft's open source offerings for Java developers. If you had asked me 10 years ago about the chances of someone from Microsoft coming to Philly JUG to speak about Java and open source, I would have given an answer once I stopped laughing. 

Yesterday, Microsoft announced the availability of SQL Server on Linux. Today, it was announced that Microsoft was joining the Eclipse Foundation, and while they were at it, open sourced a plugin.  The announcement about Eclipse started with this:

Categories: Java

Pages