Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm looking for a solution to the excessive verboseness of Java without using Groovy

I like how Groovy makes all of your instance variables and class variables public and writes getters and setters on your behalf. This saves a lot of unnecessary coding. On the other hand, my boss hates it, making me very sad :(

Is there a way to achieve the conciseness of Groovy in Java without having to use Groovy or some other framework/add-on?

I have a feeling the powers that be will not take kindly to the introduction of this foreign framework where I work.

So what I'm looking for is a solution to the excessive verboseness of Java without using Groovy or something like it.

Can it be done in Java alone - such as by simply making everything public?

like image 541
Harry Quince Avatar asked Dec 02 '22 08:12

Harry Quince


1 Answers

The Java language is what it is. You won't find much to change the core language without moving to a new language (like groovy). Getting buy-in from management might not be as hard as you think to move to groovy. I was in a similar position as you a few years ago. You can start introducing groovy into a few areas of your software that make sense.

A great place to start is to start using it for unit testing. Essentially when you write a class in groovy, it compiles down to Java bytecode. As long as you have the groovy jars on your classpath, others may not even know it is groovy code. By using it for testing, you can demonstrate how it simplifies your code and makes things easier. You should be able to sell that to management.

From there, keep introducing it in other new areas where a dynamic language would save you some work. Groovy and Java mix very well together since they use the same set of core libraries.

like image 193
Chris Dail Avatar answered Feb 16 '23 01:02

Chris Dail