1
vote
2answers
230 views

Is it okay if we use an arbitrary string as UUID?

I found the tutorial of client (android) and server (pc) bluetooth tutorial from here. But my question is about the UUID. Is that okay if we define it randomly without the proper format? Because I ...
0
votes
1answer
76 views

Automatically create or update object in database

I have a database class with the following interface: public Database { //returns false if p (its ID) is already available //otherwise adds p the the list and returns true public boolean ...
4
votes
2answers
208 views

Can decoupling hurt maintainability in certain situations?

Can the fact that the business logic is mapped to interfaces instead of implementations actually hinder the maintenance of the application in certain situations? A naive example with the Java's ...
0
votes
3answers
90 views

Wrapping a map with instance or static method

I have a java.util.Map<String, Object> object which different types of values in it. I don't want to cast whereever I do a get operation over this. To do this, I created different classes ...
1
vote
1answer
54 views

Alternatives to JDT Annotation - License issues

I have used the JDT Annotation library in my Java project as I am quite fond of what it offers. To be more exact, I used the @Nullable and @NonNullByDefault annotations as I can use the synergy with ...
0
votes
5answers
263 views

Is it a good practice to wrap collection in Java? [closed]

I came across a snippet like this, and find it's over engineering. Is it a good practice? public class SchoolList extends ArrayList<School> { } public class School extends ...
1
vote
1answer
156 views

Pythonic version of Java interfaces

I fully acknowledge that Python and Java are different programming languages and should be used differently. That said, "Program to an interface, not to an implementation" is good language-agnostic ...
4
votes
2answers
883 views

When is it worthwhile to replace working mature code with frameworks+patterns

I fear that frameworks in many cases have become a fashion or trend and are being abused. In many ways people are sacrificing speed just because they want to keep up with every single lib that comes ...
1
vote
1answer
217 views

What is the accepted practice for string resource management in java?

In Android, final strings are stored in a strings.xml file, which makes it easy to update text, reuse strings and to translate an app to a different locale -- because everything is in one place. ...
3
votes
5answers
5k views

Java web application folder structure

As a beginner to J2EE, I have recently started developing my own project from scratch using the Core of J2EE : Servlets & Jsps. I could not evaluate whether my project folder structure is right ...
5
votes
3answers
3k views

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) { ...
3
votes
3answers
738 views

Ordering if conditions for efficiency and clean code [closed]

This is purely a design question and the example is simple to illustrate what I am asking and there are too many permutations of more complex code to provide examples that would cover the topic. I am ...
0
votes
1answer
121 views

Get entities ids from two similar collections using one method

I've got two lists: List<Integer, ZooEntity> zoos; List<Integer, List<ZooEntity>> groupOfZoos; These operations will return collections of values: Collection<ZooEntity> cz ...
-2
votes
2answers
3k views

how to write good programming logic? [duplicate]

recently I got job as a java developer, and now I have assigned project too. I want to know what is a good logic? when I check in the code my team lead is saying that its a good code. But when it ...
2
votes
1answer
358 views

Is this high coupling?

Question I'm currently working a on an assignment for school. The assignment is to create a puzzle/calculator program in which you learn how to work with different datastructures (such as Stacks). ...
0
votes
2answers
3k views

How to update an existing excel file using java program? [closed]

I've made a file browser in java that opens and read already been made excel files. (using Apache poi 3.9 library) program read those files perfectly but i want to update some of those files. how can ...
2
votes
3answers
440 views

Parallel Class/Interface Hierarchy with the Facade Design Pattern?

About a third of my code is wrapped inside a Facade class. Note that this isn't a "God" class, but actually represents a single thing (called a Line). Naturally, it delegates responsibilities to the ...
1
vote
1answer
196 views

Are Protected Auto-Cast Methods Ok?

I often have superclasses that contain a more abstracted form of a class as a member variable than my subclasses need. I find my code littered ((ClassName)variableName).methodName(). Is the best way ...
3
votes
2answers
288 views

Can classes violate Single Responsibility if they delegate internal tasks?

I have two classes Output and Timeline, neither of which violate SR, but the two of them are linked together. So what I'd like to do is have a class called Elco (there's a reason behind the name) that ...
-3
votes
2answers
2k views

Java: The best way to learn it when MOOCs and books are not enough? [closed]

This topic was taken from Stack Overflow, but it was put on-hold due to Opinion-based question. So I moved it to here. I've had some great troubles with my homework exercises and I've used ...
0
votes
1answer
106 views

Creating Set Subclasses or Allowing Outside Configuration

I have a TriggerCaller and a TriggerAction class. The Caller "calls" the do() method on the action, which is set with the TriggerCallers setAction() method. The rest of the program should deal with ...
3
votes
5answers
316 views

Need thoughts on a course curriculum for an entry-level programmer [closed]

Would love to know your thoughts on a curriculum that will be developed for people that want to get started in the programming field. The goal of the course is to help it's students to ensure that ...
1
vote
2answers
220 views

if i have many calls of single method that returns field value, is it better to make a local variable?

