Two Guys Arguing

2011.tech_resolutions.pop(5.questions)

Posted in questions by youngnh on 01.06.11
  1. What are you currently hacking on?

    Just before Christmas, I put together a small LL(1) parser-generator in Clojure. LL(1) has the distinction of being one of the simplest classes of grammars to parse, and a great number of textbooks on the subject will tell you that it’s often quicker to write a parser by hand for a LL(1) grammar than to go to the trouble of using a parser-generator. I think my code removes most of those objections. However, it currently suffers from 4 problems that I vowed I would remedy before it saw the light of day: its very slow for only marginally deep parse trees, it has no tests, no documentation, and the error messages it spews forth are currently only meaningful to myself. None of these problems are sexy, nor could the process of solving them be construed as “hacking”, so my motivation to finish the project has plummeted.

  2. What do you want to hack on more in 2011?

    I have no shortage of ideas that could be expressed via computational algorithms, but recently I’ve had a harder and harder time convincing myself that any of them are significant in any way other than the challenge in realizing them. This year I’d like to stay away from the “because it’s there” projects. I’d like to hack on things that:

    • someone would pay money for: a fart app, for example, or possibly one that does facial recognition so that if you think you’ve seen somebody famous on the street or simply can’t remember the name of the person you’re currently talking to, you can pull out your phone and shove its tiny camera in their face
    • something that people I’ve never met before would find useful: most of my keystrokes are deleted, a select few are saved to files, fewer still find themselves a part of a working project, and of those projects that people other than myself get their hands on, their purpose could generously be described as niche. I write software largely for the compulsive pleasure of seeing an ephemeral thought produce flashing pixels on a screen, but I’d like to try writing something that might be useful to others at the same time.
    • change an old way of doing things: Starbucks changed the way you order drinks, parenting at dinner is a contentious process, and the airline industry has been sticking with a sub-optimal solution to one of the hardest problems in all of computation but that doesn’t mean a few guys didn’t throw a bunch of servers at the problem and give it a go of their own (and crashed and burned). These are hacks in the best sense of the word.
    • change how non-programmers interact with computers: it pains me to watch people use software. You might already be rolling your eyes in preparation for a rant from a programmer about non-technical people’s poor computer skills, but that’s not it. What I see when my mother-in-law or grandfather use their computers is the incredibly resourceful, thoughtful and clever way in which they approach an inanimate, ineffable and often arbitrary hunk of plastic and silicon, and manage to make it do unbelievably complex things. I’ve read the manuals, I spent four years in college and all of my professional career learning how these things are put together and I can barely get my wireless printer to work. The only difference between us is that I have the ability to change the machine to match their understanding of it. Helping non-programmers is my peace corps, my doctors without borders.
  3. What do you want to stop hacking on in 2011?

    I think what I wrote above covered most of what I’d like to hack on, and being a very good dichotomist, I’d like to stop hacking on anything that isn’t a Big Idea. This is not to confuse Big Ideas with small hacks. Big projects never get finished. Short sprints of interesting and valuable concepts are strongly encouraged, not the least for morale. Anything that someone might ask “Why that?” of, and that I would respond with “well, because it just seemed neat…” should be viewed with strong suspicion in 2011.

  4. Big idea that just needs a free weekend to come to life?

    As you wrote big idea with a little “i”, and I’ve just finished pontificating on big “I” ideas, I’m going to say a Java compiler that does type inference. I haven’t done my homework and checked if something like this already exists, so if it does, please point me in its direction. Aside from the massive amount of typing (lol) it’d save, why should Scala get to have all the fun? A slightly more powerful compiler might lead to a better, if sloppier, place for the Java masses.

  5. How can we get more arguing on this blog?

    We could go find that youtube video of two kids having an argument and put it up here, thereby reclaiming the rest of the hits from Google searches for “two guys arguing”.

    If you’d like something software-related, pick the “social sciences” of programming, like methodologies, or productivity enhancements or what editor to use, as they often don’t have verifiable outcomes and thus can generate argument indefinitely.

    Personally, I’ve found that being wrong about a thing leads to more comments and discussion than solving that thing competently. On a positive note, I’d like to think that it has been our extreme competence in what we do that has kept this blog from rocketing us into the stratosphere of computer scientists around the world.

