Remote Pair Programming – Remote pair programming resources, articles, and thoughts.

I have been a remote programmer for a while now (over 3 years), working across time-zones (10 hours difference in many cases).

I used this blog a lot as an inspiration and took many great tips.

If you are into remote programming and you have remote workers, you should read the posts in this blog.

Remote Pair Programming – Remote pair programming resources, articles, and thoughts..

Do your own Agile…

There’s a lot of buzz going on about software development methodologies, people talking about Agile, Kanban, Pair, XP and more and more.

There’s not much people are talking about when it comes to a single developer.

I have been a consultant/developer for the past ~3 years or so, working from home for several clients both in Israel and abroad (US mainly).

During this time I gained tons of experience in knowing what works and what doesn’t, this may be specific to me, but I don’t think so, so I decided to share this knowledge. So… what am I doing to keep productive during the day?

Pomodoro

The pomodoro technique I am using is simple, I have a small application running on my Mac constantly (there’s windows versions as well).

When I start work, I simply choose start pomodoro, input what I am going to work on and dive in.

Now, all that’s pretty standard, but I am using it with get-shit-done, so once I start a pomodoro, get-shit-done executes work mode.

This work mode shuts down all outer traffic to time-sinks like Facebook, Twitter, news sites, YouTube and many more.

The script is customizable so I keep changing what I want/need. Along side with shutting down the time sinks, I execute a “busy” mode on Skype and any IM I am using at the moment. This is completely automatic, you can see it in the following screenshots

Pomodoro scripts
IM status change by Pomodoro

As you can see, any pomodoro I do is going into “Things” which I can then look at my day and see where my time went, what did I accomplish during the day and so on (it has OmniFocus integration as well).

If you want to get the app, you can get it here

Stay Hydrated

This may seem stupid so up high here, but it’s REALLY important. I found that in days where I drink and stay hydrated, I am much more productive, less tired and get a lot more done during the day.

Water break

Another benefit is that I need to visit the restroom quite often :) so I don’t slack around in the chair too much. I use an application for that as well, it sits in my top bar and reminds me to take 5 minute water breaks every hour. if you are wired in, you can just ignore that, but don’t ignore it too much, it’s not the point :-)

If you want to get the app, you can get it here

Things To Do

Things To Do

I open every day with a “things to do” list.

I write down anything I need to do, and then I forget about it, I don’t keep my mind occupied with all I need to do, I look at the list during the day.

One important thing is that I set times for stuff

  • 1-2pm => working on the cashier module
  • 2:30-3:30pm => working on the master/slave @dirty variable

While of course, these 2 tasks don’t actually take an hour, it’s here just for an example :-).

Anything you need to remember during the day, write it down, than simply let it go, don’t keep you mind occupied about that.

I keep any blog post idea, stuff that come to mind on other project that are not currently in work order and more…

Knowing I have it written down saves me the trouble of having it in my brain, and I dedicate all my brain resources (which are slim to begin with) dedicated to my code.

I must say, I have tried any TODO app out there, the one that works best for me is a pen and a paper, I use Things as a history for my pomodoros and nothing more (usually)

TDD

Another possible controversial title in a “be productive” blog post :-)

When I am TDD’ing my mind goes into a “small piece” mode, I think only about the next 2-3 steps in what I need to accomplish.

People (wrongly) think that TDD is time consuming and they get less done, I have proven it numerous times in the past that this is incorrect, people that TDD are often 2-3X more productive then others.

Just think about every time you open a browser to “test” something, it can be done in TDD while you save your file, and you can instantly see if you broke something else in the code you are not thinking about.

The right side code is test, left side is actual controller code :-)

TDD your ass off

When you are not productive…

There are simply days when you are not productive on the actual things you need to get done, in these days I don’t try and force myself into it, I simply move to other exciting stuff for 20-30 minutes (sometimes more)

I do a TON of open source, I help people in groups, forums etc..

