Thursday, July 21, 2016

React Composite Component Life-Cycle

React lifecycle... straight from the source:

 * ------------------ The Life-Cycle of a Composite Component ------------------
 * - constructor: Initialization of state. The instance is now retained.
 *   - componentWillMount
 *   - render
 *   - [children's constructors]
 *     - [children's componentWillMount and render]
 *     - [children's componentDidMount]
 *     - componentDidMount
 *       Update Phases:
 *       - componentWillReceiveProps (only called if parent updated)
 *       - shouldComponentUpdate
 *         - componentWillUpdate
 *           - render
 *           - [children's constructors or receive props phases]
 *         - componentDidUpdate
 *     - componentWillUnmount
 *     - [children's componentWillUnmount]
 *   - [children destroyed]
 * - (destroyed): The instance is now blank, released by React and ready for GC.
 * -----------------------------------------------------------------------------

Monday, September 15, 2014

There are so many great podcasts out now... here's some of my favourites:

Relevant tech:
Ruby Rogues:
Javascript Jabber:
Giant Robots:
Ruby5 (5 minute ruby show)
The Ship Show (sys admin & programmatic infrastructure)

Semi-related tech:
FLOSS Weekly (Open source)
The Java Posse (very good, senior guys from Google, Netflix, etc)
Illegal Argument: (loosely related to jvm from NZ)
Software Engineering Radio
Functional Geekery (one guy interviewing Functional programmers)
Mostly Erlang (various functional prog)

This Agile Life
Agile Toolkit Podcast (seems dead now, but good back catalogue)

Non Tech:
The Skeptics Guide to the Universe (SGU)
NPR Ted Radio Hour
NPR Snap Judgement

Wednesday, April 23, 2014

New Breed of Ruby Gems
Module to define equality, equivalence and inspection methods
Attributes on Steroids for Plain Old Ruby Objects
Read only attributes initialized from attributes hash
Powerful, flexible and configurable coercion library. And nothing more.
Mixin to ease compositions under ruby (only 1,2 or 3 attributes allowed)

Neat delegation for ruby objects

Track descendants of a class
Declare abstract_type classes and modules in an unobstrusive way

Morhper is a data transformation algebra with optional tracked evaluation.

Create immutable objects
Deep freeze ruby objects

Minimal Finite State Machine.

Pub/sub observers in plain objects
Application architecture through use-case actions


Concise DSL for constructing SQL queries and table schemas

Friday, August 30, 2013

JS Callback Variations

Each JavaScript library does Ajax callbacks slightly differently.

At work we have a project that's seen Prototype, jQuery, Dojo and Backbone frameworks at one time or another.  They're all slightly different :(

Using jQuery ajax parameters

You can pass options into ajax

Ajax Option    Callback Params
-------------  ------------------------------------
success        data, textStatus, request
error          request, textStatus, errorThrown


    url: '/some/url',
    error: function(request, textStatus, error)

  request is the jqXHR object -- a jQuery wrapped ajax response.

  textStatus:  Is a string categorizing the status of the request
               ("success", "notmodified", "error", "timeout", "abort", or "parsererror")

  errorThrown: When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status,
               such as "Not Found" or "Internal Server Error.".  Otherwise it's an exception object.

Using jQuery ajax async callbacks

Asyn Callback  Callback Params
-------------  ------------------------------------
done           data, textStatus, request
fail           request, textStatus, errorThrown
always         (called with same params as done OR fail depending on if success/error)

success        data, textStatus, request
error          request, textStatus, errorThrown
complete       request, textStatus


  $.ajax(url: '/some/url')
    .done(function(data, textStatus, request)

Using Rails UJS .bind()

When using unobtrusive rails.js bindings, the parameters will include
the event object followed by normal jQuery ajax parameters.

Event          Callback params
-------------  ------------------------------------
ajax:success   event, data, status, request
ajax:error     event, request, status, error
ajax:complete  event, request, status

    .on('ajax:success', function(event, data, status, request) {
      // ... code here

Using Backbone Model callbacks

The options below can be passed to a models #fetch, #save, #destroy
and also to a collections #fetch

Option         Callback Params
-------------  ------------------------------------
success        model, response, options
error          model, response, options

Success will also trigger model.trigger('sync', model, response, options)
Error will also trigger model.trigger('error', model, response, options).

Using Backbone Sync

If you use backbone sync, there is no wrapping, you get jQuery ajax equivalents.

Thursday, December 20, 2012

Interfaces & Roles in Ruby

The foundation of an object oriented system is the messages.  You don't send messages because you have objects, you have objects because you send messages -- from @sandimetz's book 

Your system is like a teaming pool of objects, all jumping up and down eagerly awaiting a message.

Worlds largest busiest swimming pool - Funckr

Think "Roles"

Initially, it's easy to follow code which depends on concrete classes for collaboration -- that is, instantiating an object, and  expecting it (obviously) to be only that kind of class.  However, the problem is you can't substitute the collaborator for another object that is playing the same role.

Think of it this way: The world is too big!

If you take on the personality of an object, and stand inside it -- then you can limit perspective to the number of things you can deal with at one time.

You are looking out from within an object - a message sender.  You know what you want, but you don't care how your collaborators do it.  You know what you expect from your collaborators.

So, limiting your perspective in this way, you start to see other objects you collaborate with as playing roles -- not specific classes, but a more abstract interface.  A collaborator playing a role could be any number of future object types.
"No object in your system should have to know the class of any other object in order to know how to behave.  Everything is a Duck.  Tell the Duck WHAT and the Duck should know HOW."

Roles are Interfaces

Classes have expectations about the messages their collaborators understand.  You should expect an interface and not a specific class -- think "Role".  Interfaces are just a subset of messages you respond to!

But... how to share with your team? to newcomers?  It's not obvious since we don't have an "Interface" language construct.

The answer is to document roles via tests:
  • For example, a mock with the subset of methods that represent the role (or Interface)
  • A shared spec  to ensure both the mock, and the real objects playing the role conform to the interface
(Note: this post was written directly from notes I made about  the chat between Avdi Grimm and Sandi Metz in "Objects on Rails" deluxe version... go buy it)

Tuesday, October 30, 2012

Presentations aimed at helping Large Rails apps

 Wrangling Large Rails Codebase, by Stephan Hagemann
As Rails applications grow they see a lot of the same problems that any enterprise level software project will see at some point: longer running test suites, more complex code interaction, and a rising requirement to keep "all that stuff" in your head at once.
Rails may have been a framework for single applications in the past, but it nowadays has some features that allow you to tackle bigger projects with more ease. We'll cover Rails code structuring techniques like unbuilt gems and engines that you can use to get faster test suites, cleaner structures, and more flexible apps.

Mega Rails, by Jack Danger Canty
... This talk is about how we've turned individual Rails pieces into separate services and scaled our codebase, data, and integration testing practices to support multiple big teams efficiently.

Service Oriented Architecture #REALTALK, by BJ Clark
...our small team has been slowly breaking up our monolithic Rails and Perl legacy application into small apps that handle just one part of our business at a time. We love it. Our small apps are self contained, have crazy fast test suites (without parlor tricks) and it's made our mean time to delivery faster than ever.

Sustainable Productivity with Rails, by Xavier Shay
Ruby on Rails claims to be "optimized for programmer happiness and sustainable productivity." I strongly disagree with the latter assertion. In this talk I will channel my half decade of industry Rails experience into expounding this position and providing constructive feedback as to what needs to change---in both the framework and the community---before we can support this claim. I'll also cover practical techniques you can use to be sustainably productive on your own projects in the meantime.

Hexagonal Rails, by Matt Wynne
In the early days of a project, Rails absolutely dazzles.
Tragically, the very same forces that make it so easy to add new features to a brand new Rails application are the ones that start to hold you back as the number of features grows.
Your test suite gets slower and slower, and refactoring becomes more and more of a chore. Everything seems coupled together, and it's hard to see much of a structure other than the MVC triad.
In this talk, Matt explains why this happens, and shows you a way out, using a ports-and-adapters or hexagonal architecture to introduce a separation between your application's domain logic, and the Rails framework.

Maintainable Ruby on Rails, by Steven Baker
As we enter a decade of applications developed with Ruby on Rails, many teams are starting to feel growing pains relating to design decisions that were made in the past. Development slows down, and morale declines.

Fast Rails Tests, by Corey Haines
Test-driven development is a major player in keeping your design malleable and accepting of new features, but when you stop paying attention to the messages your tests are sending you, you lose this benefit.
In this talk, I will go over some techniques for keeping your test suite lean and fast. Along the way, we'll discuss the design improvements that come out of these changes.

Services, Scale, Backgrounding and WTF is going on here ?!??!, by David Copeland
Designing services from the start can be tricky, but there is guidance out there. Extracting services can be even trickier, and whenever there's a message queue or job processing system, it becomes very difficult to truly understand the order in which things happen in your system. If you're lucky, you've got alerting when things go wrong, but even then, what do you do about it?

Rails services in the walled garen, by  Sidu Ponnappa, Niranjan Paranjape
This talk will focus on our experiences building a system involving about a dozen rails based services integrated over HTTP and XML and the issues we had to deal with when working with large data sets.

View Components in Rails, by Harun Abbas Pathan
There is definitely a need of lightweight view components in rails which are nothing but mini controllers and can be better fit to replace partials and filters. This talk is about Why do we need these lightweight components and details of Merb Parts, Rails Parts, Cells & Apotomo. For smaller applications Filter and Partials don't affect that much, but as the application grows, so your code-base too; then you start seeing just too many filters and partials. So we need a mechanism to serve the unrelated sections on main view using independent mini controllers.

Sunday, October 21, 2012

Worthy Gnome3 Extensions

Here's my list of installed gnome 3 extensions:

Alternative Status Menu

by gcampax
Replaces GNOME Shell Status Menu with one showing Suspend/Hibernate and Power Off as separate items

Axe Menu

by easy
Big and beautiful menu for gnome-shell.

Dash to Dock

by michele_g
Transform the dash into an intellihide dock.


by gfxmonk
Speed up the gnome-shell animation speed.

Notifications Alert

by hackedbellini
Whenever there is an unread notification (e.g. IM Messages), paints the message in the user's menu with a color chosen by the user.

Remove Accessibility

by lomegor
Remove the accessibility button from the top panel.


by Xes
Settings shortcuts : gnome-tweak-tool, dconf-editor, gconf-editor, gnome-session-properties, gnome-shell-extension-prefs, seahorse and nvidia-settings.