You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If class is abstract, then it is can have multiple childrens. Assuming that singletone should be instantiated only once, then this situation doesn't make sense.
In addition AwtSpriteStore has public constructor which ruins the idea of singletonius SpriteStore.
I think of several solutions of this problem:
Do not use Singletone pattern, instantiate SpriteStore in main(String[] args) and pass its instance to all classes that use SpriteStore. For small classes like Player it is good idea to pass Sprites to constructor.
Merge classes SpriteStore and AwtSpriteStore to single class. This option is suitable for using singletone pattern.
The text was updated successfully, but these errors were encountered:
This project was born as a study material, initially it was much simpler.
I've read everything and what I see you know about Java. I would opt for the second option, what do you suggest to do? It would be best to divide the code into multiple classes by avoiding single classes with 1000 and over lines of code (for ease of reading and editing).
I did my best to make the project simple, so my choice definitely falls on the organization of several classes tied to a specific package in the project. This makes the structure easier to understand and keep code in the future will be less complex.
I hope I do not look too beginner (I am). Thank you.
You did a great job making first step. You don't look too beginner for me. You understand basic concepts and use them. I like the idea of keeping this project a study material. Thats why I explain those issues here. It is important that everyone understand why any change has been made.
Class with 1000 lines of code is not bad if it is used for single purpose (cohensive). But when you feel, that code in the class is used for multiple purposes, then you need to think about making another class.
When you feel that a number of classes are used together more often, then you might want to make package.
I prefer 1 solution because it makes use of SpriteStore obvious. Currently all references to SpriteStore are hidden and spread across whole project. This phenomenon is called high coupling.
If class is abstract, then it is can have multiple childrens. Assuming that singletone should be instantiated only once, then this situation doesn't make sense.
In addition AwtSpriteStore has public constructor which ruins the idea of singletonius SpriteStore.
I think of several solutions of this problem:
The text was updated successfully, but these errors were encountered: