Java is a high-level, platform-independent, object-oriented programming language originally developed by Sun Microsystems. Java is currently owned by Oracle, which purchased Sun in 2010.

learn more… | top users | synonyms

21
votes
5answers
7k views

Efficient way to shuffle objects

I'm writing a program for some quiz software. I have a question class containing the ArrayLists for the question, answer, options, marks and negative marks. Something like this: class question { ...
19
votes
7answers
3k views

Does modular programming affect computation time?

Everyone says that I should make my code modular, but isn't it less efficient if I use more method calls rather than fewer, but larger, methods? What is the difference in Java, C, or C++ for that ...
13
votes
6answers
5k views

Are Java's public fields just a tragic historical design flaw at this point? [closed]

It seems to be Java orthodoxy at this point that one should basically never use public fields for object state. (I don't necessarily agree, but that's not relevant to my question.) Given that, would ...
8
votes
6answers
920 views

Static functions vs classes

Let's say that I want to build some utility functions to do some basic maths with the BigDecimals, for example I want to have a function that computes the average of a List<BigDecimal>. What is ...
2
votes
7answers
1k views

tips, guidelines, points to remember for rendering professional code? [closed]

I'm talking about giving clients professional looking code. The whole nine yards, everything you hardcore professional highly experienced programmers here probably do when coding freelance or for the ...
25
votes
9answers
10k views

Is there any reason to use “plain old data” classes?

