Sunday Thought: Patient / Fast

Some times I am such a dolt.

I open a new OSS project and my first thoughts are usually “This library is ^&*$% it doesn’t do anything right.” 

“RAGE! (╯°□°)╯︵ ┻━┻”  don’t they know that, MY WAY is better!

Its sad, but that is exactly what I am thinking. I am on such an immediate gratification high, thanks to my 8 core, 8GB RAM, SSD, super high speed internet capable machine that I forget that not everything can be measured in sub-second latency. Things like instant on-demand movies, and Amazon 2 day shipping don’t help with my attitude either. When it comes to learning, this demand for instant gratification has, many times, gotten in the way of what it is I really want to accomplish.

So, I ran into this situation again this week, and after IM’ing the maintainer – complaining about how this and that worked (ok, lets be honest – I was whining like a 4 year old) – I kinda just snapped out of it. I recalled a quote from the book The Toyota Way, where they stated that the #1 problem with new engineers is that they can’t slow down. They just want to charge into things head first and solve all of the problems. Hmm, sounds a lot like me. Except that I have 10 years underneath my belt now. So, why am I still acting like a new developer? My biggest guess, is that I haven’t really honed my process. I need more people to catch me acting this way and to call me on it. But that can be hard to find in our community, because we all tend to act this way.

We, developers, are always on the look out for the next shiny library or framework that we can “learn” and by learn I mean implement. We like libraries so simple that a new programmer could understand them. We don’t want a learning curve at all. I think that this is one of the reasons things like express.js, flask, and sinatra play so well in our community. You can see, immediately, how it works. They have almost no abstraction over the underlying concepts. Let’s not forget, that its the abstractions that bring the real power, and that not every abstraction is a poor or leaky one.

Its Sunday, which is an introspective day for me, and I want to try and improve myself. I think that if I could work on this aspect of my skills and attitude, I would become a better developer. Being a better developer is something that I want to be. Ok, so how am I going to do this. After much thought, I was reminded of a similar experience that worked well for me outside of the software development world.

Patientfast

For that last three months I have been training in Olympic Lifting. Now for those of you that have never performed olympic lifts, you need to know that while strength is a big part of it, skill also plays a huge part. You can’t just hoist 150 pounds over your head with out a level of skill. The snatch is an explosive lift, that requires an insane amount of patience and balance. My coach and teammates have a phrase that I have come to love. ”Patient / Fast”, which means to me that you have to move fast, but at the same time be patient in the pull. It took me a long time to really grok that concept. It feels like a damn Zen koan at times, but I keep repeating the phrase and each day it reveals itself to me a bit more.

So there I was, at the keyboard, about to burst a vein, when I woke myself up from my emotions, calmed down – and asked myself what would “Patient / Fast” look like here? I decided that I would patiently look through the code, asks questions to myself via comments and then go answer them, and start to understand what the code was doing, on the flip side I would be very fast to start writing, running, and debugging unit tests to get ahold of the code base. Sure enough, the code started to reveal itself to me, I could see the author’s intentions much better now. I started to build up a good amount of understanding, and was able to effectively solve my problem but was also even able to make a nice pull request back to the library that I think cleaned up a very small part of the code base. :) 

In the end, I spent more time than the old me would have liked understanding the library. But the reality of it is, this small investment in understanding a key part of my infrastructure is going to pay dividends in the long run. And less than a day understanding how a critical part of my system works, is indeed a small investment. So, from here on out I am going to remember. Patient / Fast

Posted in Uncategorized | 1 Comment

Fine Grained Issues

One of the little things that I have noticed as a new trend for us here at Dovetail is the use of finer grained issues. Smaller and more focused issues. While this is nothing new, and has always been a helpful thing to do, it has never been easy to do (at least for me). You have to go to some website or app, type a bunch of information into the app and then start over with the next fine grained issue.

Well, I have found a command line app for creating github issues. Its called ‘ghi’ http://rubygems.org/gems/ghi

with this I can open issues with the following simple command

githubrepo> ghi -o "issue title"

or

githubrepo> ghi -o "issue title" -m "issue body"

ghi assumes that you are in a directory of a git repository, which is also nice because you don’t have to tell it which repo to send the issue to.

Take this, and combine it with http://huboard.com and you can get some amazing issue management. Lightweight enough for me to actually use it, and captures enough data that its helpful to the team. Since we all get emails of the issues, the team is alerted and then we all can start piling on comments. Then once it is done, we can simply push the commit with a ‘close #123′ and now the issues is closed.

Again, nothing amazing, just a simple tool and a simple technique that is making my life better.

-d

Posted in Small Ideas | 1 Comment

A brief overview of type system metadata in various languages

So given that a class that is nothing more than a data bag. After all, each object is just a bag of dict’s which are pointers to some byte array some place. What can we introspect about the byte array in each language?

The following is my attempt to document my metadata experiments.

Let’s start with .Net, its what I know the best and what I am ultimately comparing everything too.

.Net

public class Loan
{
    public decimal Amount { get; set; }
}