A Solution from Purgatory (for the Matrix from Hell)

Posted in challenge, math, questions by benjaminplee on 01.02.11

This post attempts to recount some of my thought process which eventually (more than a year later) lead to the Matrix from Hell puzzle I posted about a few days ago.  If you don’t want to know my answer, don’t read the rest of this post.  My final solution is at the bottom.

You have been warned.

~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~

Below is a list of my general thought process and the main ideas/revelations/halucinations that I know helped me to my solution.  An annotated matrix is at the bottom with some of the ideas highlighted in different colors.

  • Should indices start at 0 or 1?
  • Values along either axis count up by 1 in both directions when the other =0
  • Values are duplicated over the f(x)=y axis –> Order of indices given to function is inmaterial since they can be swapped
    [The RED 5 can be seen duplicated over the diagonal]
  • Calculation of max/min index is O(1) so stop worry about it and “forget” the bottom half of the matrix (assume X>= Y)
  • Values generally increase as they go right/down but not always
  • f(x,x)=0, f(x,0)=x
  • Values are symmetrical perpendicular to f(x)=y IFF the bounding square in question is a power of 2
  • “Quad” patterns can be seen repeating for every power of 2.  In each “Quad” the top left quadrant is the same as the bottom right and the top right is the same as the bottom left.
    [Each “Quad” of the example matrix is outlined in BLUE with the quadrants in LIGHT BLUE. PINK shows the repetition]
  • power of 2 repeating nature of the values leads to thinking of binary trees
  • binary trees leads to thinking about a possible solution which could run in O(log2 n) time:
    • In a nut shell, for a given (X,Y), algorithm would find smallest boudning power of 2 including X and would walk back “Quad”s by each successivly smaller power of 2 “Quad” until the last one is met.  For each “Quad” determine which quadrant the value lives in and remap to root values.
    • Debate if this would really work for large numbers and if it could be reduced to constant time function by math that I have forgotton from college/HS
    • Dismiss b/c I can’t remember a way and base idea is > O(1)
  • Binary trace back algorithm idea makes me realize that it can be also looked at as the “binary” representation of a number (e.g. 01011011010) where each 1 represents a “Quad” where the value was in the upper right or bottom left and vica-verca.
    [Following the matrix value at (5,6) can be seen ORANGE.  The value 3 is in the bottom right  of the 1st “Quad”, then BL, & TR. {BR BL TR} => {101} => {3}]
  • Remembered that f(x,y)=0 IFF x==y …. which means that difference between X and Y is important to value of f()
  • Eureka!
    • F(X, Y) = X xor Y
    • solution typed above in white on white to protect the innocent. highlight to view.

sample matrix with some of my thought process drawn out

That is it.  I never said it was pretty or made any sense.

Tagged with: , , , ,

2011.tech_resolutions.push(5.questions)

Posted in questions by benjaminplee on 01.01.11

In the spirit of the first posts to this blog and the new year I poste the following 5 questions to Mr Young…

  1. What are you currently hacking on?

  2. What do you want to hack on more in 2011?

  3. What do you want to stop hacking on in 2011?

  4. Big idea that just needs a free weekend to come to life?

  5. How can we get more arguing on this blog?

Tagged with: ,

C# Meta-Programming And Extension Methods Question

Posted in .net, functional programming, questions by benjaminplee on 12.30.10

First, it should be noted that my ASP.Net MVC-foo is yet great and I know this.  If you know a better way to do this, please take the time to explain how you are superior.  If you don’t, how will we ever know?

Working with ASP.Net MVC 2 client-side form validation this past week, I ran into two unfortunate (IMHO) facts which kept tripping me up:

  1. Html.ClientValidationEnabled() must be called as a scriptlet BEFORE the form is created
  2. Html.ValidateFor or Html.ValidationMessageFor must be called for EACH property of the model you want validated.

*** This StackOverflow answer includes a couple other important & useful things to note

These two issues (and many more) bother me about ASP.Net MVC 2 client-side validation but #2 in particular was really ticking me off.  I like that I can conditionally turn validation on/off on a field by field basis … but why make me enumerate all validation-needed model fields twice in my view!?  Especially in my case where I want validation turned on for ALL model object fields that have DataAnnotation Validations defined for.  Obviously the fields are going to be enumerated in the view once; how else are the text boxes and drop downs going to be created, but why make me list out each field AGAIN just to turn on validation?

