# Brainmess: Extract Tape Class (Cleanup)

This is just a quick update. My last refactoring on Brainmess was to extract out the tape class. While reviewing that code today, I noticed some artifacts left over from the refactoring process. These were cleaned up in commit 836a96

Four of the methods: MoveForward, MoveBackward, Increment, Decrement still had return values that were not needed. For example before we extracted out the tape class, this is what the MoveForward method looked like:

int MoveForward()
{
return tc++;
}


and this is how it was called from the Run method:

switch(instruction)
// ... snip
{
case '>':
MoveForward();
break;

// snip...


The MoveForward method and the tc variable were then moved into the Tape class. You can see however that there is no need for the MoveForward method to return anything. It can be simplified to the simple expression tc++.

Similar changes can be made for the other three methods so that we get this for the Tape class.

public class Tape
{
private readonly int[] tape = new int[5000];
private int tc = 2500;

public void MoveForward()
{
tc++;
}

public void MoveBackward()
{
tc--;
}

public void Increment()
{
tape[tc]++;
}

public void Decrement()
{
tape[tc]--;
}

public int Current
{
get
{
return tape[tc];
}
set
{
tape[tc] = value;
}
}
}
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.22424039244651794, "perplexity": 5674.326453477916}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2017-47/segments/1510934806338.36/warc/CC-MAIN-20171121094039-20171121114039-00461.warc.gz"}