var aLoan = new Loan {Amount=5};
aLoan.GetType();
//an instance of Type filled with data about Loan
for(var prop in aLoan.GetType().GetProperties())
{
    Console.WriteLine(prop.Name);
}
aLoan.GetType().GetProperty("Amount");
//returns an instance of PropertyInfo

Links:

Type: http://msdn.microsoft.com/en-us/library/system.type.aspx
PropertyInfo: http://msdn.microsoft.com/en-us/library/system.reflection.propertyinfo.aspx

Ruby

class Loan
    attr_accessor :amount
    def initialize(initialAmount)
        @amount = initialAmount
    end
end

aLoan = Loan.new 5
aLoan.class #Loan
aLoan.method(:amount) #a method object

After playing around, I couldn’t find anyway to get the type returned by the ‘amount’ function. This is exactly what I expected, but wanted to confirm. I could get the number of arguments via the ‘arity’ method. That said, I was able to extract a lot more information than I had expected. Special thanks to @jflanagan for the much need schooling in ruby.

Links:

http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Classes#Accessor_Methods

http://ruby-doc.org/core-1.9.3/Method.html

Python

class Loan(object):
    def __init__(self, initialAmount):
        self._amount = initialAmount

    @property
    def amount(self):
        return self._amount

aLoan = Loan(5)
aLoan.__class__ #Loan
aLoan.amount #nope, this returns 5
dir(aLoan) #return 'all the things'

Links

http://docs.python.org/library/functions.html#property

JavaScript

function Loan(initialAmount) {
    //as recommended by Ryan Rauh
    this.amount = initialAmount;
    return this;
}

var aLoan = new Loan(5);
typeof(aLoan); //object
Object.getPrototypeOf(aLoan).constructor.name; //Loan
for(prop in aLoan) {console.log(prop)}; //prop is a string
typeof(aLoan['amount']); //number
//this is actual a typeof(5)

I was again surprised at how much I could extract. Special thanks to @rauhryan for the JavaScript schooling.

Beyond my reach (for now)

So I wanted to do some other languages outside my comfort zone like lisp, haskell, and erlang. But my brain was exploded by the very different nature of the languages. What I do have is how I would set the structure up roughly in the various languages. I hope to come back overtime and update this as I learn or people share with me. :)

Lisp

('Loan, ('Amount, 20))

Haskell

data Loan = Loan { Amount :: Int }

http://www.cs.auckland.ac.nz/references/haskell/haskell-intro-html/moretypes.html

Erlang

-record(Loan, { Amount })

Links:

http://www.erlang.org/doc/reference_manual/records.html

 

Any feedback on how to do these kinds of things in other languages will be most appreciated.

-d

Posted in Uncategorized | 28 Comments

Another Question: Information Sources

Where are you getting your new information on software development? No matter the language or platform. Who outside of the software realm is influencing your development learning?

Please let me know in the comments what books you are reading, what magazines, what websites, who are you following on twitter/blogs.

Interested in hearing from you!

-d

Posted in Uncategorized | 28 Comments

Sunday Thought: Embracing the Type System

I had a lot of fun talking with all of you on the benefits of dynamic languages on the previous post. Definitely getting a better picture of what working with a language like that is like listening to your stories, so thank you for sharing. I also was given a killer link to an over view of type systems that I want to share with you incase you missed it in the comments or when I tweeted about it.

What to know before debating type systems

Yup, I liked it that much. Easy to understand and gave me a fresh perspective.

Also during my read of the above link, was lead to this guy which blew my mind:

A type based solution to the strings problem

Damn, I need to spend more time in haskell. Interestingly, the little languages that he talks about in the post, and how we usually just use strings to represent them. That problem is one of the reasons why I love the little library called HtmlTags (although built by the Fubu guys has no dependencies on FubuMVC) - makes working with fragments of HTML so much easier. I need one of these for everything that I currently use strings for. :)

Which goes back to another thought of mine which is that we as developers depend far too heavily on primitives in our languages. We use strings to represent everything. Instead of taking the time to write a few app level primitives to wrap up these strings inside type’d goodness, we are content to just let them get passed around as anonymous objects. In .Net at the very least we could be using the BCL’s ‘SecureString’ when we need to lock strings down. You can also read an older post of mine on Business Primitives. And if you work with code that loves types as much as your compiler does you can get some really bad ass code to work with (my favorite is the way I can extend things in FubuMVC).

Do you have to write more code? Yes. Do you get value from doing so? Yes. Do you get enough value to make it worth it? That’s up to you, but I know that I do.

I would say that over the past year I have been looking at python and ruby and I just don’t get the same buzz out of those languages that I do out of languages like C# and Haskell. For my larger projects that is. I still maintain a few small sites and scripts in python (and I LOVE IT). but as my projects get bigger my brain is just wired into the type systems provided to me in a more static language. I love it, I can bend C#’s type system to my will in ways that crush my brain, much like the Haskell type system is currently crushing my brain.

Anyways, just my thoughts on this chill Sunday.

Posted in Uncategorized | 3 Comments