Probable excessive use of java interfaces in my implementation of Ms. Pac-Man

I have been a Java programmer for the last 6 years, and since the beginning of this year I have been interested in game programming. So, I thought it was a good idea to start with a popular game, and I implemented Ms. Pac-Man in Java. I can say that my implementation looks about 90% similar to the original game, and I tried to use as many design templates and best practices as possible, since it was just a personal project to learn how to code basic 2D games.

Now that I have finished coding, I realized that I have 19 interfaces and a total of 17 classes! So I'm starting to wonder if I can abuse interfaces.

Here is an example of several classes / interfaces that I use:

Class - FullGame (implements FullGameInterface and FullGameObservable)

Class - View1 (implements FullGameObserver)

Interface - FullGameInterface (main function methods: resume, pause, play, etc.)

Interface - FullGameObservable (allows you to view views for update notifications)

Interface - FullGameObserver (implemented by two different types of games for receiving notifications)

Am I using interfaces?

What is your opinion?

+3
source share
4 answers

The interfaces are good. This is not a problem when there are a lot of them.

, . , , , , . , , , , - , , , , , .

+2

, .

- FullGame , , .

- FullGame, , , FullGameInterface.

2: , . , , . , . ( , .) , , , . - , , .

EDIT :

, () (). :

  • , , . , List, ArrayList LinkedList. List - , ArrayList, LinkedList. Collection .
  • . , , - - . - . , . Java RMI .
  • . , Image , FileImage FileImageProxy. FileImage Image . , , ; , Image, .
+9

, , ( , , , ). , .

, , , .

+4

. , . API , (), , .

+1

Source: https://habr.com/ru/post/1719104/


All Articles