Saturday, September 22, 2012

Functional Programming

I've really enjoyed the coursera courses that I've taken so far - game theory, compilers, algorithms (part 1). I've enjoyed them so much that I'm taking another one - functional programming principles in scala.

I've gone through the setup and my first impressions were simple: it uses a lot of my RAM and uses maven repositories (using sbt).

Here's hoping I finally grok functional programming.

https://class.coursera.org/progfun-2012-001/

Wednesday, July 11, 2012

I made a compiler?

Avid readers of my blog will recall that I enrolled in an online compilers course. Four assignments,countless quizzes/exams and many late nights later, I'm done! According to my calculations, I just barely made the pass mark, which I'd say is not as good as I'd hoped, better than it could've been and less than I'd expected. But gluing my 4 assignments (lexer, parser, semantic analyser and code generator) you end up with something that can compile some programs which run and give you the output you expect!

To be fair, the course description did warn that it would be tough, and not a great place to learn a new language (C++ for me). But apart from C++, I've gotten exposure to flex, bison, and MIPS. I recommend the course to anyone willing to devote the time into it.

Sunday, April 29, 2012

Let's make a compiler

These past couple of weeks, I've been taking a game theory course https://class.coursera.org/gametheory/class/index

It's almost like taking a course at uni, except everything is multiple choice, styled with twitter bootstrap, and without the long commute. The course is winding up, so I thought I'd start another course.

As you may have guessed from the title, that course is about compilers https://www.coursera.org/course/compilers.

Compilers is one of the courses that post-Uni, I wish I had taken, so I'm pretty excited for the course. I am of the belief that understanding what goes on beneath the layer of abstraction you usually work at will make you write more effective code.

At the same time, I'm going to attempt the programming in C++. I've never written anything C++, and it's been a while since I last used a programming language without GC (C was my last one) so it'll be interesting to see how far I get!

If you're interested in taking an online course yourself, have a look here for something you might be interested in: https://plus.google.com/107809899089663019971/posts

Saturday, March 24, 2012

Making unity useful

ccsm -> ubuntu unity plugin -> behaviour -> key to show the launcher = <alt><super>

Tuesday, January 31, 2012

Last One

This is the last post in my write a blogpost every day in January challenge. So I figure it's time to get meta. I started this challenge because I had previously tried to start this blog. Then I ended up with barely anything on this blog. Then I wanted to have something on this blog, because I told someone I would. Rather than one good post, it's a lot of small posts, though.

Starting this challenge gave me an excuse for the writing to not be great (actually, an excuse for it to be terrible). It's a lot easier to write something when you don't pressure yourself to make it too meaningful.

Writing these 30 posts has made me realise how contradictory I can be. In every post, I can poke holes in the things I've said.

New challenge starting tomorrow: 30+ minutes of cardio every day for as many days in a row as I can manage (first goal is getting through February).

http://www.ted.com/talks/matt_cutts_try_something_new_for_30_days.html

Monday, January 30, 2012

Little Things

It's funny the things we remember sometimes. A little detail - a phrase, a sight, a sound - will stick in our memories, when things we'd much rather remember - where we left our keys, for example - won't come back no matter how hard we will them to.

Sometimes, these things aren't important at all. But often, I wonder if this is really the case. I will reflect more on a particular tidbit of memory and draw connections with other small tidbits. Soon enough, the tidbits form a big tidbit, that I wouldn't have seen before without each of the small bits.

As things are in the large, so they are in the small. See what you can pick up from noticing the details, and you might be surprised.

Sunday, January 29, 2012

Stressless

Stress less until you're stressless. When we are under stress, it can be hard for us to develop creative solutions. You're in fight-or-flight mode, engaging your basest instincts. Unless you're Leonardo da Vinci, your basest instincts preclude being very creative.

Is stress ever helpful? It can be. A little bit of stress can make you concentrate. A little more stress can get some adrenaline pumping.

But don't let stress ever be your baseline state. The more stress you start off with, the less excess capacity you have to handle stress when things go wrong (and things will go wrong!)

http://www.randsinrepose.com/archives/2011/04/04/a_hard_thing_is_done_by_figuring_out_how_to_start.html

Saturday, January 28, 2012

Concentrate

It can be hard to concentrate, sometimes. Especially with a wide array of distractions readily available. And yet, to do anything more than habitual drudgery, we need to be able to concentrate. And not just for a minute at a time between searching tweets. So how does one concentrate in a world filled with distractions?

There are two options. Change your environment to minimise distractions. The second is to change yourself to be less distracted. Sometimes you won't be able to change your environment.

It would be nice to focus in a quiet park. Tuning into some radio (using earphones) could be the next best thing. If your work involves a lot of co-operation, however, this may be impossible. You're left with using your own brain to tune out the noise.

Have you tried doodling?

Friday, January 27, 2012

Tracking progress

If you're trying to improve something, you should track it. Tracking does a couple of very important things.
  1. It forces you to have an idea of what you're measuring. If you're a writer and your measure is how long you spend with a pen in hand, you might find a pen in your hand walking down the street, but that doesn't exactly help you getting your book ready for publishing.
  2. It gets in your face. If you're not putting the effort in, it's not hidden from you. You'll start to see a trend and notice when you haven't been hitting your targets.
If you start tracking, and you notice your metrics improving, but you don't notice any progress (over a sustained period of time) that's a hint that you're tracking the wrong thing.

I recommend tracking in chunks of a day.

Links:
http://calendaraboutnothing.com/
http://lifehacker.com/281626/jerry-seinfelds-productivity-secret?tag=softwaremotivation

Thursday, January 26, 2012

Teaching

Ah teaching, the sharing of knowledge from one to another, and then another to others. It's like a bittorrent swarm that's just starting up. At first, one holds all the knowledge, shares it out a chunk at a time, and then that recipient can share the knowledge too. If it works, pretty soon everybody is sharing knowledge and everyone has all the pieces, and newcomers are inundated with knowledge as fast as they can take it in. No longer are they limited by the amount of teachers - everybody is a teacher.

A most curious part of teaching, however, is that in teaching, you also learn a lot. The equivalent bittorrent analogy is that no individual has all the pieces, but collectively, a full copy exists. Only by sharing, can the pieces be put together, and everybody is better off for it (ignoring throughput costs).

plz seed knowledge

Wednesday, January 25, 2012

Thankfulness

Do you remember the last time somebody thanked you for something? Do you remember how you felt when it happened?

Usually, thanks is reserved for a special occasion. Perhaps you did something far beyond your call of duty, or have been outstanding over a period of time. But wouldn't it be better if we recognised these every time they happened? With just a little thank you?

Little things don't cost a lot, but can mean much. It motivates you to go out of your way to help somebody. And you may also feel compelled to thank others more often.

If everybody thanked everybody for every little thing, does the thanks then become meaningless? Perhaps. But when everybody can thank everybody (that they meet) for something, that would be a lovely world to be a part of.

Tuesday, January 24, 2012

Debugging

Debugging is that wonderful time when your expectations don't line up with reality. You set things up just so, making sure they make sense, and then reality hits you with an unexpected truth; you are wrong.

But you eat some humble pie, interrogate your expectations, and revisit your assumptions in the light of this new reality. After you've done all that (and save some pie for me!), you find a problem, adjust your expectations and assumptions, change your implementation and now you and reality see eye to eye once again.

Of course, other things get in the way as well - bugs in third-party code, or any dependencies your code or toolchain requires. Always check your own code first. I don't care how many compiler bugs have bitten you before, you know your code, so it's quick to check. Once all that's done, find the bugs, create patches, and forward them to the appropriate maintainers.

Don't let your ego get in the way of successful debugging. What you thought should be true is not, and no amount of "But it should work!" will make it so.

Monday, January 23, 2012

Feedback

Feedback is a tool for guiding action. Good feedback says: "I like that, more of that please." Bad feedback says: "I don't like that, less of that thanks." Lack of feedback says: "Did you change anything? I didn't notice. You might want to try something else."

