1
vote
1answer
38 views

Extend or Encapsulate [closed]

I couldn't find proper tips anywhere, since searching for these general terms isn't very efficient. I deal with this almost everyday, creating Java SWT widgets in particular. Each time I create a ...
12
votes
4answers
155 views

Tic Tac Toe game in Java OOP

I have written a simple GUI Tic Tac Toe Application and since this is my first shot, I think it can be improved a lot. Please tell me what you think about it and what you see I made wrong so I can ...
5
votes
3answers
98 views

Confusing control flow

Currently, the following code runs and produces the expected and desired output. However, I'm sure that there's much wrong with it. This project queries the (flat) database, instantiates each row as ...
3
votes
1answer
45 views

Refactoring this producer consumer class to minimize what is exposed

I don't like the service class below, specifically, the way it exposes the internals of the producer. While it would be possible to combine all three classes into one producer-consumer, I would ...
6
votes
1answer
107 views

Simple chat console app

I wanted to practice using sockets and multithreading. This is simple code where I start a Server and connect to it via Client ...
11
votes
2answers
413 views

Inventory - how to handle items?

I've been designing a game server, where a player has inventory, bank, and other features with items. There are some definitions of what item can be in my game: Item is either stackable or not ...
4
votes
1answer
118 views

Avoid flickering on game screen

This is the smallest SSCCE of my project. I get flickering on the screen with this code. Main class (on which I start the application) ...
0
votes
1answer
36 views

Where the validation should be done in a 3 layers Entity-Repository-Service application? [closed]

I am struggling to define where the validation process would be better placed in the different layers of the application? (I am not talking about user input validation here, I'm really talking about ...
10
votes
2answers
412 views

Finding average of eight immediate neighbors of a matrix

I have this basic Java code to find average of eight immediate neighbors of a matrix. Is there any way to simplify or merge any part of it, or can I refactor it? I'm a beginner in Java programming ...
1
vote
1answer
93 views

MVC Layout - Which way to add listeners is better?

So I'm doing a basic MVC layout for a pretty basic game that I am making. The game requires the user to move up/down/left/right via buttons on the GUI. Since I'm using an MVC layout and my buttons are ...
7
votes
1answer
89 views

Interacting with GUI class and Main class

Usually when I make mock-up programs (like this one), I look for things I can improve on in case the situation happens again. Today I thought I'd brush up on basic OOP (I understand the concept of ...
10
votes
2answers
106 views

Functional interface hierarchy in Java 8

I just created the following code and am wondering whether it is logically correct (all other feedback is of course also welcome): ...
2
votes
3answers
98 views

Best practice creating model? [closed]

Version 1 ...
2
votes
1answer
75 views

Correct use of delegate pattern

I would much appreciate your advice on this design I am going to implement. I am relatively new to object programming and I am not so sure about the delegate pattern. I need to provide the ...
5
votes
2answers
120 views

A simple web-app code - user registration. Is the layering ok?

So knowing the little pieces is something different and putting them together is something different. Here is the code where I try to follow good oop practices and 3 - layered structure. Any ...
5
votes
3answers
199 views

Creating date strings and setting dates

I've created a Java class, Date, in which I basically create date strings and set dates. Is there anything I can do besides adding comments to improve/shorten my ...
3
votes
1answer
69 views

Appropriate way to create object for storing data in a ListView & Profiling

I'm creating a location based reminder application in Android using proximity alerts, geocoder, Google Maps API and their Places API. Currently there is a default ...
15
votes
4answers
766 views

Modelling a Call Center

This is the requirement I have (from the book: Cracking the Coding Interview) Imagine you have a call center with three levels of employees: fresher, technical lead (TL), and product manager (PM). ...
6
votes
4answers
1k views

Making a word processor

The Word Processor I had in mind would be similar to Microsoft's word and OpenOffice. I am trying to keep my logic separated from the User Interface and that separated from the controller, basically ...
7
votes
1answer
755 views

Drawing a triangle and some concentric circles

For class, I had to use Java to draw a triangle and some concentric circles. Here's my code (questions follow): ...
10
votes
3answers
821 views

Basic bingo game in Java

I've recently wrote a simple bingo game in Java to refresh myself in oop principals I have not touched in quite a while. I feel like I have accomplished this, but I would like to learn as much as ...
9
votes
2answers
147 views

Java API without exposing implementation details

I am creating an API for consumption by other developers to interface with an internal framework. My goal is to be able to have the developers type something like: ...
3
votes
1answer
96 views

Throw an exception to control the flow of code execution

There is a recommendation not to use an Exception to control the flow of execution. This gives me a reason for doubt when I do something like this: ...
4
votes
1answer
121 views

Simple class to represent progress

Progress class was written using TDD. Interface of this class (pseudo-code): ...
4
votes
2answers
80 views

Review of java interface for constructing brain model

I have built a partial human brain model and the following is an example of how I use all the classes. I was wondering if anyone could critique my implementation strategies because I feel like the ...
3
votes
2answers
130 views

Constructing a binary tree in java

I am constructing a binary tree. Let me know if this is a right way to do it. If not please tell me how to?? I could not find a proper link where constructing a general binary tree has been coded. ...
2
votes
3answers
377 views

Clear ArrayList

I create class level static ArrayList by the following line. static ArrayList<Student> studentList = null; Then I create and fill ArrayList with some ...
6
votes
2answers
153 views

Calculating min and max with if-statements within a for-loop

This code section is from the main method of my Annual Fuel Use class. The program projects my annual fuel usage based on at least three fill ups of my car. Here, I am calculating the max and min for ...
5
votes
1answer
127 views

Batch process as an OO design solution

I was given the task of batch process a single-level control break program to produce a lecturer information report by lecturer from a university course file. I have attempted to create a solution ...
5
votes
3answers
296 views

How to split this Bingo game into 3 separate classes?

I have a single file of a java Bingo program that I want to split into three separate classes (BingoMain, BingoGUI, BingoCard). Extending a program across several files is something I have never ...
4
votes
2answers
293 views

Managing employee information

I have created a program that allows the user to view/add/delete employees and also view employee payslip, either weekly employee or monthly employee, which is all done in the console. My programme ...
0
votes
2answers
113 views

Q&A minigame structure

I've decided to improve / test my knowledge so far, as I haven't coded in Java for a while now. Is there anything I can improve in my code? The OOP structure? The code itself? Useless code? ...
4
votes
2answers
3k views

Random password generator

I just wrote my first Java class, and I wanted to share it with you and maybe get some quick check from more experiences coders than I am. I want to learn OOP, and Java is just the tool I thought was ...
7
votes
4answers
419 views

Tic-Tac-Toe design

Kindly look at this code and point out design flaws or areas for improvement. I think I've done the last part right (the enum). I think the rest of the design is flawed but I am very new to ...
3
votes
2answers
89 views

Help me improve my Hangman app

I just created a Hangman app (same game mechanics mostly) using Java. I did this mainly to test my knowledge in OOP design/coding. I'd like to know your thoughts on my code The whole project is on ...
5
votes
1answer
102 views

Writing an effective method that reflects good OO design and fixes this broke method

I'm working on my personal project and have recently had a bit of trouble with a method I wrote during the week. This method compares user input from the same ...
0
votes
1answer
2k views

Java Fraction Class - Adding Together Two Objects [closed]

I'm currently working on a fraction class. I've successfully figured out how to create a fraction object as well as check for errors but I've blanked and cannot figure out how to add together the two ...
1
vote
1answer
338 views

Getting multiple inputs from single EditText

This is an Android app and there is a EditText box, and I need to accept multiple types of inputs one after another in order. This order is predefined. On ...
1
vote
2answers
953 views

Designing classes and methods for hospital management system

I am working on hospital management system project. I have implemented it using the following design. Is it a good design? I have created four classes: Patient, ...
2
votes
3answers
113 views

Did I Needlessly Complicate This Function?

Background: We're using a class called Places (inspired by Allen Holub's great article on DrDobbs) that resolved our program paths based on the existence of a configuration file, environment variable ...
0
votes
1answer
155 views

Java game selection + true/false game review needed

First of all, I won't include the spin game there, cause its very simple. just random formula. Ok, I went a bit deeper into object oriented since the last time, I learned array lists, using them with ...
2
votes
4answers
160 views

One or multiple classes? Better-looking way to create tetrominoes in game

Background A few weeks ago, I started working with Java. To get more familiar with the language, I decided to make a Tetris clone. So, as I finished the Tiles ...
6
votes
1answer
349 views

Intern with no mentor struggling with refactoring and OOP

A little background I'm an intern at a large engineering company, and I'm also the only CS major in the entire building. The people on my team don't have technical backgrounds, but hired me to start ...
2
votes
0answers
93 views

How to design a robust class for Packet Capturing tool? [closed]

I need to design a class for packet capture tool. Class should provide service to start and stop a dumpcap packet capture. Class should be capable of accepting all sorts of inputs which includes ...
4
votes
2answers
264 views

Improving my Java object-oriented? Review!

Did I improve since then? I have been writing this program today, and tried my best to improve my object-oriented understanding. Mains.java: ...
4
votes
3answers
326 views

Simple spin game

I see many many programs that are written out of the main method. But most of my programs are written in main() and access some ...
1
vote
1answer
80 views

Single-player Pong game in Java

I recently created the following code, which is supposed to implement a Pong variation for one player. How can I improve or optimize my code? Pong class: ...
0
votes
1answer
37 views

Best way to manage a device information class

This is probably a really simple question. An embedded device I'm working with will store the device information in an xml file. In my code, I want to read this xml file and freely reference to it ...
2
votes
3answers
188 views

Flaws in this Design?

I need to find the flaws in this design. So far the only ones i can think of are: No use of generics the class Concept uses a parametrized constructor, which means every sub class would need to pass ...
1
vote
2answers
122 views

Java Theory: Classes Design for Currency, Futures and Metals Analysis 1

This is a continuation from here: http://stackoverflow.com/questions/16761207/java-theory-classes-design-for-currency-futures-and-metals-analysis I have created 2 classes for now. 1) Historical Data ...