Tagged Questions
1
vote
3answers
45 views
Why addListener() typically returns void?
Am seeing that a typical addXXXListener() returns void !
I have seen this as a practice across the board whether it is UI frameworks (like Swing) or server-side frameworks.
For ex:
Class: ...
28
votes
9answers
21k views
Conveniently map between enum and int / String
When working with variables/parameters that can only take a finite number of values, I try to always use Java's enum, as in
public enum BonusType {
MONTHLY, YEARLY, ONE_OFF
}
As long as I stay ...
3
votes
6answers
1k views
What's the Scala way to implement a retry-able call like this one?
Still the newbie in Scala and I'm now looking for a way to implement the following code on it:
@Override
public void store(InputStream source, String destination, long size) {
ObjectMetadata ...
0
votes
6answers
721 views
Dealing with ugly SQL in Java
Here goes a SQL-Java coding style question...
How do others here deal with creating complex custom queries in Java cleanly?
I am speaking of the seemingly simple task of preparing a string which is ...
0
votes
1answer
32 views
Code structure with Asynctask Android
I guess I am just producing "Spaghetti-Code". Perhabs some experts can help me write a better code for my solution. Following Pseudocodes will show my problem:
I have some procedures that runs long. ...
4
votes
2answers
60 views
good practices while using enums in java
I have a problem related with implementing something in Java and I guess Enums are a part of it (or maybe it's just me who made them a part of the problem.
So the thing is I have a model class, lets ...
1
vote
2answers
71 views
C++ NEW Object as parameter (Like Java)
I'm coding some stuff in C++, and as always we have some "thoughts" if something similar exists on the language...
I'm now, with an doubt about objects passing as parameters.
What I always do, is ...
0
votes
3answers
38 views
How to decide whether is-a or instanceof relationship is suitable in a given situation?
OK, this has happened to me many times now so I might as well ask the community. I often have a problem deciding whether declaring something as an instance or as an is-a inheritance (and declaring an ...
0
votes
1answer
38 views
Java Code beautifier/formatter library with PHP, JavaScript support
I'm searching a java library that formats/beautifies a given source code snippet. The library should support at least PHP and JavaScript source files.
The reason why i'm searching this is because the ...
7
votes
3answers
508 views
Performance of reflection: quality byte code in JVM
Edit 2:
Does a program with a fully object-oriented implementation give high performance? Most of the framework is written with full power of it. However, reflection is also heavily used to achieve it ...
0
votes
6answers
61 views
Which is better of the two: if-elif-else or if-else
This is not a homework question, this question is a result of just another discussion with my friend.
I searched a lot but could not find any reliable source which establishes the answer with proper ...
19
votes
5answers
4k views
Where should I put @Transactional annotation: at an interface definition or at an implementing class?
The question from the title in code:
@Transactional (readonly = true)
public interface FooService {
void doSmth ();
}
public class FooServiceImpl implements FooService {
...
}
vs
public ...
2
votes
1answer
108 views
Coding standard for calling multiple methods on same object in Java/ C# [closed]
Could this code snippet
StringBuilder builder = new StringBuilder();
builder.Append("Have a ");
builder.Append("nice day!");
be better written like this?
StringBuilder builder = new ...
6
votes
5answers
140 views
Should callers check validity of arguments before calling constructor?
I have been reading a lot about TDD and clean code recently so I start working on a simple project that puts these to use and I have come up against something that I am really not sure what the best ...
0
votes
3answers
32 views
Dictionary: hard-coded vs. external file
I have a java application which is started and stopped multiple times per second over hundreds of millions of items (called from an external script).
Input: String key
Output: int value
The purpose ...