In legacy code I occasionally see classes that are nothing but wrappers for data. something like: class Bottle { int height; int diameter; Cap capType; getters/setters, maybe a ...
21
votes
11answers
2k views

Does low latency code sometimes have to be “ugly”?

(This is mainly aimed at those who have specific knowledge of low latency systems, to avoid people just answering with unsubstantiated opinions). Do you feel there is a trade-off between writing "...
17
votes
2answers
1k views

Java: why do collections accept a Comparator but not (a hypothetical) Hasher and Equator?

This issue is most apparent when you have different implementations of an interface, and for the purposes of a particular collection you only care about the interface-level view of the objects. For ...
15
votes
6answers
3k views

Using nested public classes to organize constants

I'm working on an application with many constants. At the last code review it came up that the constants are too scattered and should all be organized into a single "master" constants file. The ...
14
votes
2answers
4k views

What does “GPL with classpath exception” mean in practice?

Oracle seems to license all their Java-related open source code under the GPL with a classpath exception. From what I understand, this seems to allow to combine these libraries with your own code into ...
13
votes
2answers
2k views

What is the best approach for inline code comments?

We are doing some refactoring to a 20 years old legacy codebase, and I'm having a discussion with my colleague about the comments format in the code (plsql, java). There is no a default format for ...
12
votes
1answer
2k views

Multiple Dispatch vs. Function Overloading

I'm trying to understand the difference (if any) between the two. According to the Wikipedia page for Multiple Dispatch it is synonymous with Function Overloading, but then later on goes on to say: ...
11
votes
3answers
684 views

Introducing a new JVM programming language into an established enterprise environment

Imagine that your current workplace is a Java shop. There is a lot of built-up knowledge about the Java language and there is a comprehensive build and deployment process in place to handle everything ...
10
votes
5answers
2k views

What are you thoughts on GWT? [closed]

Since I'm learning Java in this period and I just finished with the tutorials I think I'm ready to start contributing to a project (since I know from experience this is the best way to really learn). ...
9
votes
3answers
1k views

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 ...
8
votes
3answers
4k views

Can Java be considered a managed programming language?

I am curious; can Java be referred to as a managed language? I am mainly thinking about the Microsoft model when it comes to unmanaged versus managed code (say native vc++ to C#). With the ...
8
votes
2answers
7k views

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/...
8
votes
3answers
2k views

Design pattern for window management in a Java Swing app

I've just started creating my very first little Java Swing app. When the program opens, it brings up a single, simple window with a label and a couple buttons. Clicking one of those buttons is ...
6
votes
4answers
8k views

Which design pattern is more suitable for logging?

I should log some events in a program but as far as I know it would be better to keep the logging code outside the program because it is not about the real functionality of the program. So may you ...
4
votes
2answers
694 views

Do wildcards in Java generics restrict or increase flexibility?

I have read many sources about wildcards and Java generics. Even though I have seen many explanations and answers, none of them seems correct. The question is very simple: Do wilcards in Java ...
4
votes
3answers
598 views

Improving exception handling? [duplicate]

I am a newbie programmer and I recently started learning about exception handling in Java. I know what try, catch and finally blocks do, but I really need to understand how to use them well and where ...
3
votes
8answers
2k views

Is it necessary for Java programmers to learn some C/System programming?

I've read a blog(in Chinese only) in which the author had jeered at Java programmers who know little about C and system programming. The author illustrated how he had found the deep reason of a Java ...
2
votes
3answers
934 views

What is minimalistic setup for Agile Development for a small team?

I have 10 developers and 3 Testes team and I want to setup CruiseControle as CI for automated builds, tests and deployment to production server and some repository for SCM ( Source Code Management). ...
2
votes
2answers
464 views

Problems with OO design for application with pluggable components

I'm trying to refactor an ugly code and make it easly extendable in the future. The application should be nothing else but a series of components that have input(s) and output(s). The components ...
0
votes
4answers
2k views

what is best book to learn optimized programming in java [duplicate]

Possible Duplicate: Is there a canonical book for learning Java as an experienced developer? Let me elaborate a little: I used to be a C/C++ programmer where I used data structure concept ...
0
votes
1answer
298 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'...
20
votes
6answers
3k views

Why did the team at LMAX use Java and design the architecture to avoid GC at all cost?

Why did the team at LMAX design the LMAX Disruptor in Java but all their design points to minimizing GC use? If one does not want to have GC run then why use a garbage collected language? Their ...
18
votes
7answers
1k views

How do I avoid “Developer's Bad Optimization Intuition”?

I saw on a article that put forth this statement: Developers love to optimize code and with good reason. It is so satisfying and fun. But knowing when to optimize is far more important. ...
18
votes
11answers
2k views

Is pure oop necessary [closed]

Please don't direct me to this post: http://stackoverflow.com/questions/1551/how-to-think-in-oo. I have read it and still have no answer. I have programmed c++ for years and was taught that ...
14
votes
3answers
26k views

Best practices for constants [closed]

How do you guys handle constants, especially in Java (static final) and C++ (define)? Do you use dedicated headers (C++) or classes (Java) for all constants? Do you turn all literal values into ...
13
votes
5answers
3k views

How to code in a more functional style in Java? [duplicate]

I code Java for at least 5 years now and I really appreciate how the language works. When looking at new JVM languages (e.g. Scala, Clojure) there is a trend to more functional ways to code and this ...
13
votes
5answers
4k views

Why is the 'final' keyword used so little in the industry? [closed]

Since I discovered the powers of the final keyword in Java a few years ago, it helped me to make my codes a lot more readable, since people can easily see what are read-only variables. It may also ...
10
votes
9answers
490 views

Studies on code documentation productivity gains/losses

After much searching, I have failed to answer a basic question pertaining to an assumed known in the software development world: WHAT IS KNOWN: Enforcing a strict policy on adequate code ...
7
votes
5answers
2k views

Suggest other people's code to study [closed]

What open source Java code would you suggest for me to study? EDIT: I'm interested in the design, simplicity(?), their programming style, logic. EDIT2: The first thing that came to my mind is ...
7
votes
5answers
2k views

When and why would we use immutable pointers?

In Java, the String object is both immutable and also a pointer (aka reference type). I'm sure there are other types/objects which are both immutable and a pointer as well and that this extends ...
7
votes
2answers
11k views

What does RESTful web applications mean? [duplicate]

Possible Duplicate: What is REST (in simple English) What does RESTful web applications mean? A web service is a function that can be accessed by other programs over the web (Http). To ...
6
votes
10answers
23k views

Do coding puzzles make good interview questions [closed]

I am interviewing candidates for Java programmer positions. My colleague insists in filling more than half of the interview with java coding puzzles.His view is that, if candidates are able to ...
6
votes
6answers
795 views

Why are my unit tests so expensive? [duplicate]

I am a Java developer, working on a small project. We are three people in the team, we have a budget for 3 months of coding (+ some time for the Analyst, Project Manager and QA team). It is a small ...
6
votes
4answers
3k views

Is JavaBeans a good example of encapsulation?

I'm trying to understand if JavaBeans is a good example of encapsulation. In my view, it's not as usually all the internal state is exposed through getters and setters. A simple example is public ...
4
votes
3answers
848 views

Storing object-graphs with class-evolution in Java with transformation (long time archiving)

Abstract A common problem is to store objects (with graph), and to load them back. This is easy as long the stored object representation matches the executing code. But as time goes by, requirements ...
4
votes
4answers
13k views

How to run an applet like a desktop application without installing entire JDK?

I want to make a desktop application- an analog-clock with the option of setting alarms using java. For rendering all the graphics and the button features, a Swing applet is the answer. But the ...
3
votes
9answers
2k views

C vs C++ for a Java (and possibly python) Programmer [closed]

I am a Hobbyist Java programmer and I would like to further my programming skills by learning C or C++ and Python. I have read many C vs C++ articles but none of them contain the information I'm ...
3
votes
7answers
1k views

How can I get started on my first non-trivially sized Java project? [closed]

In a month, I have to hand in a Java project. I have to make an e-shop program which has two types of users (admin and normal users). The admin can add/delete/restock stuff in the shop while the ...
0
votes
9answers
9k views

Line break before/after operator [closed]

While Sun's Java code convention suggests to put line break before the operator many other guidelines disagree with it. I do not see any obvious pros and cons, so are there advantages of using one of ...
0
votes
3answers
656 views

Checking for the presence of optional properties of an object

I'm designing a class that holds several types of data. Some of the properties are optional. For example, let's say I have a class that represents a person, and one of the properties is occupation. ...
0
votes
5answers
2k views

The need for adding an interface to every class [duplicate]

My coworker and I are arguing very hard about this topic. He's thinking that every single class should have an Interface that the class implements (also Single-Implementations). He uses this design ...
24
votes
7answers
3k views

Is there any practical way for a linked node structure to be immutable?

I decided to write a singly-linked list, and had the plan going in to make the internal linked node structure immutable. I ran into a snag though. Say I have the following linked nodes (from previous ...
19
votes
9answers
1k views

Advantages and Disadvantages of Forced Code Reformat

I'm currently working at a place that may be looking at forcing developers to use an automated code formatter on version control check-in. I'm looking for developers opinions on the advantages and ...
14
votes
9answers
2k views

Isn't class scope purely for organization? [duplicate]

Isn't scope just a way to organize classes, preventing outside code from accessing certain things you don't want accessed? More specifically, is there any functional gain to having public, protected, ...
12
votes
7answers
960 views

Thinking of simultaneously coding the same project in two languages. Good Idea? [closed]

Is this a good way to learn a new language? Or to develop a preference of one language? I was thinking of coding a project in both Python and Java. The only foreseeable problem is trying to transfer ...