Skip to main content

All Questions

283votes
6answers
168kviews

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: ...
Johan Sjöberg's user avatar
22votes
6answers
13kviews

Efficient try / catch block usage?

Should catch blocks be used for writing logic i.e. handle flow control etc? Or just for throwing exceptions? Does it effect efficiency or maintainability of code? What are the side effects (if there ...
HashimR's user avatar
276votes
14answers
125kviews

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 ...
Slamice's user avatar
  • 2,657
59votes
9answers
49kviews

Should the methods of a class call its own getters and setters?

Where I work I see lots of classes that do things like this: public class ClassThatCallsItsOwnGettersAndSetters { private String field; public String getField() { return field; }...
Daniel Kaplan's user avatar
56votes
3answers
74kviews

Which is a better practice - helper methods as instance or static?

This question is subjective but I was just curious how most programmers approach this. The sample below is in pseudo-C# but this should apply to Java, C++, and other OOP languages as well. Anyway, ...
Ilian's user avatar
17votes
3answers
43kviews

How to test the data access layer?

I have a DAO method that utilizes Spring for JDBC access. It calculates a seller's success rate of selling an item. Here is the code: public BigDecimal getSellingSuccessRate(long seller_id) { ...
Michael's user avatar
46votes
6answers
7kviews

How necessary is it to follow defensive programming practices for code that will never be made publicly available?

I'm writing a Java implementation of a card game, so I created a special type of Collection I'm calling a Zone. All modification methods of Java's Collection are unsupported, but there's a method in ...
codebreaker's user avatar
10votes
4answers
28kviews

Replacement for instanceof Java?

So I'm fairly new to programming in the real world (outside of academic projects) and have come across lots of posts saying that using instanceof is a bad thing to use to determine what class a ...
Thomas Mitchell's user avatar
87votes
10answers
111kviews

How many lines per class is too many in Java? [closed]

In your experience, what is a useful rule of thumb for how many lines of code are too many for one class in Java? To be clear, I know that number of lines is not even close to the real standard to ...
Michael McGowan's user avatar
84votes
8answers
73kviews

Is modifying an incoming parameter an antipattern? [closed]

I am programming in Java, and I always make converters sort of like this: public OtherObject MyObject2OtherObject(MyObject mo){ ... Do the conversion return otherObject; } At the new ...
CsBalazsHungary's user avatar
49votes
7answers
48kviews

Is it a bad practice to have an interface to define constants?

I am writing a set of junit test classes in Java. There are several constants, for example strings that I will need in different test classes. I am thinking about an interface that defines them and ...
FabianB's user avatar
27votes
6answers
34kviews

Is it a bad habit to (over)use reflection?

Is it a good practice to use reflection if greatly reduces the quantity of boilerplate code? Basically there is a trade-off between performance and maybe readability on one side and abstraction/...
Random42's user avatar
11votes
3answers
12kviews

When comparing a string variable to a string literal with .equals(), is there a standard practice for the order of items? [closed]

There are benefits to each and I understand the differences, but what is considered best / standard practice? And why? For example : "myString".equals(myStringVar) Avoids a potential NPE and does ...
BrandonV's user avatar
0votes
5answers
2kviews

Do I have to write a lot of boilerplate code if I keep working using Java? [closed]

I'm working for a company writing ERP applications. My problem is that I have to write tons of boilerplate code. I came up with ideas to automatize/prevent the drudgery but only some of them were ...
Adam Arold's user avatar
21votes
9answers
3kviews

How to teach Exception Handling for New Programmers? [closed]

How do you go about teaching Exception Handling to Programmers. All other things are taught easily - Data Structures, ASP.NET, WinForms, WPF, WCF - you name it, everything can be taught easily. With ...
Kanini's user avatar
  • 2,258

153050per page
close