-
Notifications
You must be signed in to change notification settings - Fork 5
Description
A proposal for some refactoring.
The TileRendererFactory does not implement the factory pattern. I asked ChatGPT what it thinks it does and it said:

That is exactly what I would think, but instead it is a collection of static render methods, So TileRenderer would be a more appropriate name.
The current TileRenderer class does very little apart from initializing the VectorStyle (which is not rendering) and wrapping the render calls. It also disposes the connection, but this is something it should not do because you are not supposed to dispose injected objects.
I propose to make the TileRenderer static. Initialization of the VectorStyle should be done on the outside and it should be passed as argument to the render calls. All the static methods from the TileRendererFactory should be moved into the TileRenderer.
Another way to approach it is to delete the TileRenderer and rename the TileRendererFactory to TileRenderer. The caller of TileRenderer will need to do a bit more work.
Btw, for me it was a bit confusing that a VectorStyle contains data (the VectorTileSource is assigned), this is not something to expect. It would be less confusing if the VectorTileSource would contain a style, but perhaps they should be completely separated. Or perhaps a class which holds them both.