Feedback is extremely important. Imagine trying to fire arrows without the feedback of seeing where your last arrows hit. You could try and try, but you wouldn't know if you were getting any better or worse at hitting that bullseye. You wouldn't know if you needed to aim a little left, right, or even if you weren't reaching the target at all.

Seek feedback when you need direction. Value feedback when you get it. Give feedback often (and appropriately...).

Sunday, January 22, 2012

Sleep

Sleep is important. And it is important enough to get right. If you don't sleep, you die. If you don't sleep enough, you have a bad day. If you sleep too much, you don't have less time in the day. As a species, sleeping is something everybody does pretty much every day.

It's thusly interesting that sleep disorders are so common. We should've gotten better at it by now, no? Perhaps it is my limited worldview. I don't see too many bloggers in third-world countries blogging about the great sleep they get, after all.

For myself, sleep is something I value. But I also value my time. If I could spend one hour each day sleeping less, being only slightly less well-rested, that seems like a good trade-off to me for seven hours "extra" a week.

However, I don't think polyphasic sleep is for me.

Saturday, January 21, 2012

Present, Future and Future Past

Our preferences are often different based on when we are. If we are now, maybe we feel like taking a nap. If we are looking to the future, maybe we'll do some hard work then. If we are looking to our future selves looking back to now, maybe we don't want us to to take a nap, but do the hard work instead!

Hard work often pays off later, but laziness always pays off now!

The trap of putting things off to the future, is that the future becomes the present. And the future present you, is infinitesimally different from the present present you. If the present present you is putting things off until the future present you, what stops the future present you from putting things off to the future future you!?

"""
[9] This is a good plan for life in general. If you have two choices, choose the harder. If you're trying to decide whether to go out running or sit home and watch TV, go running. Probably the reason this trick works so well is that when you have two choices and one is harder, the only reason you're even considering the other is laziness. You know in the back of your mind what's the right thing to do, and this trick merely forces you to acknowledge it.
""" http://www.paulgraham.com/wealth.html

Friday, January 20, 2012

Speaking

For any given subject, there will be competing theories. Or perhaps, a number of theories, some more competitive than others.

To decide between them is hard, especially in the face of a lack of facts. This will often be the case, and you may often be under time pressure, too. Thankfully, in the absence of facts, a debate will often have opinions.

A successful debate requires both sides to put forth convincing arguments for their own side, and against the others. A debate can be enjoyable, but often the debate is simply a mechanism to make a decision, rather than being purely for enjoying a hearty verbal joust.

To do so, there must be a change in at least one side, to yield to the other, or improve on both to something better than either. This is not possible, if you are not listening well. If you do not argue well, you risk being stuck with a worse option.

"strong opinions, weakly held"

Thought path: listening -> speaking -> speak as though you are right, listen as though you are wrong -> http://collierbrown.com/2010/10/01/speak-as-if-youre-right-listen-as-if-youre-wrong/ -> googling -> http://bobsutton.typepad.com/my_weblog/2007/02/why_specialists.html

Thursday, January 19, 2012

The Weird Wee Hours

Sometimes in my life, I'll have times where I'll think everything is going ok, good, or perhaps even well. It's at these times that it's all the more startling when I suddenly feel "wrong". And not just wrong, but wrong for such a long time. Wrong in a "Why didn't I see this before?" way. Now, (or more accurately about an hour and a half ago) is one of those times.

Our lives are balancing acts. Nothing is purely black or white. A reasonable approach is to weight all characteristics, and make a call based on the totals. A less reasonable approach is to look only at the positives, or only at the negatives.

This less reasonable approach can be taken because of lack of sleep, or other reasons.

Wednesday, January 18, 2012

Listen

Listening is one of the most valuable things you can do. Your body is optimised for listening - two ears, one mouth blah blah blah.

In all the world, with billions of other people there is far more knowledge from others as a whole, than coming from you.

Humanity has stored its collective knowledge in writings and recordings. Open your ears, and take it in.