In a method, i have calls of single method of another object that returns field value, like foo.value(), which is defined like Field value() {return this.value;} Is it better to make a local variable, ...
3
votes
3answers
1k views

articles in variable names and hard-coding strings

re-edited by author: no this is not 2 questions. This is one question about code review questions containing two separate points. Please do not edit my question. For naming variables, the two sides ...
3
votes
3answers
1k views

When should I use or not BooleanUtils.isTrue(…) and BooleanUtils.isFalse(…)? [closed]

About this function: org.apache.commons.lang3.BooleanUtils.isFalse(Boolean bool) and the similar isTrue, my co-work (less experienced) use it for every boolean in the code. I am trying to convince him ...
0
votes
2answers
98 views

Making subclass more type-specific with accessors

I have a super class: TriggerManager with a subclass TimedTriggerManager. NOTE: I'm working in java TimedTriggerManager only deals with TimedTrigger s, a subclass of Trigger. TriggerManager ...
0
votes
2answers
164 views

Code formatting for variable declarations [closed]

Is it looked down upon or bad to write multiple variable declarations on the same line? As in: boolean playMoreGames = true; int length; boolean win; int ...
3
votes
1answer
80 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 ...
4
votes
2answers
394 views

How to delete an object when other things reference it (and not making the code full of inter-dependencies)

The situation: In my program, there are a list of cues. To call a cue at a certain time, there are objects called Triggers. Cues have many public methods that allow them, among other things, to be ...
4
votes
4answers
568 views

Is it bad programming practice to check if a class referenced by its interface is an instance of another class?

I have a class (Timer) with an array list of Timable objects. Timeable is an interface. There is some specific functionality that I need for the Trigger class (implements Timable), which has a ...
0
votes
1answer
63 views

How to record/store edits?

In many programs and web apps (stack exchange included) the program is able to backtrack what edits where made to the piece. My issue is similar: I want to be able to store a "timeline" of edits, ...
1
vote
2answers
109 views

When to store values in constants/finals

This might seem like an odd question, but I'm worried that I'm putting too many things as constants/finals at the top of my java class. I've started to put every value that is in my program into a ...
1
vote
3answers
503 views

What is the preferred access modifier for instance variables of a data transfer object?

I'm creating a data transfer object and can't decide whether it would be better to just give public access to the instance variables or if there would be a purpose to using getters and setters to ...
1
vote
2answers
136 views

Is repeating links to the same class in a single javadoc comment a bad practice?

I'm currently writing an API and its documentation. For example I have something like this: public interface Event { } public interface Process { } public interface EventProcessor { /** * ...
6
votes
2answers
2k 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 ...
3
votes
2answers
619 views

Programming methodology - best way to level up? [closed]

Ok, so I'm at a point where I think I have my basics down. I'd like to think I'm just starting to become an intermediate dev. So, how do I level up here? It feels like I have reached my threshold, ...
1
vote
2answers
231 views

Wrapping specific checked exception in domain unchecked ones? [duplicate]

Uncle Bob says in Clean Code book that Unchecked Exceptions should be used. Now JDK has some checked exceptions: IOException, IllegalAccessException etc. which cannot be avoided. In my application ...
5
votes
4answers
714 views

Differences in If… Else… statement

When I first started to learn programming I remember having an argument with my teacher about If Else statements. I was arguing that: if { ... } else if { ... } ... is basically the ...
6
votes
4answers
3k views

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 ...
21
votes
9answers
4k views

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; ...
13
votes
2answers
1k 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 ...
6
votes
5answers
404 views

Everything has an Interface [duplicate]

Possible Duplicate: Do I need to use an interface when only one class will ever implement it? I am taking over a project where every single real class is implementing an Interface. The ...
3
votes
2answers
2k views

Best practice for packing Java enums?

What is the best practice for packaging Java enums? is it separate file for each enum? or having same file for all the enums? What are the pros and cons ?
47
votes
2answers
16k 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: ...
9
votes
11answers
8k views

Why is using System.out.println() so bad? [closed]

Of course, it is very good use to use a logging framework for the error messages or warnings. But sometimes I use System.out.println() if I want to try something new in a short time. Is it really so ...
2
votes
3answers
212 views

A place for putting code samples in projects

Every now and then I get or write some minimal code samples to achieve tasks. What's the usual practice for storing these samples (which could prove useful later on) ? Have a separate source folder or ...
7
votes
3answers
2k views

Multiple Same Object Instantiation

What exactly happens in Java when you instantiate the same object multiple times? For example: Test test = new Test(); then later on I will call it again, Test test = new Test(); again or inside a ...
4
votes
3answers
301 views

When module calling gets ugly

Has this ever happened to you? You've got a suite of well designed, single-responsibility modules, covered by unit tests. In any higher-level function you code, you are (95% of the code) simply ...
98
votes
11answers
18k 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 ...
1
vote
1answer
210 views

Synchronously write file

I am implementing a server in C for a course project. The server should serve more than one client simultaneously. The description of the project states that fork() should be used to serve more than ...