Skip to main content

All Questions

4 votes
2 answers
194 views

Should I write a wrapper within a manager object?

I have three classes that work together to do one function (from the perspective of the rest of my program). There is a little bit of set up between them, so, to make it easier for the rest of my ...
0 votes
1 answer
239 views

Is immutable objects over POJO in general?

Lombok is used in the legacy project where I am currently working for since last year. The project is legacy with 10+ years, and POJO/JavaBeans, i.e. @Data annotated classes, have been widely used for ...
276 votes
14 answers
125k views

Should we avoid object creation in Java?

I was told by a colleague that in Java object creation is the most expensive operation you could perform. So I can only conclude to create as few objects as possible. This seems somewhat to defeat ...
2 votes
4 answers
3k views

I wrote a class with "init" method. Should I call it from other class methods? Or leave it to the object user? (Code Design)

I have a java class with an init method. It's different from the constructor. The constructor just initializes the variables/fields. The init method connects to a database and performs some ...
9 votes
2 answers
1k views

Should function names describe their parameter types?

If you wish to perform the same action using different parameters, you can either make differently named functions: public Apple findAppleById(long id){ return repo.findById(id); } public Apple ...
2 votes
1 answer
274 views

Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?

I am currently working on a semi-large project that has several packages. There are 3 main packages, a "client" package, a "server" package and a "common" package. There are two jars, one for the ...
1 vote
4 answers
341 views

Storing both a compiled service for a Docker container as well as the container in a repository. Good practice, bad practice or no precedent?

This has erupted from quite a turbulent meeting between two senior developers, a lead developer and an engineering lead, and after 90mins reached no resolution. We create Spring Boot Java services ...
2 votes
1 answer
3k views

When should a class be final? [duplicate]

I've only really seen this on Java's wrapper classes (String, Integer, etc.), but never in open-source projects, and I was never taught about it in any books or classes. I know it means the class can'...
8 votes
6 answers
5k views

What is more important? SOLID or KISS?

What is more important? SOLID or KISS? To be consistent with SOLID I would have to inject Decorator and Footer classes and create interfaces for them. public class HelloService { String name; ...
-1 votes
1 answer
16k views

@Getter, @Setter vs @Data in lombok? [closed]

So I was sending code for review and approvals for some changes I made recently. that includes a class as below: import lombok.Getter; import lombok.Setter; @Getter @Setter public class ...
283 votes
6 answers
168k views

Choosing between Single or multiple projects in a git repository?

In a git environment, where we have modularized most projects, we're facing the one project per repository or multiple projects per repository design issue. Let's consider a modularized project: ...
2 votes
1 answer
1k views

Does it make sense to use byte instead of int in Java? [duplicate]

Recently, I had to implement a business rule in a certain project. The rule basically consisted of checking a range between 1 and 12, values that would be used later, in some way, with Bootstrap. ...
-1 votes
2 answers
262 views

Do I really need TaskManager class? [duplicate]

Background: I'm coding an app, the core idea is simple - I can choose a 'Task' (consists of name, code to perform aka Runnable, progress) through GUI, start it, stop it, start all 'Task's and stop all ...
3 votes
4 answers
780 views

Is it a bad practice to have an interface method to tell whether it can handle an object?

interface Resolver { boolean canResolve(SomeInput input); SomeOutput resolve(SomeInput input); } public static void main(String[] args) { List<Resolver> resolvers = ...; ...
1 vote
2 answers
497 views

Is using KDoc/Javadoc comments inside of a function considered bad practice?

I often find it helpful to use KDoc/Javadoc comments inside of a class or function instead of normal comments. IntelliJ colorizes them more obviously by default and, more importantly, allows ...

15 30 50 per page
1
2 3 4 5
9