Listening is especially important at the start. If you do not listen carefully, there are many possibilities leading you to dead ends. Although you may find this out quickly for each, in aggregate, you are hindered greatly.

Tuesday, January 17, 2012

Dealing With Setbacks

It's important to have a backup plan. Sure, it's nice when everything goes swimmingly, but the chaos monkey will often get in your way. Your backup plan is an investment you make to increase your chance of success.

A side-effect of having a good backup plan, is that it forces you to think more deeply about your plans, or at least for a longer time. Think of it like a speed bump that slows you down and gives you more time to look around for hazards; you have more chance of avoiding incident entirely.

Some setbacks can't be dealt with on-the-spot. But are trivial to handle with just a little bit of planning. For example: what do you do when you're taking an exam, and your pen runs out of ink? With a bit of planning, and bringing (at least) two pens, you would've been fine.

Monday, January 16, 2012

A Thought Away

Mind control should be an efficient thing. Rather than pushing somebody's head in the direction you want it to face, you simply think it, and it happens. This avoids all the energy loss associated with lifting one of your own fingers, to name just one loss.

Two types of mind control:
  1. Using psychic or electric powers to manipulate another's mind to do your bidding
  2. Being in control of your own mind
The first seemingly requires less willpower, while the second requires vastly more. But if you practise often, it will become your own superpower, one not too many other people have.

Sunday, January 15, 2012

Yourself

Be yourself. If you don't, who will? Nobody. So be yourself.

Why be yourself?
  • You will only be second-best, at best, at being somebody else.
  • Claim your uniqueness!
  • You are optimised to be yourself.
If there was a universally "optimal" personality that everybody should aspire to, that would be too boring. Unless that personality enjoyed everybody being the same. But without diversity, all of humanity's eggs are in one basket. Surely that would be suboptimal. Thus, I have proved, by contradiction, that there is no universally "optimal" personality that everybody should aspire to.

As a corollary, be yourself. (This is not a true corollary, but I can't fit the proof in the margins of this page - I haven't found out how to put text in the margins in this editor.)

Saturday, January 14, 2012

New Things

I like new things. I guess you could call me a neophile. I get a little buzz when I get a new SMS or email. It's probably why I also like checking my twitter, and facebook, and google+, amongst other things.

But I also like old, familiar things, so I guess I'm not a true neophile. The idea of using something until it's used up, and using things for non-standard purposes.

It makes sense, then, that a combination of new and old, would be especially appealing to me. I signed up for Amazon's AWS service yesterday (What else would you do on a Friday night?). I first saw the AWS console with its myriad of tabs - each one promising new and exciting opportunities. I also started a new project on sourceforge (after being confused by its myriad of options). I didn't realise all the things sourceforge does apart from project and code hosting!

Friday, January 13, 2012

Superstition

Happy Friday the 13th, everyone. Have you had any bad luck yet today?

Superstition ain't the way - unless it works for you. If you need a four-leaf clover and black-cat-filtered glasses to believe you can jump that little bit higher, or run that little bit faster, or lift that little bit heavier, I say go for it.

Believing you can is half the battle. There's a spectrum of attitudes from an "I could never do that", "I can't do that", "I can do that", to "I will do that" (and ultimately "I've done that"). Some simple things will happen whether or not you think they can. Maybe you don't think you can get the wire of your headphones to tangle - but if yours are anything like mine, they will tangle all by themselves! Other things will require a conscious, sustained effort. If you can't believe that what you're doing will ever work, how, other than by being crazy, could you continue working in that direction over months, years, or decades?


Thursday, January 12, 2012

Doing The Important Things

What's the most important thing you should be doing?
Why aren't you doing it?

If you answer to the second question is "I am", do not be surprised when I call you a liar. I can hardly imagine a set of circumstances where reading my blog is the most important thing you should be doing.

Nothing in life worth having comes easy. Some things, you just have to work at.

You will hit challenges along the way. You will start to ask - Is it worth it? What if I work this hard, but I only fail? Take comfort in the fact that you dreamt of a better future, and took action. Far too few even make it that far. But know that when you succeed, your reward will be worth it.

Wednesday, January 11, 2012

Writer's Block

What do you do when you have writer's block? You write anyway. Don't think too much about what you want to say, but say what your mind is saying. The words will follow naturally, just listen to them and write them down. Don't erase them (yet). You just need to get the first draft, and then rewrite it (over and over). A spark will hit you, which will lead to another, and another, and before you know it, you'll have a thunderstorm of ideas.

What do you do when you really can't think of anything to write? You write something that's already been written - just write, then change it up a little. If it works for music, why not words?

Coders do this all the time - finding a piece of code that is near to what they want, and modifying it 'til it suits their purposes.

Write something, anything. Come back later and change it. But I can tell you now, writing nothing is much further from writing what you want to write than writing something you don't want to write.

Thought Points:
Finding Forrester
Synthetic Muso-Regurgative Composition

Tuesday, January 10, 2012

Cycles

There are cycles everywhere you look. From sunrise to sunset, as you wake and sleep, cycles inexorably continue. From the clock in your computer, to the motor in your car (or the gears in your bicycle!), cycles are an important part of life.

We, humans, also have our own cycles. Our energy levels ebb and flow, our tastes change, only rarely do we find a food that we'd happily eat for every meal of the rest of our lives. And we have a three stage cycle of play, rest and work.

Zooming out a little, humanity has its own cycles too. "What we learn from history, is that we learn nothing from history." - George Bernard Shaw.We make the same mistakes our ancestors made, and if I were a betting man who would live to see the day, I suspect our descendants millennia from now will making the same mistakes we make today.

Monday, January 9, 2012

Just Ask, Just Tell

How many times have you not asked a question you needed the answer to? How many times have you not said your piece to someone who needed to hear it?

Far from "Don't ask, don't tell", I suggest "Just ask, just tell". Do not worry yourself with the repercussions of the truth. Instead, concentrate on the truth you possess. Don't fill your truth with emotional baggage. Instead, speak your truth with open ears and an open mind. It will save everybody time and anxiety. Moreover, your stature will improve, by being able to say what everybody is, or should be, thinking.

Do not think your truth is absolute. Instead, listen earnestly for the truth of others. Conversation is the foundation of a healthy relationship.

Sunday, January 8, 2012

The Trap of the New and Non-existent

alternative title: Buy vs Build vs Improve

The buy-vs-build argument is well-known by any business which has ever needed some software to fulfill a requirement.
Typically it boils down to something like:
  • Buying is cheaper, but gets you only 80% of what you wanted. Customising it might be able to get you closer, and support is available at a price.
  • Building will get you to 100% of what you wanted, but is a lot more expensive. However, you can save on support (by handling it in-house).
There are two other options missing here. The first is to decide you don't need the software - arguably the best option, if available. Assuming you do have a legitimate need, the other option is to improve what you already have.

Ask yourself, how is the problem being solved currently? If it's really a problem that needs solving, chances are it has already been solved - albeit with bits of string and a big roll of duct tape.


Perhaps eliminating the duct tape and just using some glue and nails would be better. For example, writing a script to do a download, some munging, and an upload to another service. Maybe you don't need to build the two services into one, but just an intermediate application.

New and shiny things are attractive, and don't carry the emotional baggage of the past. Look past your emotions, and see if there's something there valuable enough to keep.

Saturday, January 7, 2012

Generalist vs Specialist

Jack of all trades, master of none
I've always wanted to know everything - to be omniscient. This is a little unrealistic, so I usually state this goal as simply being a generalist. Often, when something feels "wrong" in my life, and I just can't put my finger on it, I'll later come to realise that it was because I had focussed too much on one thing, to the detriment of everything else. Through my study at UNSW, I completed several general education courses, and tried to do so as broadly as possible. That was good, but didn't satisfy forever.

One of the reasons I'm in the software space, is because of the wide variety of things to do. There's a whole spectrum from kernel hacking, to pixel layouts. Apart from that, there's also the wide variety of ways to do things. This is embodied in the TIMTOWTDI principle of Perl, and Ruby. But I love even languages that emphasise one way and one way only - Python comes to mind here. And don't even get me started on LISPs, functional programming, constraint programming or logic programming!

