Refactoring legacy code

Recently I’m trying to upgrade one big project from Ruby 1.8.7 to 1.9.3.
It is bumpy road but here are some thoughts gathered during this time:

1. Make small steps – especially when pushing those changes to production. You’ll never know what are going to break.
2. When changing API endpoint find every call to that endpoint. Record HTTP requests & responses and test them.
3. Improve test coverage. The more good specs you have, the better.
4. Update only necessary gems to get your code working on Ruby 1.9.3.
5. Set up Continuous Integration server to run specs on both Ruby versions: 1.8.7 & 1.9.3.
6. Analyze & understand business logic in code. Use metric_fu, simplecov to know more about code.
7. Delete unused code.

Reklamy

FTP server on OS X 10.8.5

On my OS X 10.8.5 I tried to do specific task: I want to set up FTP server where user has full access to that specific place — he can upload/download and remove files without any problems. After spending some time with this I came to solution to create new user in system and set configuration of /etc/ftpd.conf to sth like that:

chroot REAL /path/to/directory
modify all
upload all

To start & stop FTP server I used those commands

sudo -s launchctl load -w /System/Library/LaunchDaemons/ftp.plist
sudo -s launchctl unload -w /System/Library/LaunchDaemons/ftp.plist

Those resources were helpful for me:
Start an FTP or SFTP Server in Mac OS X
OS X: anonymous ftp directory on Mountain Lion

Review: „RESTful Web APIs”

cover

Good reference book

In my current project I use JSON heavily as representation when „talking to” servers. I decided to read that book and possibly get some insights how design better APIs.

First three chapters are reminder how HTTP works, its semantics a protocol and what exactly REST stands for. As an example authors use simple microblog service. Consecutive chapters cover hypermedia, the collection pattern, the design procedure and much more.

From my perspective the most interesting part (& most useful) were chapter devoted to the collection pattern and discussion about minimising semantic gap. From my developer’s point of view: using consistent, well-defined structure for JSON responses can simplify parsing and it’s easier to manage.

What I miss in this book are more complex „real-life” examples. I like academic discussions but I like practical examples more 🙂

My rating:

Product page: http://shop.oreilly.com/product/0636920028468.do

I review for the O'Reilly Blogger Review Program

Review: „iOS 6 Programming Cookbook”

cover

Cook your iOS apps

I like cookbooks and iOS6 Programming Cookbook is no exception. Author covers a lot of practical knowledge: basics of Objective-C, UI solutions, Xcode features (e.g. Interface Builder, Storyboards), concurrency, gestures, maps, networking, graphics, motion and many more.

Vandad presents material clearly, solutions contains screenshots, schemes, references and code to understand and implement it.

iOS6 Programming Cookbook is good reference book and I can recommend it to every iOS developer/hobbyist.

My rating:

Product page: http://shop.oreilly.com/product/0636920027683.do

I review for the O'Reilly Blogger Review Program

Review: „Randal Schwartz on Learning Perl”

cover

Perl from the ground up

Learning Perl Video is almost 11 hours long lectures covering Perl from the ground up. Randal Schwartz presents concepts and quirks in Perl step by step. Videos are nicely divided by topics. Every video is shorter than 1 hours, so it’s optimal to pay attention to presented material and take break between videos.

Randal presents material clearly, tells some anecdotes but there are not too many examples. Hands-on experience seems to me vital when learning programming language and I checked many code snippets when I watched those lectures.

My rating:

Product page: http://shop.oreilly.com/product/0636920014430.do

I review for the O'Reilly Blogger Review Program

Review: „Scala Cookbook” By Alvin Alexander, O’Reilly Media

cover

Scala in examples

Scala Cookbook is very practical book. Author presents every small example as problem to solve and possible solutions with discussion. I learned syntax for some concepts (like pattern matching, auxiliary constructors, executing external commands, lazy collections) I’ve seen in other programming languages. The book helped me better understand how implicits work.

Moreover, there are available bonus chapters providing recipes about XML, XPath, testing, debugging and Play framework.

Scala Cookbook is comprehensive book. It provides practical solution for typical developer’s problem and I recommend this book everybody interested in Scala.

My rating:

Product page: http://shop.oreilly.com/product/0636920026914.do

I review for the O'Reilly Blogger Review Program

Review: „Think Complexity” By Allen B. Downey, O’Reilly Media

cover

Nothing special

When I first saw title of this book it seemed to be quite promising, but…

After studying 5 years Computer Science there are not too many surprising topics in that book. It was nice adventure to refresh some Python and go through „Case Study” chapters.

For me, topics are interesting, but many examples are presented in too boring form and they don’t have too much interesting context.

It would be better if code were gathered in one archive/repository and author provided script to install all dependencies at once.

My rating:

Product page: http://shop.oreilly.com/product/0636920022480.do

I review for the O'Reilly Blogger Review Program

Git – konkretne rozwiązania

W trakcie pracy z gitem natrafiam na różne problemy – szczególnie wtedy, gdy zaczynam coś psuć 😉

Poniżej lista rozwiązań znalezionych w sieci, które przydają mi się w pracy z gitem:

Inne przydatne materiały:
Roger Dudler – Git Guide
Git CheatSheets
Git Ready
Pro Git
The Git Community Book
Git – SVN Crash Course

Review: „The Modern Web” By Peter Gasston, No Starch Press

cover

Good overview

Web is changing: new technologies, frameworks but also new devices for browsing Internet.

The Modern Web: Multi-Device Web Development with HTML5, CSS3, and JavaScript is interesting book  informative but often author barely scratches the surface. In Introduction author describe multi-device world — Internet of things. Consecutive chapters are devoted to technologies mentioned in subtitle: HTML5 (structure, semantic markup, microformats, microdata), CSS (media queries, RWD, viewport-relative units, new layouts: Flexbox, Grid Layout, Multi-columns), JavaScript (async, defer, selectors, device APIs). From my perspective last two chapters describing Web Apps & the future of web are especially interesting — e.g. Web Components bring some concepts from programming craft: decorators, templates, mixins.

Big advantage of The Modern Web book is that at the end of chapter there is further reading section. Author provided source code of examples on: http://modernwebbook.com.

My rating:

Product page: http://shop.oreilly.com/product/9781593274870.do

I review for the O'Reilly Blogger Review Program

Review: „Lift Cookbook” By Richard Dallaway, O’Reilly Media

cover

Practical Lift

I’ve written many web apps in many framework and languages (Sinatra, Rails ⇾ Ruby; Snap ⇾ Haskell; Play! ⇾ Scala; Mochiweb ⇾ Erlang). However, Lift was not-so-easy to grasp for me.

Lift Cookbook is very practical book. Author covers the most basic & used aspects of web apps (HTML rendering, form, Ajax, REST API, connecting to SQL & NoSQL databases and more). Material is presented in question-answer (+discussion) form. Author provided set of repositories on Github as working examples.

Book is well written. Examples work. That’s how good cookbooks should look like.

My rating:

Product page: http://shop.oreilly.com/product/0636920029151.do

I review for the O'Reilly Blogger Review Program