Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
Edward Anderson edited this page Aug 13, 2015 · 4 revisions

Philosophy

This project's class structure attempts to follow Peter Harkins' design guidelines described in RailsConf 2015 talk What Comes After MVC. The terminology below follows the definitions and hierarchy he described.

Benefits

Storing data in Value Objects rather than ActiveRecord models allowed for

  • very fast integrated testing of logic associated with models, without having to involve the database
  • dead simple, single-query persistence and load of a complete portfolio record
  • separating data and associated logic into classes that make sense, without having to modify or separate from the underlying data structure

Having adapters in front of the API and persistence provided

  • interfaces with methods that provide what the app (shells) wants to consume
  • data structured in value objects with behavior attached, so a users of the data don't have the responsibility of transforming it to fit their needs

Doing most of the work below the Shells made it

  • easy to read and understand what is happening at a high level
  • accessible to test all but this very small part of the application without integrating with external services (network, DB)

Class Overview

Role Mixins

  • ValueObject include Adamantium, Equalizer(all attrs), and Lift
  • Entity include Lift, Equalizer(id attr[s])

Shells

  • PortfoliosController Load Portfolio from PortfolioStore; use FetchDataWorker to load missing data
  • FetchDataWorker Fetch data for a GitHub user using GithubAPI, and store results in a PortfolioStore

Adapters

  • PortfolioStore Persist and load Portfolio objects in the Rails cache
  • GithubApi Fetch data from the GitHub API, returning data structured in Value objects

Entities

  • Repo (GitHub Repository) A value object that allows mutability for convenience (in practice, it is not modified after being built)
  • Header An ActiveRecord model that stores a user's customized copy for the user's portfolio header

Value Objects

  • Portfolio A presenter with convenience methods for views to access all the data needed to render a portfolio; it composes all the other value objects and can be serialized/deserialized
  • ResponseObjectConverter Factory that creates value objects from API data
  • Comment Comment data
  • Commit Commit data, with methods to derive short sha and parts of the commit message
  • Issue Issue/PR data, with convenience methods for state and user lifecycle roles
  • RepoRelevance Determine how relevant a repository is based on several RelevanceFactors
  • RelevanceFactor Holds a value (score) and weight for a particular category
  • Stats Given raw numbers from an API response, derive statistics of interest
  • User A GitHub user's name and login
  • UserRole Given stats for a user, calculate the user's contribution role
  • Version A versioned release; calculates its age

Other

  • Branding Derive colors from a hue; look up the hue in application config if not given
Clone this wiki locally