brianegan / bansa

A state container for Java & Kotlin, inspired by Redux & Elm
MIT License
444 stars 29 forks source link

Remove empty interfaces State and Action #3

Closed clemp6r closed 8 years ago

clemp6r commented 8 years ago

Hi again,

I removed the State and Action interfaces, they're useless until they remains empty. Generics are enough to get type safety. Also, users may not understand why they would have to implement empty interfaces.

What do you think?

brianegan commented 8 years ago

Hey, thanks so much for the cool PRs! Really digging the outside ideas and help :)

This is an interesting proposition, but I'm leaning towards keeping the Marker interfaces.

Say, for example, you want to find all possible actions in your project? Which is not uncommon if you're new to a project. You could look up anything that implements the Action interface! Yay!

Or, similarly, you're reading through some code in a big project and find an "Init" class, but you'd have no indication it's an action until you look through the code to see how it's used. In these cases, a simple marker interface can help convey the intention of the author to the reader, without this library dictating any specifics as to how they work.

So, for me, the idea behind the marker interfaces is to convey to the reader of the code the intention behind the author's work. Does this add up from your point of view, or do you simply find them confusing? Do you think others would find implementing such Marker interfaces confusing? I'm still fairly new to the Java / Kotlin world, so advice would be great :)

Thanks again!

clemp6r commented 8 years ago

I understand but I still think it will be confusing for future users, because In Java it is not common to declare empty interfaces. Interfaces are use to define a contract, like methods that are required to exists. If you don't put anything in the Interface, it is probably useless.

Also, the two generic types in the Store interface will force users to declare their own supertypes, so as you wanted they will still be able to easily find all actions (unless they use Any as their action type but it will be their responsibility).

brianegan commented 8 years ago

Cool, I dig it! Checked with some coworkers as well to get some general opinions. Y'all have convinced me :)

Thanks again so much for contributing! Really appreciate it :)