Sometimes, answering a question, gets me back into code mode and I can find myself wired in for 2-3 hours after it.

To sum up

I touched but a fraction of my work methodology.

The thing is, you need to find YOUR groove, you need to find your pace, the hours where you are productive, the things that excite you.

You may take some of what I said here, you may take all and you may take nothing, all I am saying is that regardless of where/how you work in the team, you can have your own thing going on.

You may work with Pivotal Tracker or Trajectory, but still maintain your TODO list for the next few hours (like I do).

Share your thoughts…

I would love to hear what you think in the comments and have a discussion.

Fuck you, pay me!

As every developer, I am a member of numerous groups, email groups, chats, forums, facebook groups, Quora etc…

Usually, I really try and help people in those groups, even if they ask the most simple question, one that a developer with just a few years behind him take for absolute granted. Once in a while, there’s a question that hits me in the stomach, that touches a nerve.

I am far from taking any of this too personally, this is also becuase I will never follow up on these offers, but the reason it makes me angry is becuase other people might, some developer with less experience might fall into the bullshit some slick salesman sells to them.

One of these questions was posted today to a user group I am a member of in Israel, it’s a forum for web developers.

The message was posted by an SEO company representetive, most of the time just this title is enough to get what the content is about.

What was the message about and why did it make me angry?

Well, the message went on and on as in how they are one of the leading companies in Israel (but provided no link to a website, nor the company email, or even the name). He said that over time, they gained an astonishing experience in developing content management systems (but have none of their own).

Now, they are looking for a guy (it’s ok if he will be a beginner), that will work for no money, just for the amazing experience they have.

They will give him tips as to what the system should look like, and then he will develop it. They will then sell it to customers and “most” of the profit will go to that developer.

No data was supplied as to what the demands are and what is the quantity of the work.

Just in case you know how to read Hebrew, here’s a link to the message: here

Fuck you pay me!

A while ago, I watched a presentation over on Vimeo that was really well put together.  It was nothing new to me, and I have experience these sort of behaviors when I was the CTO of a web design/development firm. What’s amazing about this talk, is that when you take out the language, it’s structured really well, and the attourney speaking there is quite a sharp guy.

2011/03 Mike Monteiro | F*ck You. Pay Me. from SanFrancisco/CreativeMornings on Vimeo.

So, what is my point?

Well, I talked about the message that through me into this post, I talked about the presentation, so what the hell is my point?

My point is that you should not work while not getting payed!
Never, Ever.

The only exception is that if you are in a partnership with a party on the same professional level as you.

The relatioship between you should be equal, what this guy is offering is far from it.

No serious professional developer I know will ever follow up on these suggestion, nor should any beginner developer.

The business of free

There are many things you can do for free that will promote you as a professional and as a person. You can build a website for a charity organization, you can contribute to open source project etc…

As a conclusion, you can watch this funny as hell youtube video.

Is this post the entrepreneur killer?

No, it is not, I am not going against people in pursuit of their dream, I am not going against people who build a startup from the ground up, I am going against messages targetting youg developers, dismissing the professional capabilities our business demands and holding back the web.

That is what I am against, nothing else.

Personal note

I really don’t get the people offering these things, how do they run a business and how are they able to request such a thing.

Did any of them ever offer anything to a client for free, will they give me a car with a sticker advertising their business?

What do you think?
Comment below and let’s discuss this issue…

Get shit done. I mean it!

Like any other web developer that respects what he does, I am constantly trying to better myself as to how productive I am, how much I am really getting done and what is the quality of what I do.

Along the way, I tried many systems and methods for getting myself in focus, for not getting distracted by all the noise, both digital (mostly) and human around me.

I think that finally after a long time, I did find what I was looking for, and there’s nothing fancy about it, no fancy system, no calm music no nothing.

So, what is it?

First, let’s focus on the problem, as I am sure most of you will relate to it.

