HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

A rating is a simple structure that is powerful in its flexibility. Its three core attributes are customizable, allowing a developer to tailor an application's rating system to its needs.

### Design a resource reference

One core attribute of a rating is the resource reference, which identifies the resource to which the rating is applied. In the Optimizely Community API, resources are identified using the `Reference` class. The scheme applied to define these references is designed within your application. This gives a developer the freedom to structure ratings so they can be conveniently identified, organized, and retrieved in the application.

When designing a scheme for representing references, consider the following:

  • **What are you rating?** Are you rating a first-class object within your system, a class of objects, or a facet of an object? For example, you might rate a product, a variant, or the product's price. Design your reference scheme to accommodate intangibles like facets, which are not necessarily uniquely-identifiable objects within the application.

  • **How will you retrieve your ratings?** Do you intend to retrieve ratings individually or in batches? If you need to retrieve a batch of ratings for a category of resources, consider representing that organizational scheme within your resource references.

A URI or similar namespace scheme provides an ideal template for a reference. Consider the following sample reference scheme that might be applied to address the above considerations:

For information on `References`, including best practices, see  _References and IDs_ in [Discovering the platform](🔗).

### Design a rating scheme

The value of a rating is represented as a simple integer value. The value's significance is defined in your application.

  • A simple 5-star scale might be represented by values 1-5

  • A 5-star scale, allowing half-star ratings, might be represented by values 1-10

  • A percentage-based scale might be represented by values 1-100

Anticipate the potential for future alterations to your rating scale. For example, your application currently requires a 5-star rating scale, but you anticipate a future need for more granular values. In such a situation, consider implementing that scale with the values 1-10, rather than 1-5, where each whole star is represented by an even integer within that range. This allows for the possibility of introducing half-star ratings later without skewing the statistics for existing ratings.