I'm far from an expert in all of these, but I feel that each has helped me with the other. Knowledge is like a bunch of cables in a drawer. Add a cable, and it gets entwined with the others. The more cables you have, the faster and more entwined the later cables get.

But alas for the generalist, modern society, is only possible because of specialisation. Think, in your daily life, about objects you interact with. How many of them could you build? How long would it take you to learn how to build all of them - more than a lifetime! We even say "Don't reinvent the wheel" as a warning to those who would try.

I finish with this quote, however, from one of pop culture's most famous generalists.
Jack of all trades, master of none - the finish of that phrase is - though often better than a master of one. - Adam Savage
http://video.google.com/videoplay?docid=1515761638951440862 - @35:55

Friday, January 6, 2012

Making Things Sticky

Self-improvement is one of those things that some people appear to be innately good at, while others struggle with the basics of better behaviour. I tend to think of myself as falling into the latter camp. I'll start out with the best of intentions, but the changes don't stick - like any good New Year's resolutions. I've tried a bunch of things to try and trick myself out of it, and while I'm not perfect yet (nor will I ever be!), I do think I've improved at improving myself.

Here's a quick list of tips that have helped me:
  • Start from the moment you wake up - That moment when you wake up and nothing is distracting you nor interrupting you is precious, use it wisely.
  • Plan your morning before you fall asleep -
  • Make sure it's a change you want to make - If you don't want it, you won't get it.
  • Do it every day - When you start doing things every "couple of days" it's easier to lie to yourself saying "3 days is every couple of days", then 3 becomes 4, 4 becomes 5... Then you realise you haven't done it in months!
  • Believe it's possible - Some things happen whether we believe they can or not. But things are far more likely to happen when we believe.
  • Start small - How do you eat an elephant? Starting with the soft underbelly, one small bite at a time.
  • Measure your progress - If you don't know what progress means in the context of your goal, start breaking it down into smaller pieces.
  • Enjoy your progress - Pay attention, be persistent, and you'll start to notice changes in yourself. Enjoy it, you're getting closer to your ideal you!
Let me know if you have any tips of your own!

Thursday, January 5, 2012

2012 Resolutions

In increasing order of likelihood.
i.e. forall (x,y) p(x) > p(y) where x < y
  1. Move out
  2. Buy a new laptop
  3. Buy a car
  4. Build an android app
  5. Contribute in a significant way to an open-source project.  (Currently thinking CubicVR.js)
    • At least 5 bugfixes
    • At least 1 feature or improvement
  6. Appreciate [my] life
  7. Finish reading all books left partially read from 2011.
    1. Debunking Economics 2
    2. The Lean Startup
    3. Founders At Work
    4. The Prince
  8. Increase pre-tax income by 40%
  9. Learn Clojure - enough to use it in preference to Java for small tasks
    • Get through the Wizard Book  in clojure
    • specifically want to learn lein and ring "well"
  10. Develop a web-based version of Minsky.
  11. Do 5 pullups (in a row)
  12. Sleep 10% more

Wednesday, January 4, 2012

Taste vs Skill

All creatives start from small beginnings, and being fans of their particular craft. A writer reads before they write, a director watches movies before they direct, a coder reads (code) before they write (code).

At first, you have no preferences - to one who can't read, how could they choose one book over another (besides its cover, text:picture ratio, size, ... just talking about text here)? Soon enough, they start being able to understand individual works on their own. Later on, they'll develop a vocabulary for talking about works. It is about this time that preferences start to be made. Now, we get to the fun part - critiquing works. You may start to discern between works and have particular "justifications" for your reasoning - the contrast is too low, not enough time spent on character development, thoughts not following a logical order.

At this point, you can develop no more, and be a reasonable critic. But to be a good creative, we must go one step further - recognising what a better version of the work would be, and making that better version.

In summary:
  1. You have no preferences.
  2. You develop preferences.
  3. You develop justifications for those preferences.
  4. (maybe) You are able to improve your work to better match your preferences.

Thought path: Listening to one of the Back to Work (podcast) episodes -> searching for "skill vs taste" -> Model Mayhem -> Ira Glass on Storytelling (part 3 of 4)

Tuesday, January 3, 2012

My 2011 New Year's Resolutions Revisited

It's always fun to look back in time, to what you were thinking a year ago. Sometimes you'll be embarrassed, shocked, or horrified. But you'll always learn something about yourself that you never knew in that moment.

Here's my 2011 New Year's resolutions - titled TODO 2011
  1. finish my stupid WiimoteAudioPlayer - done!
  2. track money better (TODO: solidify this) - failed (being specific would've been helpful)
  3. make 20% more money - failed
  4. increase e.fund by 100% (by time) - done
  5. get through the wizard book - failed (a dismal chapter 1.2)
    • learn clojure - failed - I can read more clojure than before, but couldn't use clojure day-to-day
  6. sleep 8% more - failed. I didn't track this, but I think I slept less.
  7. lose 10% body mass - failed. I gained
  8. read 40% more books - I think this was a success, but I didn't count either 2010's or 2011's readings, so won't know for sure.
  9. move in with g/f - failed
  10. make 2012 todo list - failed
Summing up:

  • Two successes
  • One half-success
  • Eight failures
That means I've made progress! I might have a crack at making a more considered 2012 list in the next week or so.

Monday, January 2, 2012

Uncle Bob's Architectural Advice

Some months ago, Bob Martin tweeted "If the first thing you type, when writing a ruby app, is: 'rails', you've already lost the architecture game." He didn't mean that we should all be using Sinatra or Express or Play. No, what he meant was that our applications should exist other than as webapps.

He recently gave a talk at Ruby Midwest 2011 about architecture in Rails which I recommend all Railsists watch.

Taking cues from Ivar Jacobsen's Object-Oriented Software Engineering, Martin explains how to design an application's core that "screams" about the domain it is involved with. We should have Interactors (Jacobsen's Controllers rebranded to avoid nameclashes) and ResponseModels and ViewModels and Presenters and Entities which are POROs (Plain Old Ruby Objects) and not ActiveRecord-based.

Martin contends that the database is a detail, and the web is a detail. We don't want these to define our application's architecture. What should define our architecture is our use cases (user stories that have been elaborated to sufficient detail - with acceptance tests).

An insight (for me at least) was his way of explaining architecture - the art of drawing lines with the interesting rule that once you have drawn the lines all the dependencies that cross that line go in the same direction. Following this, we can extract our code into a library (gem, jar, egg, dll, ...) and test our library. Cucumber isn't slow when it isn't waiting on a browser and HTML response rendering. We must integration test these as well, but don't need to test every case through a GUI interface.

This all sounds good - simpler tests, faster tests, more decoupling... but at what cost? Is it more code? Yes, but you won't be sad when waiting for your tests to run! Being able to easily add another delivery mechanism (thick client, perhaps) on top of your application's core is nice - but how often does that actually occur? It hasn't for me.

So currently it boils down to test performance vs coding time. And we all already have our own ideas about that!


Some choice moments from the talk:
Audience: Where can we find the gem that does this for us?
Uncle Bob: It's between your ears, son.

Audience:Are there any examples of a rails app or a software application that also uses rails in the way that you're talking about?
Uncle Bob: I haven't seen it yet.
Who's got one? I do have one, but i can't show it to you. The rails code that I've seen without exception does not follow this pattern.

Uncle Bob: I know what you're thinking. Yeah, but I gotta get stuff done @ 38:40

Other Links:

Clean Code Episode 7
blogpost on 8thlight's blog

Sunday, January 1, 2012

Happy New Year

"Start out how you want to finish"

This year I start out by opting for paperless statements for an account that I should've done when I first opened the account. And also blogging.  I intend to write something - anything - each day here for the month of January. If I don't, I'll donate money to a charity I hate or something... if I can find one...