Skip to main content

All Questions

2 votes
2 answers
276 views

Is it ok to extend utilities?

Apache Commons has StringUtils. It's great, but I wish it had a shuffle() method or similar Is it ok to create my own StringUtils that extends Apache's StringUtils and adds the method (Apache's class ...
Sergey Zolotarev's user avatar
1 vote
2 answers
1k views

Is it wrong to extend an inner static class in java? (Builder pattern)

I'm working on a java project for the university. The project is a card game in which you travel around a 2D map and fight against some enemies. My part consists of creating the deck and the cards. I ...
Matteo Paolucci's user avatar
0 votes
1 answer
2k views

Java convention - Implementing two similar functions for two different objects

I have two classes, let's call them Foo and Bar. They both extend different classes (Foo extends X, Bar extends Y), which have some common ancestor "way up" the inheritance tree, something like this: ...
Mickey's user avatar
  • 103
4 votes
4 answers
6k views

How to avoid code duplication while extending two umodifiable classes

I already have this core class structure that can not be changed: class A { //some basic fields and methods } class B { //some another basic fields and methods } It is core classes and I'm ...
TEXHIK's user avatar
  • 151
3 votes
1 answer
522 views

Best design for classes that draw objects but do not inherit from JPanel

I'm doing the exercise 10.1, page 476 from the book Java: How To Program, Early Objects by Paul and Harvey Deitel (10th Edition). Modify the MyLine, MyOval and MyRectangle classes of GUI to create ...
Yos's user avatar
  • 167
1 vote
1 answer
93 views

Object passed to super() referenced by subclass - Any Violations?

This is the code in question, comments point it out: class Actor extends Entity { private MutableVector2f position; private MutableIdentity identity; public Actor(MutableVector2f ...
Dioxin's user avatar
  • 953
4 votes
2 answers
2k views

Inheritance and factory together?

I have a hierarchical data model and am trying to implement their CRUD operations in my Web Application. Currently I have code inheritance for CRUD operations of my entities (resources) as follows: ...
Siddharth Trikha's user avatar
1 vote
2 answers
246 views

Processing and sending processed data to super from child class constructor

I want to do some initialization in child class constructor and pass result to super(). But Java doesn't allow any processing in child class constructor before super() call. Whats a good way to ...
mzlo's user avatar
  • 141
0 votes
5 answers
1k views

classes/inheritance, how do I handle special cases that require more change

I often find myself in this situation where I have a base class that does a lot of graphics. There are, for example, three strings that are positioned top, middle, bottom of an element. Like a scale ...
NikkyD's user avatar
  • 735
2 votes
3 answers
158 views

Refactor an old model of a LastUser Modification on every Object?

I have a software requirement, that needs to store the user that made the last modification to another object, for every object (assume that all objects are already mapped and into a BD). So we have ...
nicoLinjava's user avatar