Showing posts with label variables. Show all posts
Showing posts with label variables. Show all posts

Tuesday, January 17, 2017

User Testing Update



I've had to hit the books again to improve my understanding of variables, classes, and methods.

I've been re-writing my text adventure game so that every aspect of it is tested by the Rakefile.  This means that I have had to extrapolate the logic of the enter() method in each class, so that a test can be written for it.

The most interesting parts of the game involve somewhat complex conditionals, written as case conditionals, and for some reason it took me a while to understand how to pass on a variable to the method containing a case conditional.  Now that I look at it again, it's very simple, but c'est la vie.

Anyway, the re-written game is nearing completion and the latest code is up on Github.

Monday, December 26, 2016

Using a string as a class variable

My script relies on a single argument in the form $stdin user input:

class Project
  def initialize()
    puts "What do you want to call this project?\n"
    print "> "

    $user_input = $stdin.gets.chomp


The script is organised into a single class that contains consecutive methods.

The simplest way I have found to utilise the user input is to declare it in each method.

  def define_folders()
    project_name = $user_input


  def create_gemfile()
    project_name = $user_input

However, this is repetitive.

What would be a better way?


Monday, October 24, 2016

Thoughts on Refactoring Code

http://www.ben-morris.com/wp-content/library/refactoring-vs-rewriting.gif

I'm working on my CareerCoach job research tool, and I'm finding it very tricky to refactor the code.
There are too many moving parts, too many variables.

I'm trying to convert blocks of code into functions, which means that I have to turn variables into global variables, and that gets confusing.

I think I need to map out in more detail what I'm trying to achieve and then work on each component separately.

For now, it's time for a break.

1,050 hours

It took me 13 working days to complete my first 100 "work" pomodoros as a Junior Software Tester at Profectus Group.  Much of ...