Giter Club home page Giter Club logo

srp-facade-lab's Introduction

srp-facade-lab

CSC 309 Lab on the Single Responsibility Principle and Facade Design Pattern

Gather together those things that change for the same reason, and separate those things that change for different reasons.

Create a Facade as a way to provide clients a unique central point of access to those different functionalities

Overview of this repo

Inside you will find the beginnings of a ground-breaking new RPG game. Unfortunately in the rush to get features completed the main RpgPlayer class is starting to turn into a hair-ball of responsibilities.

You'll start by adding some more features to it to get it into a right mess, then we'll fix it up good.

Getting started

  1. Fork this repo.
  2. Clone your fork to make a local copy.
  3. Build it.

Making the situation worse...

Feature: Super rare items look more awesome

  • As a graphics designer
  • I want rare and unique items to look more awesome
  • So that the player gets a dopamine hit and keep buying more in-game currency

Add a new rule to PickUpItem that will show a blue_swirly effect if the item is both rare and unique.

Feature: Un-encumbered players can parry more successfully

  • As a game designer
  • I want the players damage taken to be reduced by 25% if they're carrying under 50% of my capacity
  • So that they will win more fights because they're lighter and can dodge attacks more successfully.

Add a new rule that reduces all damage taken via TakeDamage by 25% if the player is carrying less than half their CarryingCapacity.

...What's gone wrong?

Even though the public interface for the RpgPlayer looks nice and tidy, the nightmare exists behind the scenes.

The RpgPlayer has far too much knowledge about what the items are capable of, though initially this may have seemed like a good place to put the logic as the items are mostly acting on the player.

How to fix it?

Apply the Single Responsibility Principle to provide a better separation of concerns, improve class cohesion, and them provide a Facade as a way to provide clients a unique central point of access to those different functionalities.

srp-facade-lab's People

Contributors

bcdasilv avatar ntreese avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.