The problem, and this comes as a personal confession of mine as well, is all of the so called “social” websites, and all of the news around us. Think about it really, in an average day, you are exposed to so much digital noise that can blow your head. There’s Facebook, Twitter, Google Plus, DM, Email, Messages etc… How will you be able to get shit done with all of these in your way?

Well, You can’t, at least I can’t.

Let’s talk about a slice of 10 minutes from a regular, not that focused day of programming.

But first, a short introduction…

You come to work, maybe you are a bit tired, you are not the “sharpest” that you can be, your mind drifts to the car you want to buy, to those shiny Dr. Dre headphones in the Apple store on University Ave. Palo Alto.

Well, you get the drift, you are not as concentrated in the work as you should be, Add an iPhone notifications through Facebook to that mix and you get a mishmush of thoughts that can go through your mind in a single minute.

My focus is very fragile, if I don’t really focus at what I do, I can’t be the coding machine that people think of me, I really can’t. So, back to the slice of 10 minutes of work.

00:00 – Sit down, open up textmate on the project
01:00 – Open up the test and save it, just to see nothing breaks
02:00 – Watch the console as it goes green on 100+ tests
03:00 – Forget you are doing something, go to Facebook
10:00 – hehe, this is a funny youtube kitten @elado posted.

Maybe, I got the times wrong, but the second your mind gets a chance (probably before minute 3) it will drift away to the less painfull, not thinking part of it (a.k.a twitter and facebook).

Don’t get me wrong, I LOVE twitter and I LOVE facebook, it’s just there’s a time and a place for these websites and coding time aint one of them.** What have I tried and failed (and probably you did too)I tried being tough on myself, I tried closing up my facebook account and removing the Twitter icon from the dock.

Nothing helped, the behaviour pattern is so embedded in me, that it just failed.

What the hell does Cezar Millan got to do with that?

Cezar Millan is the dog whisperrer, I am addicted to his show on National Geographic. What he always does, to snap a dog (sorry about the comparison here, stay with me) out of his bad behavior is touch him firmly on the body.

Well, I thought about it, but the conclusion was not that I hit myself every time I go to Facebook, it’s just a virtual slap in the face.

OK, I am getting to the point.

So, what’s a slap in the face virtaully, when you want to go to Facebook.
This is:

How did I do it?

At first, I did it manually, I changed the hosts file on my Mac, and made all of the websites I don’t want just go to localhost. That is brutal force right.

BUT

That was all I needed to get back to focus, the distraction part was so automatic, I did not intentionally go to Facebook (I swear), I just did it in a moment where my mind drifted, in the nanosecond where focus is fragile. So now, when I do it, I just see the Forbidden message and go right back to work.

And then, it got even better.

But I will let you see for yourself.

You can go to my fork of the repository here

Now, all I do when I want to really work and focus is go to the terminal and hit

sudo get-shit-done work

and when I have time, like after lunch for 10 min’s or so, or at night from home is just

sudo get-shit-done play

Beautiful, elegant and simple solution for the problem, it helped me a great deal to be much more productive and my focus now lasts for hours (that sounded like a cheap Viagra spam message :))

403 Error when using passenger for rails deployment

passenger-e1298322115303
I have been using passenger for local Rails deployment for about 6 months now. I love the flexibility of not having to run Rails server, which enables me to work with sub domains and all kinds of other good stuff.

Lately, about a month back I started using my good friend and co-worker @elado‘s tip of putting all of my codebase on Dropbox.
Here’s a link to his post.

The most amazing thing about it is that you get constant backup with each save, and yeah, don’t get smart on me, I use GIT of course.

Now, since I did that, I kept getting all kind of strange 403 errors from passenger telling me that I can’t pull the favicon.ico file and all sorts of nasty voodoo bugs like that.

I went into the access logs an figured out the problem. The problem was that Dropbox was not properly configured with all the permissions that Apache (passenger) needs.

