0

iam new here, my english is not the best, but i hope you understand my question and maybe can help me. I made a little project:

Interface: vehicle

Abstract Class: vehicleImpl implements vehicle

Interface: train extends vehicle

Class: trainImpl extends vehicleImpl implements train

Interface: waggon extends vehicle

Class: waggonImpl extends vehicleImpl implements waggon

Class: trainConnection (can have multiple waggons and minimum one train)

Then there is an object which is subclass from train and waggon -> a "trainwaggon".

Interface: trainwaggon extends train, waggon

class: trainwaggonImpl extends trainImpl implements trainwaggon (i added the variables from waggon manually, because i can't use two times super(...) for both superclasses)

i also have an class location and connection (like a graph), but these dont matter now. At last, the class "administration" has maximum one instance and is managing the trainconnections.

Is that design pattern legit? Or would you recommend to change it?

Thank you for you help. -Rabe

  • 2
    We do not do code review over here. [Code Review](https://codereview.stackexchange.com/) could be more fitting. --- From what I see, this seems overengineered. The abstract classes might be unnecessary and could be dealt with using [default methods (external link)](https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html). --- Overall, the question smells like an [XY problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). – Turing85 May 02 '21 at 13:55
  • ok, thank you. Sorry i did not want to ask XY-Problems or let you review my code. Thats why i did not copy the code. It is my first time designing a project alone on my own and iam a bit confused. The code works fine, i can build and manage the objects. The question is, is that design ok or a bad fault. I will check the link for using default methods but at the first look i didnt get what you mean with that? And thank you for the Code Review Link i will use that. A last question: did i handle the "trainwaggong" right? – Kvothe Rabe May 02 '21 at 14:40

0 Answers0