reset password

Design Model Classes

In this document we will discuss how to design model classes. We will use an example taken from Homework 2 and 3 from CS520 Fall 2011, and we will mimic Suze Orman's writing style in her book The Road to Wealth by explaining the design process with a series of questions and answers.

Sample Requirements

Suppose we want to design model classes to add rubric support to CSNS.

A rubric, according to Merriam-Webster, is "a guide listing specific criteria for grading or scoring academic papers, projects, or tests". For example, the department  program assessment page lists five rubrics that are used to evaluate the students in several areas.

Create new model classes and/or modify existing ones based on the following requirements:

  • Create a Rubric class that holds the information about a rubric. This class should be in the csns.model.assessment package.
  • A rubric has a name, a rating scale which is either 1-3, or 1-4, or 1-5, and a number of criteria.
  • Each criterion has a name, and for each rating value, a description of the performance quality that warrants the rating.
  • One or more rubrics can be associated with an assignment. For example, we may associate an Oral Communication rubric to the Midterm Presentation assignment in CS520. The instructor grades a student's work for the assignment by giving a rating to each criterion in each rubric associated with the assignment. The ratings for a rubric is stored in a class RubricScore in the csns.model.assessment package.

Design

Q. How do we design the model classes?

Class design usually takes two steps: identify the entity classes and their fields (or in the terminology of the Entity-Relationship Model, the entity sets and their attributes), and then add the associations between classes (or in the ER terminology, the relationships).

Q. So how do we identify the entity classes and their fields?

Usually the nouns in the requirement description are your classes and fields. In our example, they are "rubrics", "rubric name", "rating scale", "criterion", "criterion name", "description", "ratings", "rubric score".

Most of the time which noun should be a class and which one should be a field are pretty clear. For example, rubric, criterion, and rubric score are clearly classes because they contain other things, while name, description, ratings are clearly fields because they are of simple types (i.e string, number, or date). However, sometimes things are not that cut and dry. For example, rating scale in our example could be either a class or a field:

Design A. Create a RatingScale class and add a RatingScale reference to the Rubric class.

Design B. Create a minRating and a maxRating field in the Rubric class. Because minRating is always 1, we could actually drop it and only keep the maxRating field for rating scale.

This page has been viewed 4041 times.