Showing posts with label refactor. Show all posts
Showing posts with label refactor. Show all posts

Friday, April 28, 2017

Refactoring and Unicode

Ruby's implementation of Unicode for Lithuanian, an admittedly complicated language, is not perfect but I have modified a useful script on Gist for identifying the unicode value of a given character.

Now that I can identify the unicode value of tricky diacritics and accents, I can refine my code.

Details of the script here.

Friday, December 2, 2016

Refactor, Refactor, Refactor


Original Code

from_file, to_file = ARGV
puts "Copying from #{from_file} to #{to_file}"
# we could do these two on one line, how?
in_file = open(from_file)
indata = in_file.read
puts "The input file #{indata.length} bites long"
puts "Does the output file exist? #{File.exist?(to_file)}"
puts "Ready, hit RETURN to continue, CTRL-C to abort."
$stdin.gets
out_file = open(to_file, 'w')
out_file.write(indata)
puts "Alright, all done."
out_file.close
in_file.close

Extremely Refactored Code

File.new(ARGV[0], 'w').write(File.read(ARGV[1]))
Acknowledgement: Picture from Flickr 

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 ...