So, I added these lines of code which solved my problem.

[xml]
<directory "/users/avitzurel/dropbox">
Order allow,deny
Allow from all
</directory>
[/xml]

The file (for me) sits in:

[shell]
/private/etc/apache2/httpd.conf
[/shell]

After you do that, don’t forget to restart Apache for it to pick up the changes in the file.

[shell]
sudo apachectl -k restart
[/shell]

Good luck!

Use before_destroy on a model with paperclip

I have an application that I’m working on, this application has a demand that I will show the total files and the file total size inside a project. Here is my model:

Screen shot 2011-01-04 at 10.15.18 AM

Of course I have the option of using joins and so on and then calculating the file size, but because every project has many folders and every folder has many attachments this seems a bit off and not straight forward.

This is absolutely not the Rails way of doing things, so what I added a couple of fields inside the project model and here is what my model looked like after the change:

Screen shot 2011-01-04 at 10.18.59 AM

Now, I have straight forward fields inside my model, and the database work is very light, fast and straight forward. I added an observer for the attachment model, just to update the count and the total file size in the project model.

Here’s my observer’s code:

[ruby]
class AttachmentObserver < ActiveRecord::Observer
observe :attachment

def after_create(record)
project = record.project
if project
project.increment!(:file_count, 1)
project.increment!(:file_size, record.sketch_file_size) unless record.sketch_file_size.nil?
end
return true
end

def before_destroy(record)
project = record.project
if project
project.decrement!(:file_count, 1)
project.decrement!(:file_size, record.sketch_file_size) unless record.sketch_file_size.nil?
end
return true
end
end
[/ruby]

I added the observer to the application configuration.

Now, everything seemed to be working fine on create, when I deleted a model (deleted an attachment) I got a nil exception on the skecth_file_size property. The problem is that the paperclip plugin deleted the sketch file before my callback and so prevented me from using it.

This required a patch to the paperclip plugin.

Inside the paperclip plugin there’s a file called paperclip.rb
Ffor me, it was line 242, I changed it from before_destroy to after_destory like so:

[ruby]
after_destroy :destroy_attached_files
[/ruby]

Now, also in attachment.rb (also in paperclip plugin)

For me it was line 335:

[ruby]
unless instance.frozen?
instance_write(:file_name, nil)
instance_write(:content_type, nil)
instance_write(:file_size, nil)
instance_write(:updated_at, nil)
end
[/ruby]

This worked like a charm and now my callback works, updating the model of the project as the files are adding and deleting, I don’t have to do complicated joins to get simple data.

Here’s how it looks in my application now:

Screen shot 2011-01-04 at 10.26.28 AM

This is the code I use to make it happen:

[ruby]
<h2>
<%= @project.name %>
</h2><em><%= "#{@project.file_count} files, #{number_to_human_size(@project.file_size)}"%></em>
[/ruby]

gitignore template for a Ruby on Rail project

Been working with Ruby On Rails for about 10 months now, about the same amount of time with GIT, I enjoy them both very much.

When I start a rails project and connect it to GIT, I always create the same gitignore file. Therefore, I thought I should share it with you.

Here it is:

