Refactoring is a necessity in software development. As engineers, our first attempt at writing new feature code is most likely filled with rats. Then we refactor the code to make it maintainable, readable, faster, and less prone to bugs. These refactoring rules for the three phases of development can help development teams scale the correct code and not break the business. Consultants do come in many shapes and sizes, so my disclaimer is Uninteractive, my company, is focused on general feature development for early and growth stage startups. These rules may need adjusting for your large scale development operation, although lean focused teams can live by them. Software projects land in one of three phases – The POC (proof of[…]

Today marks the end of a 365 day journey of writing one Ruby programming tip everyday. It has been a long journey to consider new and interesting content in the realm of a Ruby and Rails programmer. I have learned so much and I am very happy to share this content with the world. For today’s final tip, in the 365 days of Ruby series, let’s look at how the each_slice() method does what it can to arrays. We can iterate over collections and grab the modulus of three and return a result when that happens. [1,2,3,4,5,6,7,8,9,10].each_with_index do |num, idx| puts "#{num}" if ((idx + 1) % 3 == 0) puts "end of line" end end   #=> 1 #=>[…]

This tip comes by way of: @starvo. By using a counter in your ruby console script you can gain insight into long running actions for your application. @photos = Photo.all count = @photos.count @photos.each_with_index do |photo, idx| # … do a bunch of processing puts "#{(100.0 * idx / count).round(2)}%" end   # When the script is run we will get a percentage complete counter like: #=> 0.1% #=> 0.2% #=> 0.3% #=> 0.4% #=> … :)