rankeable | Rankeable allows you to easily add rankings | Application Framework library
kandi X-RAY | rankeable Summary
kandi X-RAY | rankeable Summary
Rankeable allows you to easily add rankings to your models in a Rails application. It's geared towards rankings that are too expensive to calculate on the request cycle, and must be calculated periodically in the background. Any object can be ranked, and any number of different rankings can be created, with different ranking rules.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of rankeable
rankeable Key Features
rankeable Examples and Code Snippets
Community Discussions
Trending Discussions on rankeable
QUESTION
It seems that technically, there is no limit in the number of multilevel inheritance. Example: class D inherits class C that inherits class B that inherits class A. However their names start getting complicated as you keep inheriting.
It seems to me that, in fact, having a base class and using interfaces would be a better approach.
The problem that I have is that, with interfaces, I have to implement the properties in every class. Using a base class, I implement them in only one place.
In my scenario I have the following:
- Base Class:
Animal
- Interfaces:
RankeableByLevel
(this has additional properties that allow animals to be ranked),FilterableByExpertise
(this has additional properties that allow animals to be filtered).
There are 10-15 Animal
subclasses, and around 7-8 that would be rankeable and/or filterable. I don't want to implement the interfaces in each of 7-8 classes (too much "duplication" in my opinion).
One option would be to create a base class called AnimalRankeableByLevel
and another AnimalRankeableByLevelAndFilterableByExpertise
by specially this last one seems too long to be right!
With interfaces, I'd have to "duplicate" implementation too much. With inheriting too many classes, it would look wrong (too long name, too many inheritings).
What would be the solution to this?
Thank you!
...ANSWER
Answered 2020-Aug-08 at 07:57Favor composition over inheritance. Implementing an interface in 7-8 classes is not per se an issue.
If you want to reduce the duplication of the interface implementations (because e.g. the calculation of certain values is similar) you can extract that calculation to another class and delegate the interface implementations to that class.
Example:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install rankeable
For example, using the context of a Game that have many players and referees.
rankeable: the owner of the rankings (in our example it's Game). Contextualizes the ranking
ranked_type: The ranked model
ranked_call: The calculation function that actually ranks objects
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page