[shell]
log/*
tmp/*
.DS_Store
db/*
[/shell]

Enjoy!

Memory management in flex applications

Lately there is alot of buzz about Flex application performance, keeping your memory low and just in general, keeping everything managed under your fingers and not just counting on the flex framework to manage your memory.

Flex has a garbage collector, but it’s a bit special on the way it handles memory, so I thought I would layout some general rules on how to keep memory low.

First thing we need to understand is that any application we will build in our careers will be using some amount of memory, and because memory is not infinite, we should keep our applications memory as low as possible.

I always say the best way to describe memory management is to “be smart” meaning – always have memory in mind, never let it go and by doing this your application will keep lean and thin all the time.

By taking up too much memory you can get into alot of trouble – you can make your users hate the application because it is running slowly and making their computer run slowly. Also, the application can simply crash.

I hear from programmers in my consulting that computers are getting more and more memory and you can see laptops coming with 4G of memory out of the box and so on, but actually we are also seeing a movement towards mobile devices such as mobile phones etc. these mobile devices do no allow us to use too much memory because it’s limited resource.

Memory leaks

Memory leaks is a big issue in flex programming and it’s generally speaking divided into 2 parts, first when our application is using memory in parts we didn’t want it to use and the other part is when we didn’t handle the cleaning part efficiently enough.

Flash handles memory management through something called “references”. Just to make things clear before we begin, the only way an object is cleaned by the garbage collector, is be not having any reference from that object to another object, that way you can make sure the object will be “picked up” by the garbage collector.

Event Listeners

Event listeners are by-far the most mis-used, mis-understood part of flex applications. I have seen people/developers using those without even understanding what is actually happening behind the scenes and when (and if) those are cleaned up in memory.

I will try to explain.
Let’s take this peace of code:

[as3]
//objectX
objectY.addEventListener(some_event, some_function)
[/as3]

We have two objects (ObjectX, ObjectY) – Object Y has a reference to a function in objectX just by passing the function. Now, if your application has a reference to objectY, object X will not get cleaned because it has a reference to a function.

There is actually something called weak event listeners, by default the event listeners are “strong” meaning every event listener is a function, if you specify the event listener is “weak” then the event listener does not count as a reference.

Static Variables

Static variables are never cleaned in the entire session of a flex application, meaning if you set the variable’s value with an object, this object will never get cleaned.

If you want to make sure the object is cleaned you should null out the variable.

[as3]
// static variable
public static var _foo:Foo;
//setting the value
_foo = new Foo();
//clean
_foo = null;
[/as3]

Dictionaries

Dictionaries are another big problem and source of misunderstanding in flex applications.

Dictionaries are key-value collections, meaning you have a collection that is built in the form of a key and a value attached to it.

You can use objects as your key and your value, for example let’s say we have two objects (ObjectX, ObjectY), you add an entry to the dictionary where ObjectX is the key and ObjectY is the value.

By default the values in dictionaries are “strong” and you can specify a “weak” key, by doing this, you can actually make sure that if nothing else has a reference to ObjectX, it will get cleaned by the garbage collection. BUT, ObjectY will not get cleaned even though the key for it got cleaned from the dictionary.

There are many questions on this issue from flex experts to adobe, those questions generally start with a WHYYYYYY????

I would also like to understand why, but this is the situation and we have to deal with it. In the Flex-Show podcast Aaron says that if you iterate through the values of the dictionary, then all values that don’t have a key (it was cleaned remember?) gets cleaned immediately.

I never encountered this behavior, but Aaron knows what he is talking about, so I trust him :) (Thanks Aaron).

Conclusion

I think those are the main three issues in flex applications. There are a few more, but if you handle those three you should be fine and your application will actually be pretty lean (at least in memory management).

** this post was inspired by Aaron’s talk on the podcast, I enjoyed it so much I decided to make a post on the issue.

Keep your mxml files neat with View Helpers

I have been working with flex and consulting about flex development for quite some time now. I guess about 3 years of consulting and 4 years of hands-on development.

I have seen flex applications written in many ways: mxml files, as files, namespaces and more. I guess there is no “right” way to do so, or at least not just one “right” way.

These past few months, I have started working with mxml files in a way I think is very convenient. It keeps my mxml file very lean and clean, all of the view code is in a separate action-script file which inherits from a base class.

I want to show you this, first. This is the sample project, this is what it looks like in flash builder:
Screen shot 2010-08-19 at 5.26.08 PM

As you can see, there is the main application, an mxml component, the BaseViewHelper class and that is just about it.

Now, let’s have a look at the BaseViewHelper class.
*note: this is a stripped down version of the class, it has many additions in my project, like a way to add validations, clean and dirty modes for the model and more, this is just to see the way I work, you can add your own additions to it.

[as3]
package com.kensodev.core
{
import mx.core.UIComponent;

public class BaseViewHelper
{
private var _view:UIComponent;

public function BaseViewHelper()
{

}

public function init():void
{

}

public function set view(v:UIComponent):void
{
_view = v;
}

public function get view():UIComponent
{
return _view;
}
}
}
[/as3]

As you can see, I kept it very simple. It has a view getter and setter to set the view it handles, and an init function (for creation complete events).

Now, let’s see an mxml component and how does the helper fits, but first let’s see a view helper which inherits from the BaseViewHelper class.

[as3]

package com.kensodev.views.helpers
{
import com.kensodev.core.BaseViewHelper;
import com.kensodev.views.MyViewComponent;

public class MyViewComponentHelper extends BaseViewHelper
{
public function MyViewComponentHelper()
{
super();
}

public function get myView():MyViewComponent
{
return MyViewComponent(this.view);
}

public override function init():void
{
//TODO Auto-generated method stub
super.init();
}

public function myButton_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
}
}
}
[/as3]

This is a helper file for the MyViewComponent. Now, here’s the source code for implementing the helper inside each View component

[as3]
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
width="400"
height="300"
creationComplete="helper.init()"
xmlns:helper="com.kensodev.views.helpers.*">

<mx:Script>
<![CDATA[

]]>
</mx:Script>

<helper:MyViewComponentHelper view="{this}" id="helper" />

<mx:Button id="myButton" click="helper.myButton_clickHandler(event)"

</mx:Canvas>
[/as3]

As you can see, the file is very clean, it has only data relevant to understand the structure of the component (which is all you need in mxml), all of the logic files “seats” behind the scenes.

There is a naming conventions for views and view helpers
its
view_name
view_nameHelper
This way, when you navigate your way through the code, you can always see what you are looking for with ease like so:

Screen shot 2010-08-19 at 5.36.53 PM

I hope you take inspiration with this way, I assure you I did, it’s a very useful way to manage large projects with many views and view helpers.

The source code of the example project is on git.

******

update:

After a discussion with @douglasknudsen I want to make things clear, this is not the ViewHelper implementation of cairngorm Mvc framework, it’s something you should (or can) write on your own just to make things organized and clean.

I am using it regardless to the MVC framework I am using which is RobotLegs B.T.W

Should all developers be (active) members of the virtual community?

Usually when I blog, I make comments, raise decisions, write code or something like that, it’s never a question. This post, above anything else is a question and a try to spark a debate from my fellow developers and software craftsman out there.

Earlier this week I started working on a very interesting project for an international company creating test suites for devices and applications. The suite is cross platform and can run on any machine both windows and Linux and test any device, from mobile phones to DVD’s to diving sensors.

The client side is written in flex and pure AS3, the server and services are written in Java and Perl scripts.

What is my point?

My point is that this company has some pretty strong developers, all know a thing or 2 on software developement, both in Java and Flex.

Another thing, usually when I get invited to consult and develop for a company saying “we have a flex application” I do see an application but it’s horrible, un-scalable, mxml+code in the same file, services calls in mxml and more.

In this company, that wasn’t the case. The application is actually pretty solid, stable and gone over more then a couple of QA steps inside the company and clients. You can imagine that the developers over there can contribute a thing or two to the community.

OK, so far so good, what am I saying here?

From conversations I had with the developers I found out something amazing, none of them has a twitter account, none of them has a blog and none, absolutely none contributed to an open source project, not even a line of code, not even opened a case in the WIKI.

so, what do you think?
Should all developers be active members of the community?
Should every developer have a profile and answer questions on the amazing StackOverflow.com?
Should every developer write a blog?

Love to hear your thoughts on this…

Another thing, when you interview programmers, do you care about these issues?