Over over over over over over and over again. The goal is not to memorize the code, but to remember the pattern and structure of the algorithm. Would repetition solve that hurdle? I am testing that theory right now. I am reminded of the classic movie Live Die Repeat. Every time the hero died, he was caught in a time loop. However, with every loop he became better. He had to remember the steps. I think he got killed approximately over 300 times. Every time he has gotten better, to the point where he even surpassed the previous person who was caught in a similar time loop (his mentor).

Can we persevere and create our own time loop via refactoring? Perfect the imperfect code. I look forward sharing an example of such an idea.

A preview. In Ruby. See the work in progress >>> Here

leaves = doc.xpath('response//data//median//firstView//docTime')
 leaves.each do |node|
   puts "#{node.name}: #{node.text}" #unless node.text.empty?
   # => Time
 end
 
 
 leaves = doc.xpath('response//data//median//firstView//bytesInDoc')
 leaves.each do |node|
   puts "#{node.name}: #{node.text}" 
   # => Requests
 end
 
 leaves = doc.xpath('response//data//median//firstView//requestsDoc')
 leaves.each do |node|
   puts "#{node.name}: #{node.text}" #
   # => Bytes In
 end
 
 leaves = doc.xpath('response//data//median//firstView//fullyLoaded')
 leaves.each do |node|
   puts "#{node.name}: #{node.text}" 
   # => Time (Fully Loaded)
 end
def return_results(xml_url)
  doc = Nokogiri::XML(open(xml_url))
  results = {}
  results[:load_time] = doc.xpath('response//data//median//firstView//loadTime').text
  results[:first_byte] = doc.xpath('response//data//median//firstView//TTFB').text
  results[:start_render] = doc.xpath('response//data//median//firstView//render').text
  results[:speed_index] = doc.xpath('response//data//median//firstView//SpeedIndex').text
  results[:dom_elements] = doc.xpath('response//data//median//firstView//domElements').text
  results[:time_fully_loaded] = doc.xpath('response//data//median//firstView//fullyLoaded').text
  results # hash results


end

repeat. repetitive. repetition

Category: Programmierung
225 views