All of this amounts to one WET solution. Am I missing something?

The best solution I have seen, and the one I am about to start implementing, is this one by Rick Anderson over at MSDN found via this related forum post.  The idea is to create additional Html helper extension methods which will combine the creation of the HTML form element with turning on and configuring validation.  This solution has the benefit of making me enumerate the model fields being used only ONCE in my view code and reads cleaner.

The only problem is that I have to walk through our application, find anywhere that is using a built in HtmlHelper extension method to build an HTML form element (e.g. input tag), build a new validating wrapper extension method that matches the signature of the original, and then replace the original code with the new extension method.  This can be done, but is time consuming and error prone.  And I am lazy.

The real issue …

I want to … create additional HtmlHelper extension methods based on all existing ones that produce form elements and take in a Linq expression to find the model property that first pass that expression to helper.ValidateFor() and then return the original extension method’s valued.

Is there any meta-programming feature or technique in C# that will allow me to concisely do that?

e.g.

Since Html.TextBoxFor(user => user.FirstName) is used in our app, as it stands I will am going to create a custom extension method similar to:

public static class ValidatingFormElementsExtension
{
  public static MvcHtmlString ValidatedTextBoxFor<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression)
  {
    helper.ValidateFor(expression);
    return helper.TextBoxFor(expression);
  }

  // and so on for EACH one we use

}

Anyone have any ideas?  Am I completely off base with this? Is there a better way?

~~~~~~~~~~

<mini-related-rant>

A few more quick cracks at ASP.Net MVC  that I need to get off my chest

  • Why are so many things done in scriptlets!?  I feel like I am back in the vanilla JSP days of yesteryear.
  • They are Annotations in Java and Attributes in C# …. so why are the data validation attributes defined in System.ComponentModel.DataAnnotations?
  • I get that HTML checkbox form input fields have TRUE/FALSE values passed back when the form is submitted, and that doesn’t map perfectly to how other fields are handled by the Required attribute …. but why was NOTHING included to do this?  Having to use a RegularExpression validator for [Tt]rue is clumsy no?

</mini-related-rant>

The revenge of the 5 questions

Posted in questions by benjaminplee on 02.04.10

Ever since CodeMash my brain has been a buzz of activity, but I haven’t had time to really dive into anything too substantial.  I have a number of posts/ideas in the works but nothing to show for it.  But, if large corporate cultures have tought us nothing, it is to write status reports about work are often more important than the work itself.

In lieu of a “new year” post that I never ended up writing, I am going to revisit one of this blog’s first posts: 5 questions. To revisit the questions:

  1. What are you currently hacking on?
  2. What are you currently getting better at?
  3. What do you do when your computer is asleep?
  4. Describe that ‘big fish’ project that’s been stewing in your brain.
  5. What are you gonna post about this coming week?

1.) Clojure, JSON, and misc little coding challenges.  Instead of writing a list of goals for the year I am taking a bit more “agile” approach and just spent 2 minutes writing down anything and everything I could think of that I “wanted to know more about”.  JSON and functional programming bubbled up to the top of a quick random sorting, so the fact that my current side project w/ Mr. Zac Duncan involves both is very convenient.

2.) TDD.  Nate’s recent TDD Rock Paper Scissors challenge and very interesting talks with the guys at CodeMash left me questioning why I work the way I do, how I might do things better, and how I can effectively communicate that to another developer.  I haven’t gotten very far with it yet, but it is definitely something I am putting effort into now.  I am also currently reading Andy Hunt’s Pragmatic Thinking and Learning: Refactor Your Wetware which looks very interesting.

3.) Relaxing with the wife, and trying to get back in shape (same as last time).  Hopefully joining up with the new year’s company weight loss competition will give me that extra bit of motivation.

4.) No big fishes at the moment, just lots of little ones.  And damn are they fast.  Along with Zac’s and my side project I have mainly been pushing myself to write more code.  Any code.  And get feedback on it.  I would love to take up one of my past personally projects and see it through to fruition but for now I am content if I can get some constructive feedback on whatever I am doing.

5.) JSON and my first impressions of trying to write a real app in a functional programming language.  Along with the “want to know more about ___” items I wrote down I want to get into the habit of posting on each topic on aprox 1 week intervals, putting down whatever I have learned as best I can.

