LonamiWebs / Klooni1010

libGDX game based on the original 1010!
https://lonamiwebs.github.io/klooni
GNU General Public License v3.0
234 stars 72 forks source link

Refactor: implement factory pattern for Effects #41

Closed andidevi closed 6 years ago

andidevi commented 6 years ago

This enables

Lonami commented 6 years ago

Quite a few changes, will review when I have time thank you!

andidevi commented 6 years ago

I know, but it's less than it seems:

Lonami commented 6 years ago

Several things:

But… on the other hand I can see it gets rid of the hardcoded names, better supports things like setting a price and so on. I just wish there was a more straightforward way to do this rather than using classes to create instances of other classes.

I'd like to discuss this a bit more but first I'm pushing a automatic code reformat to your branch. Edit: Nevermind I can't.

andidevi commented 6 years ago

There are good reason to follow Patterns, as many people have been thinking about, how to implement things most straightforward. Programming feels more abstract if you aren't used to them but if you can identify the patterns, its more like building a wall out of bricks. https://en.wikipedia.org/wiki/Software_design_pattern

One could make the effect an inner class of the factory, thats how it is done usually. But I decided against it, to keep the necessary level of programming skills low to give more people the chance to implement effects.

I don't even feel bad about the boiler plates. This is how java works and it is written by the IDE aka Adroid Studio.

Edit: how to enable it? but I'll throw away my branch if you merge and keep stick to your master.

Lonami commented 6 years ago

But I decided against it, to keep the necessary level of programming skills low to give more people the chance to implement effects.

I don't think this is a valid point. When you're creating a new effect you probably copy paste an existing one anyway :P And if your skills are this low you'd have bigger trouble implementing the effect than copy pasting the file. Please change that? And I can merge then. Don't worry about code format, I'll run it on the whole project once merged.

andidevi commented 6 years ago

Just to have it clear: you want to have private classes inside the factory?

Lonami commented 6 years ago

However it's often done, like you said.

andidevi commented 6 years ago

Could you supply an editorconfig with you settings?

https://stackoverflow.com/questions/35915970/how-to-export-all-my-intellij-code-styles-to-a-editorconfig-file says:

Go to "File->Settings->Editor->Code Style". At the bottom of the right pane there is a section for Editor Config options, which now includes an "Export" button.

It's best to put the .editorconfig to the root of the repo. https://stackoverflow.com/questions/44694132/editorconfig-in-android-studio

Then the next try should be formatted accordingly.

Lonami commented 6 years ago

Noted, but I can't right now. No access to my laptop.

andidevi commented 6 years ago

see pull request #43

Lonami commented 6 years ago

Closing as #43 got merged.