Hopefully this post will convince Jeff to post another response ;-)  He is always up to something interesting.

Tagged with:

Agile Underwear Gnomes

Posted in questions, software development by benjaminplee on 11.05.09

Agile is all about the profit

While considering my teammate Amos’ recent blog post where he debates what Agile really is my mind was drawn to a statement our current client made during one of our early project kickoff meeting.  While discussion why his clients have been successful following his plans he made the statement:

You will never go broke, making a profit

At the time this seemed like a good joke and litte more.  However, the more I thought about it, the more it rang true.  What does this have to do with Agile software development?  While questioning what is or is-not Agile and what his definition of Agile might be missing, he says:

… The one thing that I didn’t mention above. … Delivering a useable project at any point in development. That is it. That is what I’m missing. This has got to be the hardest part of agile. …

I think the key here is the value of a shipped product is ALWAYS greater than that of one sitting on the shelf.  Value is the key.  To me, the agile mindshift is one of always producing value for the customer, for the team, or for yourself.

Produce value for the client:

  • by adapting to their ever changing business needs with understanding, speed, and energy
  • by aligning all user stories with tangible user value and goals
  • by planning and documenting in inverse proportion to the item’s priority and deadline
    • worry about what is in front of you first and put off decisions to the last responsible moment (stolen and probably butchered from a WWBBD: What Would Brian Button Do)
  • by working on the highest bang-for-the-buck stories first, top down, and delivering working code as often as possible

Produce value for the team:

  • by conducting frequent retrospectives where the team can think about how they are doing and how they can be better
  • by realizing that many/most of a team’s problems are really “people” issues masquerading as technical ones
  • by actively paying down technical debt
  • by reducing knowledge silos and keeping the team only full of valuable members and all members valuable

Produce value for your self:

  • by staying motivated and positive
  • by keeping the thirst for knowledge alive and always learning from any experience
  • by taking greater pride in the success of the team over the success of an individual ego
  • by working to be a great communicator: to team members, to the client, to your code (Tests)

I didn’t mean for this post to turn into a list of things to do … but often our practices are the best way we can take abstract principles and make them tangible.  So long as the practices don’t become to focal point, they are a useful way to monitor, enforce and discuss the important concepts.

Profit really is the key.  Our client helped his clients by making sure they were profitable.  Sure, maybe they could have been more profitable, if they had taken bigger risks and bet the farm for instance, but year after year a steady profit is inspiring.

Which brings me to the Underwear Gnomes of South Park.  Their business plan was a simple one.

  1. Collect Underpants
  2. Profit

By focussing on providing value (profit) at each point along the way, maybe step 2 wouldn’t be such a mystery.  Granted, gnomes are pretty agile to begin with.  Fast too.

Tagged with: ,

Leading by Bleeding – my tech map

Posted in questions by benjaminplee on 05.26.09

Below is my take on a tech map (see previous post).  I had a hard time knowing where to draw the line (languages? librarys? tools?  processes and ideas?) and how to sort them.  I decided on three main areas.  “Bleeding Edge” are things that are popping up in Google Reader lately and/or things that seem to be gathering some traction are sound interesting.  “Working” are the main things going on day to day.  “On the way out’ aren’t things I think are going to be gone in a year or two , but things that seem to be less new and interesting news surrounding them.  Right or wrong its my take and I am a bit sad by the lack of knowledge in the bleeding edge area.  I am going to have to work on that.

Ben's Tech Map

Ben's Tech Map

Hopefully the words are legible in the image.  What do you think?

Leading by Bleeding

Posted in questions by benjaminplee on 05.25.09

Tonight Chad Fowler posted on twitter an interesting comment and link to a blog post by David Copeland and his take on his knowledge of technologies; from the bleeding edge to those “on the way out”.  His post was inspired by an exercise in Chad’s new book, The Passionate Programmer, which is on my list of books to read in the very near future.

My initial reaction was three fold:

  • Annoyance that I couldn’t mark more of them in yellor or green.
  • Happiness that I had at least heard of or had some very basic knowledge in almost all of them.
  • Curiosity on how he had picked his list, why he had not included some others, and why he had placed some where he had.

I intend to fill out a similar personal survey tomorrow which I will post … but until then I leave this question to anyone who reads this:  What would yours look like, and what things would you remove/add/move if you were doing it?

Obviously any such list could contain any number of items depending on your background and scope (what do we include?  languages?  ideas?  patterns?) but a few that I thought were missing off of the top of my head were:

  • Silverlight
  • Adobe AIR / Flash
  • JavaFX
  • RCP applications
  • SOA
  • Web services
  • Haskel
  • Ruby
  • Functional programming
  • Agile development practices (Lean/XP/Scrum)
  • Hibernate or other ORMs (e.g. ActiveRecord, iBatis, etc)
  • UAT libraries / tools (e.g. Selenium, WebDriver, WebRat, Wati[R|J|N])

It really is hard to know where to stop.  Quickly it feels like a corporate skills inventory list that eveyone updates when they are hired and then never again.  We will see what the guys at work can come up with tomorrow and then see what my personal sheet looks like.  If you do one of your own, can think of something thats missing or just have a thought … please leave a comment.

At the very least, it was a very thought provoking post.

Five Questions – a Response

Posted in questions by benjaminplee on 03.01.09

This could have been a comment on the previous post, but I figured my first response should be in post form.

My responses to Nate’s 5 questions:

1.  Right now I am trying to fix up a few last things on my goofy Book Worm cheating application – booklouse – to finish version 1.0.  I have a ton more ideas for it and still want to sit down with it and see how high I can go … but for right now I want to finish up the core functionality and move on to some other stuff for a while.  Also, I have several additions/ideas for Selenium RC and/or Grid which I would love to sit down and code through.  I think they could solve some real problems I have had writing and running tests.

2.  I too am currently learning Haskell, but am not nearly as far along as you are.  My goal for next week is to work through a few more chapters in the Real World Haskell book and try my hand at a few small programs.  Along with Haskell I will be playing around with integrating Selenium tests written in TestNG into a Maven based project built and run via Continuum.  I have some experience with all of those things, but never all at the same time.  Should be interesting.

3.  When not at my computer, I am usually spending my time with my wife watching tv, enjoying a nice dinner out or letter her beat me at board game. ;-)  I am also trying to break into hard mode in Rock Band 2 still along with trying to get back into shape.  Oh, and working on my house.  My list of small and large projects grows exponentially faster than I have time to do them. Ahh, the joys of home ownership.

4.  Ever since my undergraduate research days in college and a course I took in Genetic Algorithms / Evolutionary Computation I have yearned to do a larger project where my software learned to do things.  My most obvious outlet to date for this is my mediocre attempts are writing software to play games for me better than I can play them myself.  I also have interest in working with image processing, data mashups, and automation.

5.  Hopefully a handful of smaller posts relaying my thoughts on Haskell and any progress/problems I come across as I try to integrate the above technologies into something usable for my client.

Five Questions

Posted in questions by youngnh on 02.28.09

For my co-blogger:

  1. What are you currently hacking on?
  2. What are you currently getting better at?
  3. What do you do when your computer is asleep?
  4. Describe that ‘big fish’ project that’s been stewing in your brain.
  5. What are you gonna post about this coming week?

I expect I’ll get 5 back, so as a gesture of good faith, I’ll start.

1. I’m currently working on figuring out how Google generates shadow images from marker images for Google Maps.  There’s a website out there already that will generate shadows from images for you, but they’re not pixel-perfect enough for my picky brain.

2. I’m currently learning Haskell.  I’ve been at it for about 2 months.  I can safely say that I’ve achieved a high degree of second-order incompetance in the language.  The fact that I’ve achieved minor successes at producing working programs is doing nothing to allay this fact.

3. When I’m not writing code, I’m playing Halo or running.  The summer 5K circuit is starting up and running is a favorite sport of mine because you need only shoes to get started, and even those are optional.

4. Big, nebulous project for me is making something that my family and technically disinclined friends would actually find useful.  They all have computers and none of them is very impressed with the machines themselves or by what I do with them, which is baffling, I know.  But, if I could give these people a tiny box with no switches or manuals and improve their lives without altering their day-to-day routines, that’d be a win for me.

5. This coming week, I’m gonna post a few more of these questions in the order they occur to me and something related to Haskell and my experiences with it so far.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: