< Return to Video

Ruby Conf 2013 - Bad Ruby code doesn't exist

  • 0:17 - 0:20
    MATT AIMONETTI: All right. So I am Matt Aimonetti.
  • 0:20 - 0:22
    I'm the cofounder of a startup called Splice.
    Splice
  • 0:22 - 0:25
    dot com. And what we do is we work
  • 0:25 - 0:26
    in the music space to change the world of
  • 0:26 - 0:31
    music, and we change the creation process
    by bringing
  • 0:31 - 0:33
    a lot of the programming tools and torture
    into
  • 0:33 - 0:34
    the world of music. If you want to know
  • 0:34 - 0:38
    more about it, please come and see me. We're
  • 0:38 - 0:42
    actually hiring in the, in the nice Santa
    Monica
  • 0:42 - 0:44
    area in L.A..
  • 0:44 - 0:46
    I've been programming for many years, and
    during the
  • 0:46 - 0:50
    preparation of this talk, I realized I spent
    exactly
  • 0:50 - 0:57
    17,542 hours programming Ruby. I was at, at
    540
  • 0:57 - 0:58
    hours last night, but I wrote a bit of
  • 0:58 - 1:00
    code so I had to update the slides.
  • 1:00 - 1:06
    That's about 730 days, two years non-stop,
    and at
  • 1:06 - 1:09
    the end of all that time, I don't know
  • 1:09 - 1:12
    if I can write good or bad code, but
  • 1:12 - 1:14
    I've seen a lot of code. And I've seen
  • 1:14 - 1:15
    a lot of good code and a lot of
  • 1:15 - 1:18
    bad code. At least that's what I thought.
  • 1:18 - 1:21
    Now, you need to understand something about
    me, is
  • 1:21 - 1:23
    that when I look at a glass like this
  • 1:23 - 1:25
    one, I have a tendency to see the glass
  • 1:25 - 1:28
    half empty. And when I tell that to people,
  • 1:28 - 1:31
    they're like, Matt, you're such a pessimistic.
    And I
  • 1:31 - 1:34
    really strongly disagree with them, because
    I see potential.
  • 1:34 - 1:37
    This glass is half empty, but it should be
  • 1:37 - 1:40
    full. So I see the potential of the glass,
  • 1:40 - 1:41
    and I want to fill it up. So I
  • 1:41 - 1:44
    don't believe that I'm a pessimistic. I'm
    an optimistic
  • 1:44 - 1:47
    and I see opportunities and potential in things.
  • 1:47 - 1:49
    But I also believe that I'm not the only
  • 1:49 - 1:52
    one I think the wide version, like, I don't
  • 1:52 - 1:54
    have truth. And it's hard for me to understand
  • 1:54 - 1:57
    how people think about projects and how they
    think
  • 1:57 - 1:59
    about code in general.
  • 1:59 - 2:02
    So, I started looking online and I asked people
  • 2:02 - 2:04
    on Twitter. Have you ever seen bad code? Who
  • 2:04 - 2:07
    has ever seen bad code?
  • 2:07 - 2:12
    Wow. That's not that many people. I'm surprised.
    So
  • 2:12 - 2:15
    Avdi has this quote, it said that the worst
  • 2:15 - 2:18
    code I've ever seen were in Rails projects.
    So
  • 2:18 - 2:20
    it's good, because I've been writing Rails
    code for
  • 2:20 - 2:22
    a long time. So he probably saw a lot
  • 2:22 - 2:23
    of my code.
  • 2:23 - 2:26
    And I started doing a lot of research, and
  • 2:26 - 2:29
    I came to the conclusion that there's not
    such
  • 2:29 - 2:31
    thing as bad code. I think all of you
  • 2:31 - 2:34
    guys who were raising your hand were wrong.
    There
  • 2:34 - 2:36
    is no bad code. And I'm right and you're
  • 2:36 - 2:40
    wrong.
  • 2:40 - 2:43
    I think that's about it. Now, I will explain
  • 2:43 - 2:45
    why I think you're wrong and why there's no
  • 2:45 - 2:49
    bad code, but I remember going to school and
  • 2:49 - 2:52
    hating school. I loved to learn but I hated
  • 2:52 - 2:54
    going to school because I could never argue
    with
  • 2:54 - 2:54
    my teacher.
  • 2:54 - 2:57
    The teacher was coming, and was filling us,
    usually
  • 2:57 - 3:00
    it was a female and she was telling me,
  • 3:00 - 3:01
    well, this is what you need to believe. And
  • 3:01 - 3:03
    I'm like, well, why? It's like, no, I'm just
  • 3:03 - 3:05
    telling you this. It's the truth. And I hated
  • 3:05 - 3:06
    that.
  • 3:06 - 3:08
    And I really don't like when I sit at
  • 3:08 - 3:10
    a talk and I disagree with a person and
  • 3:10 - 3:13
    there's no discussion. So I will talk for
    only
  • 3:13 - 3:15
    about ten minutes, and then I will invite
    these
  • 3:15 - 3:18
    gentlemen to come on stage with me and tell
  • 3:18 - 3:20
    me how wrong I am.
  • 3:20 - 3:22
    And we will have a discussion. And the, the
  • 3:22 - 3:25
    goal of this discussion is not to say Mat
  • 3:25 - 3:28
    is right or Bryan, which is easy because we
  • 3:28 - 3:31
    have two Bryans, is, is wrong. The goal is
  • 3:31 - 3:34
    to have a discussion together to try to change
  • 3:34 - 3:35
    and to learn something.
  • 3:35 - 3:37
    When I have a discussion and argument with
    somebody,
  • 3:37 - 3:40
    I feel I win when they convince me I
  • 3:40 - 3:42
    was wrong and I learn something new. So hopefully
  • 3:42 - 3:45
    they will convince me, but I still believe
    there's
  • 3:45 - 3:47
    no such thing as bad code.
  • 3:47 - 3:50
    So what do I mean by that? Well, I
  • 3:50 - 3:54
    mean that, there is code that runs and code
  • 3:54 - 3:57
    that doesn't run. I believe that the community
    doesn't
  • 3:57 - 3:59
    get to set what the language is. I actually
  • 3:59 - 4:02
    very disagree with Ernie when, this morning,
    he was
  • 4:02 - 4:05
    saying, we, we as a community decide what
    Ruby
  • 4:05 - 4:05
    is.
  • 4:05 - 4:08
    No. I'm sorry. The language designer and the
    interpreter
  • 4:08 - 4:11
    will define what it is. You might not like
  • 4:11 - 4:13
    it. But it is what it is. So you
  • 4:13 - 4:15
    have code that runs and you have code that
  • 4:15 - 4:16
    doesn't run.
  • 4:16 - 4:18
    Then I went back into books, because I notice
  • 4:18 - 4:21
    people give good talk quote smart people,
    and that
  • 4:21 - 4:23
    make them smarter. So I found a quote on
  • 4:23 - 4:26
    the internet. It says, code is neither good
    or
  • 4:26 - 4:30
    evil, but only a place for good and evil.
  • 4:30 - 4:32
    And that sounded very, very good to me. Because,
  • 4:32 - 4:34
    I mean, we agree.
  • 4:34 - 4:38
    And, and, I really think that's a very important
  • 4:38 - 4:43
    point. Coding itself cannot be good or bad,
    right.
  • 4:43 - 4:44
    I mean, code is just code. What we do
  • 4:44 - 4:48
    with it is what's good or potentially bad.
    So
  • 4:48 - 4:49
    I talk to a linguist friend of mine and
  • 4:49 - 4:53
    I ask her, what is good and bad mean?
  • 4:53 - 4:55
    Like, what do we mean when we talk about
  • 4:55 - 4:57
    good and bad code? And what, when people refer
  • 4:57 - 5:00
    to good things and bad things?
  • 5:00 - 5:03
    And she explained to me that every language
    on
  • 5:03 - 5:07
    the planet had a concept, a word expressing
    good
  • 5:07 - 5:11
    and the concept of having something that has
    desirable
  • 5:11 - 5:16
    qualities. One or many. And bad means undesirable.
    Something
  • 5:16 - 5:18
    we do not want.
  • 5:18 - 5:21
    Now, what's very important to understand is
    that this
  • 5:21 - 5:24
    is a universal concept, but it's a concept
    that
  • 5:24 - 5:28
    has a sense of moral judgment. This is very,
  • 5:28 - 5:31
    very to understand that we're talking about
    moral. These
  • 5:31 - 5:34
    are not scientific terms. These are terms
    that belong
  • 5:34 - 5:38
    to religion, ethics, and philosophy.
  • 5:38 - 5:42
    A code in itself doesn't have a soul. It
  • 5:42 - 5:43
    cannot be good or it could be, it cannot
  • 5:43 - 5:46
    be bad. What you do with it and how
  • 5:46 - 5:49
    you write it is your own problem. So the
  • 5:49 - 5:51
    other issue with good and bad I have is
  • 5:51 - 5:55
    that, when you start talking about good and
    bad,
  • 5:55 - 5:58
    you start talking about blaming people. I'm
    right, you're
  • 5:58 - 6:02
    wrong. And you're not really moving things
    further than
  • 6:02 - 6:05
    just a discussion of just who's right, who's
    wrong.
  • 6:05 - 6:07
    So I think we're focusing on the wrong thing
  • 6:07 - 6:09
    when we talk about good and bad. So I
  • 6:09 - 6:11
    was talking to Marc Andre yesterday and I
    was
  • 6:11 - 6:14
    telling him about a talk, and he was like,
  • 6:14 - 6:16
    Matt, no, no, no, no, it's not right. Some
  • 6:16 - 6:19
    code is just better than other.
  • 6:19 - 6:22
    And I was thinking about that, and he's probably
  • 6:22 - 6:25
    right, in the sense that, it might be probably
  • 6:25 - 6:28
    true, but how do we define and evaluate the
  • 6:28 - 6:32
    quality of your work? Because, moralistic
    values such as
  • 6:32 - 6:35
    good and bad are not good enough to define
  • 6:35 - 6:37
    what is right and what is wrong.
  • 6:37 - 6:40
    It's a tough topic, and we need to think
  • 6:40 - 6:42
    about it. So, you know, I went back to
  • 6:42 - 6:45
    my room, and I started playing some music,
    and
  • 6:45 - 6:48
    all of the sudden this music connected with
    me.
  • 6:48 - 6:51
    The lyrics were so inspirational and they
    answer this
  • 6:51 - 6:54
    question, and they went something like that.
  • 6:54 - 6:55
    So tell me what you want, what you really,
  • 6:55 - 7:00
    really want. The Spice Girls figured it out
    before
  • 7:00 - 7:04
    me, which made me feel special. And, I think
  • 7:04 - 7:07
    the key is that it's not about how you
  • 7:07 - 7:09
    do it, but why you do it. And I
  • 7:09 - 7:12
    think that too often, we are focusing on how
  • 7:12 - 7:14
    we do it, and you do it wrong is
  • 7:14 - 7:16
    how you do it. It's not why you do
  • 7:16 - 7:17
    it.
  • 7:17 - 7:18
    So I started to try to come up with
  • 7:18 - 7:23
    rules, because you guys love rules. Everybody
    love rules,
  • 7:23 - 7:25
    right. So I was like, rules? But I could
  • 7:25 - 7:27
    not come up with them because I hate rules.
  • 7:27 - 7:30
    So instead, I define a process. And this is
  • 7:30 - 7:32
    a process I'm trying to apply, and this is
  • 7:32 - 7:35
    how I think we should work when we, or
  • 7:35 - 7:36
    we should try working when we look at a
  • 7:36 - 7:37
    project.
  • 7:37 - 7:40
    First, I need to assume that everyone cares
    about
  • 7:40 - 7:43
    the end result. So, we're not talking about
    everyone
  • 7:43 - 7:46
    agrees on how to write code. We all care
  • 7:46 - 7:48
    about the same end result. To do that, we
  • 7:48 - 7:51
    need to define the expected outcome. And I'm
    not
  • 7:51 - 7:52
    talking at the code level. I'm not saying
    this
  • 7:52 - 7:54
    is what the code should be doing.
  • 7:54 - 7:57
    I'm talking about, this is the behavior at
    a
  • 7:57 - 7:59
    higher level. This is the time line we have
  • 7:59 - 8:02
    to do this. And we need to talk about
  • 8:02 - 8:05
    why we do it. Once we define that, then
  • 8:05 - 8:07
    we evaluate all the available solutions we
    have to
  • 8:07 - 8:11
    do it, we pick one, we implement it. At
  • 8:11 - 8:14
    the end we re-evaluate the process, we re-evaluate
    the
  • 8:14 - 8:18
    end result, and then the very important step
    that
  • 8:18 - 8:21
    we usually forget is communication at that
    point.
  • 8:21 - 8:23
    I think it's very important to come back and
  • 8:23 - 8:25
    have a discussion about the process, project
    and the
  • 8:25 - 8:30
    process and agree that we met, we met the,
  • 8:30 - 8:34
    the expected outcome or not. And what's key
    with
  • 8:34 - 8:37
    this process and that it helps us understand
    that
  • 8:37 - 8:40
    we're not paid as developers to write 'good'
    code.
  • 8:40 - 8:43
    We are paid to deliver great products.
  • 8:43 - 8:44
    Now, I'm not saying that we should not be
  • 8:44 - 8:46
    writing 'good' code, even though I don't believe
    in
  • 8:46 - 8:50
    good code. What I'm saying is that, our job
  • 8:50 - 8:52
    is not to write code. Our job is really
  • 8:52 - 8:57
    to deliver an end product that has reason
    to
  • 8:57 - 8:59
    be.
  • 8:59 - 9:01
    And to do that, I think the only thing
  • 9:01 - 9:04
    I know how to do is trying to understand
  • 9:04 - 9:06
    the why. Why do we do things? And the
  • 9:06 - 9:08
    problem is that when you are just looking
    at
  • 9:08 - 9:10
    code, you don't always understand why. You
    might understand
  • 9:10 - 9:13
    why a method in Ruby works a certain way.
  • 9:13 - 9:16
    But you don't understand the business context
    behind it.
  • 9:16 - 9:18
    The time line behind it. The different players.
    The
  • 9:18 - 9:21
    risk factors you have. And I think this is
  • 9:21 - 9:23
    what we often miss, because we're focusing
    on the
  • 9:23 - 9:25
    code being good or bad. And this is not
  • 9:25 - 9:28
    what it's, what it's all about.
  • 9:28 - 9:31
    The other issue is that when you talk to
  • 9:31 - 9:34
    other people and you show them what you're
    doing,
  • 9:34 - 9:36
    they usually come back to you and then, you're
  • 9:36 - 9:41
    doing it wrong. And this is another reason
    why
  • 9:41 - 9:45
    I don't believe in bad code. Because if I
  • 9:45 - 9:46
    would believe in bad code, all the code in
  • 9:46 - 9:49
    the world is bad. Every time I write something,
  • 9:49 - 9:50
    there's somebody else that will come and tell
    me
  • 9:50 - 9:52
    you're doing it wrong. It's bad code.
  • 9:52 - 9:54
    And, I was scratching my head about that.
    I
  • 9:54 - 9:55
    was like, why do we do that all the
  • 9:55 - 9:59
    time? And, I'm guilty of that quite often.
    I've
  • 9:59 - 10:02
    been in seat to judge code. A lot. And
  • 10:02 - 10:05
    it, I think this is wrong. And I think
  • 10:05 - 10:07
    the reason we do that is because we love
  • 10:07 - 10:09
    to judge things.
  • 10:09 - 10:11
    We judge people who look different. We judge
    people
  • 10:11 - 10:14
    that act differently. We judge people who
    speak with
  • 10:14 - 10:19
    an accent. We judge people who think differently.
    And
  • 10:19 - 10:21
    that's what we do as human beings. That's
    just
  • 10:21 - 10:23
    a fact. It's very annoying, but that's what
    we
  • 10:23 - 10:24
    do.
  • 10:24 - 10:25
    And what is the best way to judge people?
  • 10:25 - 10:29
    Is to define rules. When you have rules, it's
  • 10:29 - 10:31
    very easy. If you agree with my rules, we're
  • 10:31 - 10:35
    right. If you disagree with my rules, you're
    wrong.
  • 10:35 - 10:37
    And usually people come up with rules of good
  • 10:37 - 10:40
    intentions. They want to help others.
  • 10:40 - 10:44
    Really quickly these rules become a weapon
    into arguments
  • 10:44 - 10:48
    that don't really help us build better products.
    And
  • 10:48 - 10:50
    we use them to tell them their wrong. Sandi
  • 10:50 - 10:52
    Matz rule that she never really wrote, by
    the
  • 10:52 - 10:55
    way, she just mentioned something in a pod
    cast,
  • 10:55 - 10:58
    and this rules were now applied everywhere.
    Classes can
  • 10:58 - 11:01
    be no longer than one hundred lines of code.
  • 11:01 - 11:03
    Methods can be no longer than five lines of
  • 11:03 - 11:03
    code.
  • 11:03 - 11:05
    A few days ago I wrote a method, it
  • 11:05 - 11:08
    was, I think, fifteen lines of code. Sandi
    sent
  • 11:08 - 11:12
    me an email. Like, Matt, what are you doing?
  • 11:12 - 11:13
    And I was like, well, I'm really sorry, I'm
  • 11:13 - 11:14
    tired. She's like, no, that's not an excuse.
  • 11:14 - 11:16
    And as I sent my response, I got an
  • 11:16 - 11:19
    email from Bryan Heimkamp from CodeClimate,
    he said dude,
  • 11:19 - 11:23
    you got a F! I'm like, come on. I
  • 11:23 - 11:25
    finish doing that, and then I got another
    email
  • 11:25 - 11:28
    from Bryan Liles, this time, like, dude, where
    are
  • 11:28 - 11:30
    your tests? You should write tests first!
    You cannot
  • 11:30 - 11:33
    write good code.
  • 11:33 - 11:35
    So you hear things like that all the time.
  • 11:35 - 11:38
    And especially if you work with a team, you'd
  • 11:38 - 11:40
    hear people arguing, and they will be telling
    you,
  • 11:40 - 11:42
    no, no, no, dude, you don't know what you're
  • 11:42 - 11:44
    doing. You didn't get an A on Code Climate.
  • 11:44 - 11:45
    I got an A.
  • 11:45 - 11:49
    So I'm a better programmer than you. Yeah,
    we
  • 11:49 - 11:52
    should talk about that, Bryan. I'm sure there's
    ways
  • 11:52 - 11:54
    for you to fix my code so I get
  • 11:54 - 11:57
    As, right. So the point of that is that
  • 11:57 - 12:00
    you have different perspective on things.
  • 12:00 - 12:04
    And rules aren't what make you, your product,
    the
  • 12:04 - 12:07
    end result valuable. Rules are usually a way
    to
  • 12:07 - 12:10
    help you. But you need to focus on the
  • 12:10 - 12:13
    deliverables. Rules are indicators, they're
    not a goal in
  • 12:13 - 12:14
    themselves.
  • 12:14 - 12:17
    Writing good code should not be your goal.
    Delivering
  • 12:17 - 12:19
    good products should be the goal. Now usually
    to
  • 12:19 - 12:22
    deliver good products, you want to, your code
    to
  • 12:22 - 12:24
    be easy to maintain, you want to perform well,
  • 12:24 - 12:26
    and you want to do many things.
  • 12:26 - 12:29
    But all that depends on the expectations.
    If you
  • 12:29 - 12:32
    need to deliver code in five hours, you might
  • 12:32 - 12:34
    write it differently than if you need to deliver
  • 12:34 - 12:36
    it in two weeks. If you're gonna have five
  • 12:36 - 12:38
    users instead of a hundred users, you will
    write
  • 12:38 - 12:41
    code differently.
  • 12:41 - 12:42
    One lesson that I think is also very important
  • 12:42 - 12:46
    is to learn how and when to write rules.
  • 12:46 - 12:48
    But I'm just surprised by how much the Ruby
  • 12:48 - 12:52
    community loves rules. We're all about rules
    all the
  • 12:52 - 12:54
    time. And I think, I actually blame a little
  • 12:54 - 12:58
    bit Matz, because Matz didn't give us rules.
  • 12:58 - 13:00
    Matz was like, you don't need rules. You be
  • 13:00 - 13:05
    open about that. And we have this feeling
    that
  • 13:05 - 13:07
    we need rules. So even though he didn't give
  • 13:07 - 13:10
    us any rules, we feel like we have to,
  • 13:10 - 13:12
    to use these rules. I remember when DHH started
  • 13:12 - 13:16
    using put something in to do a loop, a
  • 13:16 - 13:19
    loop in a template in Rails. People got mad
  • 13:19 - 13:20
    at him because he was not using each.
  • 13:20 - 13:24
    And it's like, the language allows this. Why
    do
  • 13:24 - 13:27
    we fight the language designer, and we think
    we're
  • 13:27 - 13:29
    right and the language designer is wrong?
    We're right.
  • 13:29 - 13:32
    The interpreter is wrong.
  • 13:32 - 13:34
    But what I'm trying to say is that the
  • 13:34 - 13:37
    key to writing what you guys call good code
  • 13:37 - 13:41
    is not the syntax. It's communication. And
    this is
  • 13:41 - 13:44
    why Ruby's actually a very good language.
    Because Ruby
  • 13:44 - 13:47
    should help us community. But you don't write
    code
  • 13:47 - 13:50
    to communicate. Once again, I disagree with
    my friend
  • 13:50 - 13:52
    Ernie. I don't believe you write code to tell
  • 13:52 - 13:55
    stories. We write code to deliver products.
  • 13:55 - 13:58
    Now, to deliver products, we need to write
    code,
  • 13:58 - 14:00
    and to write code, we need to communicate.
    And
  • 14:00 - 14:02
    this is why we need to focus on communication.
  • 14:02 - 14:05
    But the end result is really what matters,
    not
  • 14:05 - 14:07
    the process as much. But of course you need
  • 14:07 - 14:10
    to also improve your process.
  • 14:10 - 14:12
    So my suggestion, before we start talking
    with the
  • 14:12 - 14:16
    panel about why I think they're all wrong
    and
  • 14:16 - 14:18
    I'm right, is to focus on the outcome. I
  • 14:18 - 14:21
    really want people to think about, why do
    we
  • 14:21 - 14:23
    do these things? How can we do them better?
  • 14:23 - 14:25
    But not start by, this is how you do
  • 14:25 - 14:28
    things, and then we, it might, we might have
  • 14:28 - 14:30
    a product at the end.
  • 14:30 - 14:32
    When I was working through this talk, I realized
  • 14:32 - 14:35
    I was just basically telling you guys you're
    really
  • 14:35 - 14:38
    wrong, and I'm not giving any hints about
    how
  • 14:38 - 14:41
    you can improve that. Now, to be fair, I'm
  • 14:41 - 14:43
    struggling with the same problem. I don't
    believe there
  • 14:43 - 14:45
    is good and bad code, but I think there
  • 14:45 - 14:48
    are ways of delivering better value. Ruby
    is one
  • 14:48 - 14:49
    of them.
  • 14:49 - 14:53
    And recently I discovered something called
    Mob Programming, and
  • 14:53 - 14:55
    I just want to mention it quickly. Mob Programming
  • 14:55 - 14:58
    is something you should try with your team.
    Mob
  • 14:58 - 15:00
    Programming is like Pair Programming with
    more people. You
  • 15:00 - 15:03
    get the entire team. One of you do a
  • 15:03 - 15:05
    project chart. One keyboard. And you rotate
    every ten
  • 15:05 - 15:06
    minutes.
  • 15:06 - 15:09
    And the idea is that you all work together
  • 15:09 - 15:13
    on the same problem, and you communicate.
    When I
  • 15:13 - 15:15
    was invited to Pair Program with them, I thought
  • 15:15 - 15:18
    it was the worst idea ever. Like, how can
  • 15:18 - 15:20
    four, five people, looking at the same screen,
    can
  • 15:20 - 15:23
    be more efficient than two teams of two?
  • 15:23 - 15:25
    And it turns out that, we focused more on
  • 15:25 - 15:29
    communication than actually the code. We talked
    about a
  • 15:29 - 15:32
    lot about edge cases. And this specific team
    ended
  • 15:32 - 15:35
    up, after a year, being able to deliver ten
  • 15:35 - 15:41
    times more quality code and products than
    they used
  • 15:41 - 15:41
    to do.
  • 15:41 - 15:42
    So they basically have a back log, and they
  • 15:42 - 15:45
    realized they're way faster by working together
    through this
  • 15:45 - 15:48
    process. It works very well for them. It doesn't
  • 15:48 - 15:49
    mean it would work for you. But I challenge
  • 15:49 - 15:51
    you to do that once a week with your
  • 15:51 - 15:53
    team. Take an hour, a hard problem or a
  • 15:53 - 15:56
    new thing, and all work together in communication.
  • 15:56 - 15:58
    And you will see that you will stop blaming
  • 15:58 - 16:00
    other people and be like, oh, your code is
  • 16:00 - 16:03
    wrong. Everybody's writing in the code together,
    and you
  • 16:03 - 16:05
    will stop doing right and wrong. You will
    start
  • 16:05 - 16:07
    talking about, how do we get to the point
  • 16:07 - 16:08
    we want to be.
  • 16:08 - 16:12
    Some other things. Daily iterations. That's
    something I also
  • 16:12 - 16:15
    learned from Woody. Instead of doing weekly
    iterations, spend
  • 16:15 - 16:17
    five minutes at the end of the day, and
  • 16:17 - 16:20
    you draw a happy face and a sad face,
  • 16:20 - 16:22
    and you just talk quickly about what went
    well,
  • 16:22 - 16:24
    what didn't go so well, and how can you
  • 16:24 - 16:26
    improve the things that, that went well.
  • 16:26 - 16:28
    If nothing happened, don't do it, but that
    might
  • 16:28 - 16:30
    be a problem. Then you rit, that was the
  • 16:30 - 16:33
    daily retrospectives. The daily, the daily
    iteration is like
  • 16:33 - 16:35
    a different, it's what kind of business value
    I
  • 16:35 - 16:37
    can deliver by the end of the day.
  • 16:37 - 16:40
    That was a very interesting concept. Like,
    it's hard
  • 16:40 - 16:44
    to break things down. But basically in their
    team,
  • 16:44 - 16:46
    they believed that they should be able to
    deliver
  • 16:46 - 16:48
    business value every single day. And that's
    how they
  • 16:48 - 16:50
    saw the day.
  • 16:50 - 16:51
    Another thing I've learned in the past that
    I
  • 16:51 - 16:55
    really liked is to pair program with people
    and
  • 16:55 - 16:58
    non-programmers, to shadow somebody, like
    a sales' person, or
  • 16:58 - 17:00
    a non-technical person. And you learn a lot
    about
  • 17:00 - 17:03
    the business. I know the thing that's very
    interesting
  • 17:03 - 17:07
    is to write in a different language. Programming
    language,
  • 17:07 - 17:10
    or even learn another human language.
  • 17:10 - 17:12
    So these are just my tips. I just want
  • 17:12 - 17:14
    to summarize that I think there's no such
    thing
  • 17:14 - 17:17
    as bad code, because bad code doesn't run,
    and
  • 17:17 - 17:18
    the only bad code that I know of is
  • 17:18 - 17:20
    the one that Matz doesn't let run, because
    the
  • 17:20 - 17:22
    interpreter doesn't accept it.
  • 17:22 - 17:24
    Now, there's code that might be hard to maintain,
  • 17:24 - 17:26
    and there's code that might have issues, but
    this
  • 17:26 - 17:28
    is based on your own expectations, not on
    the
  • 17:28 - 17:30
    programming language.
  • 17:30 - 17:33
    I will now invite a few people. If you
  • 17:33 - 17:35
    have any questions, you can Tweet to me and
  • 17:35 - 17:37
    I will ask the questions to the panel. But
  • 17:37 - 17:39
    first I would like Bryan Liles to come on
  • 17:39 - 17:45
    stage. Bryan works for ThunderBolt Labs, and
    can you
  • 17:45 - 17:49
    quickly explain what, what you do and I will
  • 17:49 - 17:49
    then-
  • 17:49 - 17:53
    BRYAN LILES: So, I, I work with ThunderBolt
    Labs.
  • 17:53 - 17:56
    We are a part-time consultancy, full-time
    product company. We're
  • 17:56 - 17:59
    trying to solve problems in data using any
    means
  • 17:59 - 18:02
    possible. Not just Ruby. Whatever's fast is
    the best.
  • 18:02 - 18:05
    M.A.: Right. And you're very well-known for
    TAFT, right.
  • 18:05 - 18:05
    Test all the time.
  • 18:05 - 18:08
    B.L.: Yeah, that's actually my epic Ruby troll
    that
  • 18:08 - 18:09
    I did five years ago.
  • 18:09 - 18:09
    M.A.: Right.
  • 18:09 - 18:10
    B.L.: I don't want to eat it.
  • 18:10 - 18:13
    M.A.: Yeah. That's better.
  • 18:13 - 18:18
    B.L.: Yeah. So. Yes. Test all the effing time.
  • 18:18 - 18:21
    Basically what that boils down to is I thought
  • 18:21 - 18:23
    that we should be thinking about testing more,
    and
  • 18:23 - 18:26
    the way that I communicated it to the community
  • 18:26 - 18:29
    was by saying it fifty times in a talk.
  • 18:29 - 18:31
    Test all the fucking time.
  • 18:31 - 18:35
    It worked. Five years later, people are testing
    more.
  • 18:35 - 18:36
    And more people hate me. So we win all
  • 18:36 - 18:37
    the way around.
  • 18:37 - 18:40
    M.A.: All right. I'd also like to invite Bryan
  • 18:40 - 18:42
    Helmkamp, from Code Climate.
  • 18:42 - 18:44
    So, yeah, OK.
  • 18:44 - 18:46
    B.H.: Fancy. Hello.
  • 18:46 - 18:51
    M.A.: So, what, Bryan, you founded, or co-founded
    Code
  • 18:51 - 18:51
    Climate.
  • 18:51 - 18:52
    B.H.: Yes.
  • 18:52 - 18:54
    M.A.: You're also very famous for a lot of
  • 18:54 - 18:57
    the blog posts you wrote.
  • 18:57 - 18:58
    And we'll get into that in a minute.
  • 18:58 - 18:59
    B.H.: Sure.
  • 18:59 - 19:01
    M.A.: I have a few questions for you. And
  • 19:01 - 19:06
    then the last guest is Aaron Patterson who
    works
  • 19:06 - 19:10
    for AT&T and is also part of the C,
  • 19:10 - 19:10
    CRuby team.
  • 19:10 - 19:11
    A.P.: Yes.
  • 19:11 - 19:12
    M.A.: The Rails team.
  • 19:12 - 19:12
    A.P.: Yes.
  • 19:12 - 19:13
    M.A.: The nokogiri team.
  • 19:13 - 19:14
    A.P.: Yes.
  • 19:14 - 19:15
    M.A.: The, what other team?
  • 19:15 - 19:18
    A.P.: I love cats. I'm probably on the merge
  • 19:18 - 19:18
    team too.
  • 19:18 - 19:20
    M.A.: Merge team.
  • 19:20 - 19:23
    A.P.: The A team. I just have to say
  • 19:23 - 19:25
    though, I'm on the, I'm on the Rails core
  • 19:25 - 19:26
    team, I can tell you there is such a
  • 19:26 - 19:30
    thing as bad code. So we're done here.
  • 19:30 - 19:34
    M.A.: All right, let's talk about that-
  • 19:34 - 19:35
    A.P.: Thanks.
  • 19:35 - 19:38
    M.A.: Well, so, let me ask the first question
  • 19:38 - 19:40
    to Aaron, since you seem to want to talk
  • 19:40 - 19:43
    about it. You're known, you're known to work
    on
  • 19:43 - 19:45
    the, some of the worst parts of Rails.
  • 19:45 - 19:47
    A.P.: Yes, that's true.
  • 19:47 - 19:49
    M.A.: So you apparently believe in bad code.
  • 19:49 - 19:50
    A.P.: I do, yes.
  • 19:50 - 19:52
    M.A.: How, how do you know it's bad code?
  • 19:52 - 19:56
    A.P.: So, I believe. So, I know it's bad
  • 19:56 - 19:59
    code. So the thing is, bad code is just
  • 19:59 - 20:02
    like, you know, I'm not gonna say exactly
    the
  • 20:02 - 20:05
    quote. Bad code is just like obscenities.
    I can't
  • 20:05 - 20:08
    tell you what it is, but I know it
  • 20:08 - 20:08
    when I see it.
  • 20:08 - 20:09
    M.A.: But in the, in the-
  • 20:09 - 20:09
    A.P.: That's how I know.
  • 20:09 - 20:12
    M.A.: -in the dictionary, they actually mention,
    as this
  • 20:12 - 20:14
    is vulgar, do not use this word.
  • 20:14 - 20:17
    R.P.: Which word? Obscenities. Yes. Yes. Yes.
    That's true.
  • 20:17 - 20:19
    M.A.: So how do you know when you look
  • 20:19 - 20:21
    at Rails code it's bad? And why-
  • 20:21 - 20:22
    A.P.: I just know.
  • 20:22 - 20:24
    M.A.: Why did people write the bad code?
  • 20:24 - 20:25
    A.P.: Why did, why did they write the bad
  • 20:25 - 20:25
    code?
  • 20:25 - 20:26
    M.A.: Yeah.
  • 20:26 - 20:26
    A.P.: I don't know.
  • 20:26 - 20:28
    M.A.: Was it bad when they wrote it?
  • 20:28 - 20:32
    A.P.: Was it bad when they wrote it? It
  • 20:32 - 20:35
    depends on the situation. I mean, sometimes,
    yeah, it
  • 20:35 - 20:38
    started out bad, or sometimes it just gradually
    got
  • 20:38 - 20:40
    that way. It depends.
  • 20:40 - 20:42
    M.A.: So, so when you're, do you write bad
  • 20:42 - 20:42
    code?
  • 20:42 - 20:46
    A.P.: All the time, yes.
  • 20:46 - 20:53
    M.A.: Why, why do you do it? I'm very
  • 20:53 - 20:54
    confused. Why do you write bad code?
  • 20:54 - 20:57
    A.P.: Well, I mean, so sometimes, like, there
    will
  • 20:57 - 21:00
    be issues where, like, we got a bug or
  • 21:00 - 21:03
    something, and you wanna do- for example,
    like, if
  • 21:03 - 21:04
    we get a bug, or if I get a
  • 21:04 - 21:05
    bug, and I need to fix it in a
  • 21:05 - 21:12
    bug-release version of Rails, for example,
    and like, I
  • 21:12 - 21:13
    can see that there's a right way to fix
  • 21:13 - 21:15
    it. But it turns out that the right way,
  • 21:15 - 21:17
    that would result in good code, turns out
    to
  • 21:17 - 21:18
    be, like, a larger patch-
  • 21:18 - 21:20
    M.A.: OK, let me just stop here. What's, what
  • 21:20 - 21:21
    does it mean, the right way?
  • 21:21 - 21:24
    A.P.: Oh, a way that I think would be
  • 21:24 - 21:25
    more correct or more general.
  • 21:25 - 21:27
    M.A.: So why is it more correct than another
  • 21:27 - 21:28
    way?
  • 21:28 - 21:29
    A.P.: Why is it more correct? It's more correct
  • 21:29 - 21:33
    in another way, because maybe it's more extensible
    or
  • 21:33 - 21:34
    easier to maintain.
  • 21:34 - 21:36
    M.A.: How do you know it's easier to maintain?
  • 21:36 - 21:38
    I'm serious. Like, I'm trying to ask you,
    because
  • 21:38 - 21:40
    when I write code, I don't want to write
  • 21:40 - 21:41
    bad code.
  • 21:41 - 21:43
    A.P.: Well, it mostly, I mean, I have to
  • 21:43 - 21:46
    say it's mostly based on experience. Like,
    I can't
  • 21:46 - 21:48
    tell you exactly why it's more maintainable.
    Something that's
  • 21:48 - 21:50
    easier to test, for example.
  • 21:50 - 21:55
    M.A.: So, Bryan. You, you, you make a business
  • 21:55 - 21:57
    of, of telling people when they write bad
    code,
  • 21:57 - 21:58
    right?
  • 21:58 - 22:01
    B.H.: I'm sorry.
  • 22:01 - 22:05
    M.A.: Aaron cannot, he doesn't really know
    why he
  • 22:05 - 22:06
    writes bad code.
  • 22:06 - 22:06
    A.P: Yeah.
  • 22:06 - 22:07
    M.A.: Can you tell him why-
  • 22:07 - 22:08
    A.P.: Why I write bad code?
  • 22:08 - 22:09
    B.H.: Why do you write bad code?
  • 22:09 - 22:12
    A.P.: I write bad code, I write bad code
  • 22:12 - 22:14
    because I want to have the smallest patch
    in
  • 22:14 - 22:15
    order to fix the bug.
  • 22:15 - 22:17
    M.A.: So is that really bad code?
  • 22:17 - 22:19
    A.P.: So. Yeah. It's bad code.
  • 22:19 - 22:21
    B.L.: Well, how about, how about, let's get
    rid
  • 22:21 - 22:25
    of the term bad. There is code and there
  • 22:25 - 22:28
    is better code. If we get rid of the
  • 22:28 - 22:35
    connotation of it being bad, then maybe that
    will
  • 22:37 - 22:37
    help you.
  • 22:37 - 22:37
    Help us help you.
  • 22:37 - 22:38
    M.A.: Help me Bryan, right.
  • 22:38 - 22:38
    B.H.: Sure.
  • 22:38 - 22:40
    M.A.: You think you know when you see bad
  • 22:40 - 22:42
    code and good code, right. That's why I get
  • 22:42 - 22:43
    an A or F.
  • 22:43 - 22:46
    B.H.: Well, so, the idea, so I think, the
  • 22:46 - 22:48
    idea behind Code Climate, and what we do with
  • 22:48 - 22:51
    code, we do static analysis and we try to
  • 22:51 - 22:55
    give sort of an objective but imperfect assessment
    that
  • 22:55 - 22:59
    can facilitate discussions within teams. So
    I think a
  • 22:59 - 23:02
    lot of, you know, you had that quote up
  • 23:02 - 23:03
    there, and Matt tells me there's gonna be
    a
  • 23:03 - 23:05
    quote on the board that says, if you're not
  • 23:05 - 23:06
    doing an A on Code Climate, your quote is
  • 23:06 - 23:08
    terrible. And I said, who are you going to
  • 23:08 - 23:10
    attribute that quote to? Cause, don't put
    my name
  • 23:10 - 23:12
    on that.
  • 23:12 - 23:13
    Code Climate does not have a 4 point 0
  • 23:13 - 23:16
    on Code Climate. Code Climate scores like
    a 3
  • 23:16 - 23:17
    point 1 on Code Climate. So if your Code
  • 23:17 - 23:18
    Climate score is above 3 point 1, it's better
  • 23:18 - 23:21
    than Code Climate itself.
  • 23:21 - 23:26
    So, you know, the, I think the reality is,
  • 23:26 - 23:29
    we're trying to help people make more informed
    decisions.
  • 23:29 - 23:32
    And that important thing is that the developer
    has
  • 23:32 - 23:34
    as much information available to them when
    they make
  • 23:34 - 23:36
    decisions about how to write the code as possible,
  • 23:36 - 23:39
    right, or as is productive to make, you know,
  • 23:39 - 23:40
    those choices.
  • 23:40 - 23:43
    And sometimes, like Aaron described, you're,
    you're always balancing
  • 23:43 - 23:46
    different trade-offs. Sometimes, a small patch
    is more valuable
  • 23:46 - 23:48
    than a larger patch that might be, I'm gonna
  • 23:48 - 23:52
    avoid the word bad, so, or good, so I
  • 23:52 - 23:54
    don't get yelled at. But might be, you know,
  • 23:54 - 23:54
    easier to understand.
  • 23:54 - 23:59
    M.A.: Right. So, Bryan, you, you build products,
    right.
  • 23:59 - 24:00
    B.L.: Yes. Yes.
  • 24:00 - 24:03
    M.A.: You care a lot about process. I mean,
  • 24:03 - 24:05
    that's why you know for, like, this, this
    TAFT
  • 24:05 - 24:06
    thing is all about process.
  • 24:06 - 24:10
    B.L.: Yes. Process is actually the, the great
    leveler.
  • 24:10 - 24:13
    Believe it or not, there are a lot of
  • 24:13 - 24:16
    great coders out there, but there are way
    more
  • 24:16 - 24:21
    not-great coders out there. Process allows
    me to distribute
  • 24:21 - 24:23
    the great among the not-as-great.
  • 24:23 - 24:25
    And a good example is-
  • 24:25 - 24:26
    M.A.: And if I'm great, I don't need to
  • 24:26 - 24:26
    write tests.
  • 24:26 - 24:28
    B.L.: Well that's, no, that's not true.
  • 24:28 - 24:29
    M.A.: Well that's what you just said, right.
  • 24:29 - 24:33
    A.P.: So Bryan, you prefer processes over
    threads.
  • 24:33 - 24:36
    B.L.: Yes. Exactly.
  • 24:36 - 24:40
    So, actually, so the whole testing thing.
    So, a
  • 24:40 - 24:43
    good example would be tests. Yeah. I do not
  • 24:43 - 24:45
    write tests first all the time. And I'll tell
  • 24:45 - 24:47
    you why. And here is the reason why.
  • 24:47 - 24:48
    M.A.: Wow.
  • 24:48 - 24:49
    B.L.: Because of-
  • 24:49 - 24:50
    M.A.: Wow. You guys should Tweet that.
  • 24:50 - 24:52
    B.L.: And I'll give you an, a great example.
  • 24:52 - 24:54
    I was writing an API for processing excel
    spreadsheets
  • 24:54 - 24:58
    the other day. I had no idea what it
  • 24:58 - 25:00
    looked like. But I knew at the integration
    level,
  • 25:00 - 25:02
    well, I didn't know what that looked like
    either.
  • 25:02 - 25:03
    So guess what? I wrote the code to do
  • 25:03 - 25:05
    it, and then I said, well that looks good.
  • 25:05 - 25:08
    I'll write a test that mirrors this.
  • 25:08 - 25:10
    Not test first, but test after. Still fine.
  • 25:10 - 25:11
    But, you know what, as I learn the process
  • 25:11 - 25:14
    and I learn the domain, yeah, I have the,
  • 25:14 - 25:16
    I actually had the mentality and the insight
    to
  • 25:16 - 25:18
    be able to write tests first. So that's fine.
  • 25:18 - 25:19
    A.P.: I think this comes back to the rules
  • 25:19 - 25:22
    thing that you were mentioning earlier, which
    is basically,
  • 25:22 - 25:24
    like, we give, we give people a bunch of
  • 25:24 - 25:27
    rules, and I don't believe in rules. I, like,
  • 25:27 - 25:29
    I'm sorry. That's, that's weird. I do believe
    in
  • 25:29 - 25:32
    rules, it's just that, I believe these rules
    are
  • 25:32 - 25:35
    guidelines, and you know, like, you, so you
    know
  • 25:35 - 25:37
    when to break those. But, like, you only learn
  • 25:37 - 25:39
    when you can break those and throw those things
  • 25:39 - 25:42
    out when you have experience doing it, right.
  • 25:42 - 25:44
    So he has experience. He knows, like, OK,
    this
  • 25:44 - 25:45
    is an OK time. I'm gonna break the rules.
  • 25:45 - 25:47
    B.L.: So actually I have a, a really small
  • 25:47 - 25:51
    piece of theory on this. Good development
    is knowing
  • 25:51 - 25:54
    why versus how. Until you understand why you're
    doing
  • 25:54 - 25:57
    something, you need the rules to actually
    show you
  • 25:57 - 25:59
    the guidelines so you do not fall off the
  • 25:59 - 25:59
    boat.
  • 25:59 - 26:01
    When you actually start understanding why,
    you can actually
  • 26:01 - 26:03
    ashew the rules, because you don't need them
    anymore,
  • 26:03 - 26:06
    because you know how to walk the straight
    line.
  • 26:06 - 26:09
    And that's, and that's, and I think that is
  • 26:09 - 26:12
    the difference between OK developer and more-than-OK
    developer. And
  • 26:12 - 26:14
    I'm not saying that that, that goes for everyone,
  • 26:14 - 26:16
    but I'm saying that is a good guideline to
  • 26:16 - 26:17
    follow.
  • 26:17 - 26:18
    M.A.: So I have an example. I almost want
  • 26:18 - 26:19
    to show you an example of code that would
  • 26:19 - 26:22
    get an A on, on Code Climate, that would
  • 26:22 - 26:25
    follow all the rules from Sandi Matz, but
    it's
  • 26:25 - 26:27
    actually code that, if I would believe in
    bad
  • 26:27 - 26:29
    code, I would actually use as bad code. Can
  • 26:29 - 26:30
    I show that to you guys?
  • 26:30 - 26:31
    A.P. & B.L. & B.H.: Yeah. Sure. Sure.
  • 26:31 - 26:33
    B.L.: And while he shows you that, I'll take
  • 26:33 - 26:36
    Code on Code Climate that is actually good
    code
  • 26:36 - 26:39
    that fails on Code Climate. I love inject.
    I
  • 26:39 - 26:43
    can think in inject. Code Climate, and I guess
  • 26:43 - 26:45
    because Bryan Davis doesn't like code, doesn't
    like inject-
  • 26:45 - 26:49
    B.H.: Yeah, it actually fails horribly. Yeah,
    so the
  • 26:49 - 26:51
    complexity analysis in Code Climate was built
    on top
  • 26:51 - 26:54
    of an opensource tool called flog, which is
    roughly
  • 26:54 - 26:57
    an ABC metric, assignments, branches, and
    conditionals, but it
  • 26:57 - 27:00
    has the few things that it really doesn't
    like.
  • 27:00 - 27:02
    And most of that is metaprogramming.
  • 27:02 - 27:06
    But one of those things is inject. And it
  • 27:06 - 27:08
    just, it will be very unhappy with you if
  • 27:08 - 27:10
    you use inject. But, as will I, because I
  • 27:10 - 27:12
    can never understand how that method works.
    I'm not
  • 27:12 - 27:13
    smart enough for inject.
  • 27:13 - 27:16
    A.P.: Can you change, can you just change
    inject
  • 27:16 - 27:22
    to reduce? And then will it work?
  • 27:22 - 27:24
    B.L.: So yeah. I actually could. I actually
    could.
  • 27:24 - 27:26
    B.H.: That, that would improve your Code Climate
    score.
  • 27:26 - 27:28
    B.L.: I'm a troll, I'm a code troll. I
  • 27:28 - 27:29
    know it.
  • 27:29 - 27:30
    M.A.: So here is example of code. So this
  • 27:30 - 27:34
    is a controller in Rails. It's actually real
    code
  • 27:34 - 27:36
    that I got from production. And so, we have
  • 27:36 - 27:39
    def create, and we have this small method
    name
  • 27:39 - 27:41
    that, you look at that, like, wow, this is
  • 27:41 - 27:42
    great. But, I'm a big-
  • 27:42 - 27:42
    B.H.: This is fantastic.
  • 27:42 - 27:45
    M.A.: -truist, so I wanted to see- What's
    that?
  • 27:45 - 27:47
    B.H.: This is fantastic.
  • 27:47 - 27:48
    M.A.: SO here's the code. This is the entire
  • 27:48 - 27:52
    code. And, I mean, this is beautiful, right.
    Single
  • 27:52 - 27:55
    line. It's great. The problem is when you
    start
  • 27:55 - 27:58
    going into this code. So you start by saying
  • 27:58 - 28:01
    set_comment_to_new_comment, and that calls
    set_comment, which is defined on
  • 28:01 - 28:03
    the bottom here, that sets the nav bar, to
  • 28:03 - 28:05
    the param. Now, we have no idea where the
  • 28:05 - 28:08
    param is because comment, we don't know what
    comment.
  • 28:08 - 28:11
    Maybe it's a string. Maybe something else.
  • 28:11 - 28:15
    But then comment comes from new_comment, and
    new_comment is
  • 28:15 - 28:18
    defined here, and turns out, it's actually
    an instance
  • 28:18 - 28:21
    of this class, which lives outside of this
    context.
  • 28:21 - 28:24
    And we pass it comment_params, which itself
    is a
  • 28:24 - 28:28
    method that calls permitted_params, which
    itself is calling params,
  • 28:28 - 28:31
    which is something defined somewhere else,
    and calls permit
  • 28:31 - 28:32
    on it.
  • 28:32 - 28:34
    And we could actually rewrite this entire
    code like
  • 28:34 - 28:34
    that.
  • 28:34 - 28:37
    B.L.: I hated that code. I really did. That
  • 28:37 - 28:43
    was bad. Sorry. I, I'm, I'm disappointed that
    the
  • 28:43 - 28:45
    author of this code didn't take the opportunity
    to
  • 28:45 - 28:49
    extract a permitted_comment_params method
    with just the, the symbols.
  • 28:49 - 28:55
    I feel like they cut a few corners here.
  • 28:55 - 28:58
    M.A.: So I don't think it's bad. I think
  • 28:58 - 28:59
    it's hard to maintain. It's hard for me to
  • 28:59 - 29:02
    follow and to understand. And over abstraction.
    But you
  • 29:02 - 29:04
    also see, on the other side, under abstraction.
  • 29:04 - 29:05
    B.H.: Yes.
  • 29:05 - 29:07
    M.A.: What's interesting for me when I see
    code
  • 29:07 - 29:08
    like that is not to say it's good or
  • 29:08 - 29:11
    it's bad, it's to talk about it. That, why
  • 29:11 - 29:13
    do you think - wow, I need to go
  • 29:13 - 29:16
    through this. Why do you think this was bad?
  • 29:16 - 29:18
    Like, why did you choose to not write that
  • 29:18 - 29:21
    instead of writing the complicated version.
  • 29:21 - 29:22
    And, and this is-
  • 29:22 - 29:23
    A.P.: I, I didn't write that Matt.
  • 29:23 - 29:24
    M.A.: Well, you didn't write it.
  • 29:24 - 29:26
    This is kind of the discussion I want to
  • 29:26 - 29:28
    have with people. It's not about doing it
    right
  • 29:28 - 29:30
    or doing it wrong. It's trying to understand
    why
  • 29:30 - 29:32
    they did it. And is that doing the same
  • 29:32 - 29:35
    thing that we want to do? We're just setting
  • 29:35 - 29:37
    the new comments.
  • 29:37 - 29:38
    So I, sorry, I just wanted to show you
  • 29:38 - 29:40
    this code, because this is a good example-
  • 29:40 - 29:40
    A.P.: Yeah.
  • 29:40 - 29:42
    M.A.: -of why rules don't always apply.
  • 29:42 - 29:45
    B.H.: Yup. So in my mind, there's, there's
    definitely
  • 29:45 - 29:49
    a line that needs to be walked between over-abstraction
  • 29:49 - 29:53
    and under-abstraction. And typically, I think
    the most common
  • 29:53 - 29:55
    pattern for large Rails apps that are maintained
    over
  • 29:55 - 29:59
    multiple years by teams of, you know, multiple
    people
  • 29:59 - 30:03
    tend to suffer from under-abstraction.
  • 30:03 - 30:06
    And that manifests itself in god objects and
    classes.
  • 30:06 - 30:08
    Those files that, like, when you open them
    you
  • 30:08 - 30:09
    want to just shut them and run away from
  • 30:09 - 30:10
    them and wait for someone else in your team
  • 30:10 - 30:12
    to finish the work.
  • 30:12 - 30:15
    So what, you know, with Code Climate for example,
  • 30:15 - 30:18
    what we try to do is provide feedback as
  • 30:18 - 30:21
    things start changing incrementally. So at
    the beginning, Code
  • 30:21 - 30:23
    Climate's gonna tell you, all your code isn't
    like,
  • 30:23 - 30:25
    it'll say, OK, there's, there's no code here.
    It's
  • 30:25 - 30:26
    an A. Great.
  • 30:26 - 30:28
    And it won't start complaining until that
    class starts
  • 30:28 - 30:31
    to get pretty big. And that's when, what it's,
  • 30:31 - 30:33
    when it's complaining at that point, what
    it's really
  • 30:33 - 30:35
    saying is, now's another time to take another
    look
  • 30:35 - 30:38
    at this and sort of start to think about
  • 30:38 - 30:42
    if there's maybe additional concepts that
    are being represented
  • 30:42 - 30:44
    here that deserve different treatment.
  • 30:44 - 30:46
    And then the developers make that decision
    in their
  • 30:46 - 30:48
    teams based on the discussion that comes after
    that.
  • 30:48 - 30:50
    A.P.: I have to say, Code Climate sounds like
  • 30:50 - 30:53
    a pretty shady business.
  • 30:53 - 30:58
    M.A.: So, at the end of the day, how
  • 30:58 - 31:01
    do you guys use this to create better products?
  • 31:01 - 31:03
    Cause that's, for me, that's really the, the
    key
  • 31:03 - 31:05
    question. We, we could argue about code and
    syntax
  • 31:05 - 31:07
    and things we like and we don't like forever.
  • 31:07 - 31:07
    B.H.: Yeah.
  • 31:07 - 31:10
    M.A.: But really, do you, do you first agree
  • 31:10 - 31:12
    that we don't write code to write code, we
  • 31:12 - 31:13
    write code to build something or not?
  • 31:13 - 31:17
    B.L.: No. All right, no. So, at home, whenever
  • 31:17 - 31:20
    I'm learning another language, yes. I write
    code to
  • 31:20 - 31:23
    write code. But whenever I'm working and I'm
    doing
  • 31:23 - 31:25
    it to make money, I want to do it
  • 31:25 - 31:29
    in the fastest way possible, with the least
    amount
  • 31:29 - 31:32
    of communication with having the most amount
    of communication.
  • 31:32 - 31:33
    I don't want to just talk about it. I
  • 31:33 - 31:34
    want to do it.
  • 31:34 - 31:38
    And I want to move on. Code is not
  • 31:38 - 31:39
    the final product, like you said earlier.
    I'm, I'm
  • 31:39 - 31:40
    paid to ship.
  • 31:40 - 31:43
    A.P.: Yeah, but on the other hand, so I
  • 31:43 - 31:45
    agree, we're writing, we're writing code in
    order to
  • 31:45 - 31:50
    build products, something like that. But I'm,
    I'm hesitant
  • 31:50 - 31:51
    to agree with this statement because it makes
    it
  • 31:51 - 31:53
    sound like the ends justify the means, and
    I
  • 31:53 - 31:56
    totally disagree with that. Yeah, I don't
    think so.
  • 31:56 - 31:58
    I want to write good code to build my
  • 31:58 - 31:58
    product.
  • 31:58 - 32:01
    I want to write something I'll be proud of.
  • 32:01 - 32:03
    I am a programmer, and what I deliver is
  • 32:03 - 32:03
    code.
  • 32:03 - 32:06
    M.A.: So let me ask you a question. You
  • 32:06 - 32:08
    write many opensource code. Is there a difference
    between
  • 32:08 - 32:13
    writing opensource code and writing applications
    that you deliver
  • 32:13 - 32:14
    for different kind of users?
  • 32:14 - 32:16
    A.P.: For me, no.
  • 32:16 - 32:19
    M.A.: What, what do you guys think?
  • 32:19 - 32:21
    B.L.: I guess it depends on your client. When
  • 32:21 - 32:25
    you're dealing with fifty billion dollar companies
    whose lawyer
  • 32:25 - 32:29
    pool is bigger than your company times ten,
    yeah.
  • 32:29 - 32:34
    You just, you gotta walk that fine line. Don't
  • 32:34 - 32:35
    M.A.: But, but, I feel like, when you write
  • 32:35 - 32:39
    opensource code, your product is also your
    code, so
  • 32:39 - 32:41
    that why, that's why it matters a lot more.
  • 32:41 - 32:45
    And, I think that, you're also an example
    for
  • 32:45 - 32:47
    the people. So it's, it's very, very different.
  • 32:47 - 32:49
    A.P.: Well, but the thing is, I mean with,
  • 32:49 - 32:51
    when I, so when I think about, OK. I'm
  • 32:51 - 32:55
    gonna use the bad word. Good code. Sorry.
    When
  • 32:55 - 32:56
    I think about good-
  • 32:56 - 32:57
    M.A.: Just to clarify, when you say good code
  • 32:57 - 33:01
    in this case, you mean code that's easy to
  • 33:01 - 33:01
    maintain?
  • 33:01 - 33:02
    A.P.: Yes. So what I, what I think about
  • 33:02 - 33:05
    is something that's easy to maintain, easy
    to extend.
  • 33:05 - 33:07
    Something that, something that can last going
    into the
  • 33:07 - 33:09
    future. And that's, that's basically what
    I think about-
  • 33:09 - 33:10
    M.A.: And you base that on-
  • 33:10 - 33:11
    A.P.: -when I'm writing.
  • 33:11 - 33:11
    M.A.: -on, on your experience?
  • 33:11 - 33:13
    A.P.: Yes. On my experience. And that's what
    I
  • 33:13 - 33:15
    wanna, that's what I wanna write when I'm
    building
  • 33:15 - 33:18
    a product is something like that, because
    you know,
  • 33:18 - 33:19
    the business rules are gonna change, and we
    need
  • 33:19 - 33:22
    to remain, remain agile and be able to be
  • 33:22 - 33:25
    more malleable. I'm afraid that if we're just,
    like,
  • 33:25 - 33:27
    well, it doesn't matter. I'm gonna get the
    product
  • 33:27 - 33:29
    done. I'll just throw code everywhere, it's
    fine!
  • 33:29 - 33:32
    Oh, the product's done. Ship it! And then
    as
  • 33:32 - 33:35
    soon as the business rules change, you're
    like, oh
  • 33:35 - 33:39
    man. Now I gotta adjust this mess I have.
  • 33:39 - 33:41
    B.H.: Yeah. I think it's, it's very difficult,
    I
  • 33:41 - 33:44
    think, in practice to have a product which
    has
  • 33:44 - 33:48
    high external quality without having high
    internal quality. If
  • 33:48 - 33:50
    you're writing code which is difficult for
    the humans
  • 33:50 - 33:52
    who are working on it to understand, it's
    gonna
  • 33:52 - 33:54
    be much more likely that there are bugs that
  • 33:54 - 33:55
    are creeping into the software. And also that
    the
  • 33:55 - 33:58
    software is not able to be, you know, iterated
  • 33:58 - 34:00
    quickly to respond to the needs of its customers
  • 34:00 - 34:02
    and its users.
  • 34:02 - 34:03
    And that's when you start to see, you know,
  • 34:03 - 34:05
    you've all probably used products that feel
    buggy all
  • 34:05 - 34:08
    the time, that feel like they are never able
  • 34:08 - 34:09
    to get updated cause you can kind of see,
  • 34:09 - 34:11
    like, the wear and tear that the developers
    just
  • 34:11 - 34:13
    can't actually maintain the system. So I,
    I think
  • 34:13 - 34:18
    it's, it's possible to have good internal
    quality, without
  • 34:18 - 34:21
    good external quality, but it's very difficult
    to have
  • 34:21 - 34:23
    good external quality without good internal
    quality.
  • 34:23 - 34:25
    A.P.: If the product was just gonna end and
  • 34:25 - 34:28
    be like, OK, it's done now, then I'd say
  • 34:28 - 34:30
    go for it, right. Whatever you want to. Doesn't
  • 34:30 - 34:33
    matter. But I don't think that's the case.
  • 34:33 - 34:34
    M.A.: Well, so I think I agree more with
  • 34:34 - 34:35
    Bryan than with you.
  • 34:35 - 34:36
    A.P.: OK.
  • 34:36 - 34:38
    M.A.: No, the reason why I said that-
  • 34:38 - 34:39
    A.P.: We're not here to agree, Matt.
  • 34:39 - 34:40
    M.A.: I just wanted to say, no-
  • 34:40 - 34:42
    A.P.: The only reason I agreed to join this
  • 34:42 - 34:44
    panel was because we were talking, and I'm
    like,
  • 34:44 - 34:47
    I completely disagree with you. I totally
    disagree with
  • 34:47 - 34:48
    you. I want to be on the pan, I
  • 34:48 - 34:49
    want to be on the panel. In fact, I
  • 34:49 - 34:51
    wasn't planning on speaking here. You can
    see on
  • 34:51 - 34:53
    my badge. It says attendee.
  • 34:53 - 34:57
    M.A.: No. I think the, the, the question is,
  • 34:57 - 34:59
    do you need to first focus on the code
  • 34:59 - 35:02
    being right, or do you need to focus on
  • 35:02 - 35:04
    the product being right? And I believe, like
    Bryan
  • 35:04 - 35:06
    was saying, that if you work on the product
  • 35:06 - 35:09
    being right, you have to actually have code
    that
  • 35:09 - 35:12
    will match these expectations. And therefore
    your code cannot
  • 35:12 - 35:12
    be bad.
  • 35:12 - 35:14
    If your code is bad it cannot deliver good
  • 35:14 - 35:14
    product.
  • 35:14 - 35:15
    B.L.: Well-
  • 35:15 - 35:17
    M.A.: And it's just, where do you focus?
  • 35:17 - 35:19
    A.P.: What is a good product? Ooh!
  • 35:19 - 35:25
    M.A.: All right you got me.
  • 35:25 - 35:31
    B.L.: You could subscribe to my code does
    smart
  • 35:31 - 35:34
    things so there are smart things inside of
    my
  • 35:34 - 35:37
    code, and therefore I'm a smart guy and whatever
  • 35:37 - 35:39
    I do is right. I mean, sure, everyone in
  • 35:39 - 35:41
    this room has seen that smart guy code stuff.
  • 35:41 - 35:42
    But, you know, when it-
  • 35:42 - 35:44
    M.A.: Are you talking about me?
  • 35:44 - 35:49
    B.L.: No. But when it comes down to it,
  • 35:49 - 35:53
    when you're running a business, you're very
    practical. You
  • 35:53 - 35:56
    can't just be short-sighted and say that I'm
    gonna
  • 35:56 - 35:57
    do this and it's gonna be perfect.
  • 35:57 - 35:57
    M.A.: Right.
  • 35:57 - 35:58
    B.L.: We, we try to do the best that
  • 35:58 - 36:00
    we can within the means that we have. And,
  • 36:00 - 36:02
    you know, some things are better than others.
    I
  • 36:02 - 36:04
    don't like the word bad, unless you're a bad
  • 36:04 - 36:05
    developer.
  • 36:05 - 36:07
    M.A.: So I should believe there's no bad code,
  • 36:07 - 36:08
    but there's, there are a lot of bad developers.
  • 36:08 - 36:10
    B.L.: Oh, I agree there. There are horrible
    developers
  • 36:10 - 36:11
    out there.
  • 36:11 - 36:16
    A.P.: I'm a bad developer. I'm a rebel. I've
  • 36:16 - 36:21
    got mavericks installed. I'm a maverick.
  • 36:21 - 36:24
    B.H.: You've been saving that one all day.
  • 36:24 - 36:25
    A.P.: That's classic!
  • 36:25 - 36:28
    M.A.: So, what are the issues, Aaron, with,
    with,
  • 36:28 - 36:30
    what you were saying, is that if, especially
    when
  • 36:30 - 36:32
    you're a junior developer, you want to do
    things
  • 36:32 - 36:34
    right, right. Because that's what matters
    the most to
  • 36:34 - 36:36
    you. But you might end up building a lot
  • 36:36 - 36:38
    of things that are not useful. And they will
  • 36:38 - 36:40
    slow you down. You're not gonna be able to
  • 36:40 - 36:44
    ship your product on time. And this abstraction
    layer
  • 36:44 - 36:45
    that you've constructed, I'm sure the people
    who wrote
  • 36:45 - 36:49
    the code I showed you here really meant best,
  • 36:49 - 36:51
    because they wanted to be flexible but at
    the
  • 36:51 - 36:52
    end of the day, it's not that fixable.
  • 36:52 - 36:54
    It's actually worse than if it was simpler.
  • 36:54 - 36:56
    A.P.: Well, this is a, it was probably a
  • 36:56 - 36:58
    person who didn't know when to break the rules,
  • 36:58 - 36:59
    right. So, and so-
  • 36:59 - 37:00
    M.A.: How do you know that?
  • 37:00 - 37:02
    A.P.: This person was probably following the
    rules and
  • 37:02 - 37:03
    didn't know when to break them.
  • 37:03 - 37:05
    M.A.: You and I seem to always break rules.
  • 37:05 - 37:06
    But what about, how do you know when to
  • 37:06 - 37:07
    break rules?
  • 37:07 - 37:08
    A.P.: I don't know. I can't tell you.
  • 37:08 - 37:10
    M.A.: Well I break the wrong rules all the
  • 37:10 - 37:12
    time. How do you know what rules to, to
  • 37:12 - 37:12
    break?
  • 37:12 - 37:15
    B.H.: So, so one theory I have about this,
  • 37:15 - 37:17
    you know, sometimes people ask me, like, well
    how
  • 37:17 - 37:18
    do I know when I need to refactor? Is,
  • 37:18 - 37:20
    like, kind of another way to think about that.
  • 37:20 - 37:22
    Like, how far can I go just sort of
  • 37:22 - 37:25
    pushing things in the same spot before I need
  • 37:25 - 37:26
    to stop and refactor.
  • 37:26 - 37:28
    And the way, one of the heuristics that I
  • 37:28 - 37:30
    use to think about that, to try to give
  • 37:30 - 37:33
    people something a bit concrete, is looking
    at the
  • 37:33 - 37:36
    code and thinking about how long would it
    take
  • 37:36 - 37:38
    me, if I had to sit down and refactor
  • 37:38 - 37:41
    this, to take it from where it is to
  • 37:41 - 37:43
    something that's really easy to work in?
  • 37:43 - 37:46
    And if the answer to that is, you know,
  • 37:46 - 37:48
    maybe half a day, a day at the most,
  • 37:48 - 37:51
    then I know that regardless of what the next
  • 37:51 - 37:53
    feature I need to implement is, I'm no more
  • 37:53 - 37:56
    than half a day away from having really maintainable
  • 37:56 - 37:58
    code to work in in order to ship that,
  • 37:58 - 37:59
    right.
  • 37:59 - 38:00
    So if I need to change it dramatically, I'll
  • 38:00 - 38:03
    spend that half day, get it into great shape,
  • 38:03 - 38:05
    and then work in there. The problem comes,
    when
  • 38:05 - 38:08
    it's like, for me to refactor this will take
  • 38:08 - 38:10
    a week, and then you're faced with having
    to
  • 38:10 - 38:13
    make some really difficult decisions about
    how to implement
  • 38:13 - 38:14
    that feature.
  • 38:14 - 38:16
    A.P.: The problem, though, the problem with
    that, though,
  • 38:16 - 38:18
    is when you say, like, something that becomes
    really
  • 38:18 - 38:21
    easy to work in, which is, just again, another
  • 38:21 - 38:25
    subjective issue. Like, you can't, you can't,
    everybody who
  • 38:25 - 38:27
    looks at one bit of code is gonna have
  • 38:27 - 38:29
    some different opinion about what is easy
    to work
  • 38:29 - 38:30
    in, right.
  • 38:30 - 38:32
    B.H.: Yeah. It's like, it's absolutely subjective.
    I don't
  • 38:32 - 38:34
    think there's a solution to that.
  • 38:34 - 38:36
    M.A.: Isn't it also based on where we're planning
  • 38:36 - 38:38
    on going with the code? Like, if you know
  • 38:38 - 38:40
    you're not gonna build more features, there's
    no need
  • 38:40 - 38:43
    for you to add layers of abstraction. And
    then,
  • 38:43 - 38:45
    the question we get from the audience, is
    how
  • 38:45 - 38:49
    do you evaluate the cost, the cost of good
  • 38:49 - 38:51
    code versus better code?
  • 38:51 - 38:54
    Because, you're saying, well there's good
    code and there's
  • 38:54 - 38:57
    better code. How do we evaluate the cost?
    Because,
  • 38:57 - 38:59
    you have to pay it, right. Especially when
    you
  • 38:59 - 39:00
    run a business, you're paying for the better
    code.
  • 39:00 - 39:02
    A.P.: It's about $350.
  • 39:02 - 39:03
    M.A.: $350?
  • 39:03 - 39:06
    B.H.: A pound? A line?
  • 39:06 - 39:11
    M.A.: In, the, the other question is, should
    you
  • 39:11 - 39:13
    really, I mean, it's still about the cost.
    Like,
  • 39:13 - 39:15
    should you worry about shipping now or any
    later?
  • 39:15 - 39:18
    Like, what is your approach to that? Because
    you
  • 39:18 - 39:20
    can refactor, right. If you ship small units-
  • 39:20 - 39:20
    B.H.: Yeah.
  • 39:20 - 39:22
    M.A.: They can be not as great as they
  • 39:22 - 39:22
    could be-
  • 39:22 - 39:22
    B.H.: Well-
  • 39:22 - 39:24
    M.A.: But then you refactor as you learn more.
  • 39:24 - 39:25
    B.H.: Yeah. So I think there are, there are
  • 39:25 - 39:27
    a couple different types of changes, and they're,
    they're
  • 39:27 - 39:31
    handled a bit differently. Like, so, Katrina
    Owen sometimes
  • 39:31 - 39:33
    talks about how when she's looking at a class
  • 39:33 - 39:36
    and working on it, she will pretty much always
  • 39:36 - 39:39
    take the steps of trying to decompose things
    into
  • 39:39 - 39:42
    composed methods, because that is just going
    to, it's
  • 39:42 - 39:45
    pretty easy to do and it pays dividends basically
  • 39:45 - 39:46
    right away.
  • 39:46 - 39:48
    So I think sometimes she says things like,
    it's
  • 39:48 - 39:49
    making an investment in, you know, a stock
    that
  • 39:49 - 39:50
    you're always going to, is always going to
    go
  • 39:50 - 39:54
    up, and is always gonna pay dividends. But
    changing
  • 39:54 - 39:58
    around the structure of your application,
    introducing new classes
  • 39:58 - 40:02
    and concepts and layers, that is, tends to
    be
  • 40:02 - 40:03
    a lot more costly.
  • 40:03 - 40:06
    So I would pretty much always try to do
  • 40:06 - 40:08
    the former, and the later is kind of more
  • 40:08 - 40:09
    what I was referring to when I was discussing,
  • 40:09 - 40:13
    you know, thinking about how much work it
    would
  • 40:13 - 40:16
    be to sort of level up your architecture when
  • 40:16 - 40:16
    you're faced with that.
  • 40:16 - 40:19
    M.A.: So a very simple rule I have, because
  • 40:19 - 40:20
    I don't have a lot of rules, but if
  • 40:20 - 40:23
    syntax doesn't work with my code, there's
    a problem.
  • 40:23 - 40:24
    So if, if I run C tags and I
  • 40:24 - 40:27
    cannot find where the method is being defined,
    there's
  • 40:27 - 40:28
    a big issue right there.
  • 40:28 - 40:29
    A.P.: So I think, I think a lot of
  • 40:29 - 40:31
    people talking about how, when do we know,
    like,
  • 40:31 - 40:33
    when should we ship and stuff like that, or
  • 40:33 - 40:35
    what, like, how do we know how good the
  • 40:35 - 40:37
    code has to be before we ship is, in,
  • 40:37 - 40:40
    in my personal opinion like, I'm, I'm totally
    afraid
  • 40:40 - 40:42
    of being like, OK, I gotta make sure that
  • 40:42 - 40:44
    this is totally perfect before we ship.
  • 40:44 - 40:46
    And that's, that's absolutely a problem for
    me, which
  • 40:46 - 40:48
    is why I know this is a weird thing
  • 40:48 - 40:50
    to say for an opensource developer, but I
    really
  • 40:50 - 40:53
    like deadlines. So if I have - yes -
  • 40:53 - 40:55
    it's totally weird to say. But I like having
  • 40:55 - 40:57
    deadlines, so it's like, well, I have to ship
  • 40:57 - 40:59
    this feature. It has to ship. I can't, I
  • 40:59 - 41:01
    mean, I'll make it as good as I can,
  • 41:01 - 41:03
    but I know that we can just make it
  • 41:03 - 41:05
    better in the future. Here's my date. Let's
    do
  • 41:05 - 41:05
    it.
  • 41:05 - 41:07
    M.A.: So you're saying that when you write
    code,
  • 41:07 - 41:08
    you don't try to write the right code, you
  • 41:08 - 41:11
    try to write the best code you can based
  • 41:11 - 41:11
    on the timeline-
  • 41:11 - 41:13
    A.P.: Yes. Exactly. I write the best-
  • 41:13 - 41:15
    M.A.: Do you time blocks? Do you say, I
  • 41:15 - 41:16
    have two hours, I want to finish that in
  • 41:16 - 41:17
    two hours?
  • 41:17 - 41:17
    A.P.: Yes, I do.
  • 41:17 - 41:19
    M.A.: Do people do that? Can I see some
  • 41:19 - 41:20
    B.L.: Yeah. I, I do that as well.
  • 41:20 - 41:22
    M.A.: You do that as well.
  • 41:22 - 41:22
    B.L.: Yes.
  • 41:22 - 41:24
    M.A.: I have a tendency to do that because
  • 41:24 - 41:26
    I get stuck or, I mean, I can try
  • 41:26 - 41:27
    to improve my code for hours, and if I
  • 41:27 - 41:30
    put a limit, I know, like, oh I only
  • 41:30 - 41:32
    have ten minutes. I better finish this thing
    now.
  • 41:32 - 41:34
    So that works for me, too.
  • 41:34 - 41:36
    B.H.: Well, one thing I wanted to interject
    into
  • 41:36 - 41:38
    the conversation is I think with the way that
  • 41:38 - 41:40
    you opened, it kind of made it seem like
  • 41:40 - 41:43
    there was a conflict between sort of shipping
    good
  • 41:43 - 41:46
    products and writing good code. And I don't
    think
  • 41:46 - 41:47
    that's necessarily the case. In fact, I think
    in
  • 41:47 - 41:50
    most cases, those are supportive of each other.
    And
  • 41:50 - 41:51
    that was kind of what I was saying earlier.
  • 41:51 - 41:54
    But there's this vicious cycle that happens
    when you
  • 41:54 - 41:57
    write code, which is, difficult to maintain.
    So you
  • 41:57 - 41:59
    have this, you know, maybe you're under a
    lot
  • 41:59 - 42:01
    of pressure to deliver something by a deadline,
    which
  • 42:01 - 42:03
    is what made me think of this. So because
  • 42:03 - 42:06
    of the pressure, you write sloppy code or
    code
  • 42:06 - 42:08
    that's hard to understand. And that has the
    effect
  • 42:08 - 42:12
    of making things even more late, because now
    it's
  • 42:12 - 42:14
    difficult for the programmers to change it,
    and this
  • 42:14 - 42:17
    just starts to sort of build on itself.
  • 42:17 - 42:19
    So the next deadline that the business has
    is
  • 42:19 - 42:21
    even harder to meet, and pretty soon you're
    just
  • 42:21 - 42:23
    stuck in this endless loop of writing crappier
    and
  • 42:23 - 42:26
    crappier code to meet more and more difficult
    deadlines.
  • 42:26 - 42:29
    And that, that causes, obviously, in some
    cases, total
  • 42:29 - 42:30
    business failure.
  • 42:30 - 42:32
    M.A.: You seem to talk about experience. You
    probably
  • 42:32 - 42:34
    experienced that in the past, right.
  • 42:34 - 42:35
    B.H.: Yeah, in various forms.
  • 42:35 - 42:36
    M.A.: So how did you get out of that?
  • 42:36 - 42:38
    B.H.: Good question.
  • 42:38 - 42:40
    So I set up Code Climate. It's-
  • 42:40 - 42:42
    M.A.: Wait. Wait, wait, wait, wait. Aaron
    has-
  • 42:42 - 42:44
    B.H.: It's C-O-D-E, so yeah, oh sorry.
  • 42:44 - 42:46
    A.P.: Would you call this vicious cycle the
    perfect
  • 42:46 - 42:47
    storm?
  • 42:47 - 42:50
    B.H.: I might. I might.
  • 42:50 - 42:52
    M.A.: All right. Back to the real question.
    So
  • 42:52 - 42:54
    how do you get out of this perfect storm?
  • 42:54 - 43:00
    B.H.: Yeah. So it's, I used to- You have
  • 43:00 - 43:02
    to be prepared for this whenever anyone tells
    you
  • 43:02 - 43:04
    you're gonna be on a panel with Aaron. You
  • 43:04 - 43:07
    have to, you spend a lot of time focusing
  • 43:07 - 43:11
    in preparation, so. So there's a two, I recommend,
  • 43:11 - 43:13
    like, I usually try to follow two steps.
  • 43:13 - 43:18
    One, is stop introducing new code, which is
    creating
  • 43:18 - 43:20
    whatever problem you're experiencing. In this
    case, like, code
  • 43:20 - 43:22
    that's difficult to understand. You have to
    stop writing
  • 43:22 - 43:24
    more code like that. And that's where I think
  • 43:24 - 43:26
    a lot of teams struggle to get that first
  • 43:26 - 43:27
    part done.
  • 43:27 - 43:28
    They realize, we have a big problem, but they
  • 43:28 - 43:32
    haven't actually stopped introducing new problems.
    And then you
  • 43:32 - 43:34
    just start chipping away at it over time.
    And
  • 43:34 - 43:36
    there, there is a point where, you know, you
  • 43:36 - 43:37
    kind of, as a development team, have to take
  • 43:37 - 43:39
    responsibility for it and say, this is how
    we're
  • 43:39 - 43:42
    going to do things because it has these benefits,
  • 43:42 - 43:43
    and we can flip this cycle around.
  • 43:43 - 43:45
    M.A.: So, Bryan, do you have a process for
  • 43:45 - 43:48
    that? I mean, you love processes.
  • 43:48 - 43:52
    B.L.: I mean, yeah. I, I, I mean. I
  • 43:52 - 43:54
    have had the pleasure of working with great
    developers,
  • 43:54 - 43:56
    and I've had the, also the pleasure of working
  • 43:56 - 44:01
    with decent developers. What I'm gonna say
    is actually,
  • 44:01 - 44:03
    I'm kinda not gonna answer your question.
    What I'm
  • 44:03 - 44:06
    gonna say is that, not everybody can get to
  • 44:06 - 44:11
    that place. Unfortunately, in the real world,
    business fail.
  • 44:11 - 44:14
    And the reason they fail is because their
    team
  • 44:14 - 44:15
    can't figure out how to do it.
  • 44:15 - 44:16
    There is-
  • 44:16 - 44:17
    M.A.: How, or what to do?
  • 44:17 - 44:22
    B.L.: Well, they can't figure out how to ship
  • 44:22 - 44:23
    in a, in a method that actually pays the
  • 44:23 - 44:26
    bills. And, you know, what, what, what I'm
    gonna
  • 44:26 - 44:26
    say-
  • 44:26 - 44:29
    M.A.: So are you saying that- sorry. Do startups
  • 44:29 - 44:31
    fail because of code? That's not shipped?
  • 44:31 - 44:33
    B.L.: Well, you know, they, they do. But,
    but
  • 44:33 - 44:35
    that code failure because, because of bad
    management, or
  • 44:35 - 44:38
    it could be because the dev team is awful.
  • 44:38 - 44:41
    There's a lot of companies, there's people
    here, in
  • 44:41 - 44:43
    this crowd right now, who are working for
    companies
  • 44:43 - 44:45
    that will not exist next year.
  • 44:45 - 44:48
    And all of us are in that same position.
  • 44:48 - 44:49
    M.A.: Don't, don't, don't say that. It's not
    nice.
  • 44:49 - 44:50
    B.L.: I mean, yes. Companies that might not
    exist
  • 44:50 - 44:53
    next year. So, no. But, I, but what I
  • 44:53 - 44:56
    wanna do is, I always focus on very small
  • 44:56 - 44:58
    incremental steps. I want to be better than
    I
  • 44:58 - 45:00
    was last year. I want to be better than
  • 45:00 - 45:02
    I was yesterday. And I can't compare myself
    to
  • 45:02 - 45:05
    Aaron or Bryan, and the reason why is because,
  • 45:05 - 45:09
    it is subjective. We have different needs.
    We have
  • 45:09 - 45:11
    different histories. We have different, we
    like different things.
  • 45:11 - 45:15
    I don't like cats. So, you know.
  • 45:15 - 45:17
    So, so what I want to say is that,
  • 45:17 - 45:19
    there is no answer to your question.
  • 45:19 - 45:22
    A.P.: I respect that. I disagree with it.
    But
  • 45:22 - 45:23
    I respect your opinion.
  • 45:23 - 45:25
    B.L.: No, but there is, there is no answer
  • 45:25 - 45:25
    to these questions.
  • 45:25 - 45:26
    M.A: So-
  • 45:26 - 45:27
    B.L.: What I'm saying is-
  • 45:27 - 45:29
    M.A.: Instead of asking, let me just rephrase
    the
  • 45:29 - 45:31
    question.
  • 45:31 - 45:34
    How and what changed your view of code quality.
  • 45:34 - 45:37
    Like, basically, I'm sure you want all the
    same,
  • 45:37 - 45:39
    like, five years ago, ten years ago, and you
  • 45:39 - 45:43
    now have a different perspective on things.
    What was
  • 45:43 - 45:46
    the trigger for you to help you go from,
  • 45:46 - 45:48
    follow these rules, you need to test all the
  • 45:48 - 45:50
    time, or whatever process you had in mind,
    to
  • 45:50 - 45:53
    be more flexible and understanding when to,
    well-
  • 45:53 - 45:55
    B.L.: This is going to be an awful answer.
  • 45:55 - 45:57
    I, I'm gonna tell you guys for real what
  • 45:57 - 45:59
    that is.
  • 45:59 - 46:03
    I love coding. I really do. I like cars
  • 46:03 - 46:05
    way more. And the cars that I like are
  • 46:05 - 46:08
    really, really expensive. So this is actually
    an, this
  • 46:08 - 46:11
    is actually, I'm working to be able to afford
  • 46:11 - 46:14
    nice cars, and then I'm not going to do
  • 46:14 - 46:14
    this anymore.
  • 46:14 - 46:16
    A.P.: Are you gonna live in the car?
  • 46:16 - 46:20
    B.L.: No, no no. So no, really. And you
  • 46:20 - 46:23
    know what it is? Actually, my goals are not
  • 46:23 - 46:24
    to write code. My goals are to be the
  • 46:24 - 46:27
    best that I can to what I do to
  • 46:27 - 46:30
    be able to live the life the way that
  • 46:30 - 46:31
    I want it. So, yes, being, and this is
  • 46:31 - 46:33
    why, why, I actually train, I actually practice
    writing
  • 46:33 - 46:36
    code, because I want to be really good at
  • 46:36 - 46:38
    it. And I want to be able to share
  • 46:38 - 46:39
    with other people how to be better than you
  • 46:39 - 46:39
    are.
  • 46:39 - 46:41
    I'm not saying I can tell you how to
  • 46:41 - 46:42
    be the best. I'm saying that I can tell
  • 46:42 - 46:44
    you things that I did that were not bad,
  • 46:44 - 46:47
    and if I can save you twenty minutes by,
  • 46:47 - 46:49
    please don't do this, then, then I've won.
  • 46:49 - 46:51
    M.A.: Do you justify it when you say that?
  • 46:51 - 46:51
    Do you say, or you just say, this is
  • 46:51 - 46:53
    bad code, don't do it?
  • 46:53 - 46:57
    B.L.: No. Usually I say, my god. Is that,
  • 46:57 - 47:02
    your pull request done? It can't be done.
  • 47:02 - 47:05
    M.A.: So we're running out of time. But, Bryan,
  • 47:05 - 47:08
    what was the trigger for you to, to change,
  • 47:08 - 47:10
    I mean, were you? I mean, I was like
  • 47:10 - 47:13
    that. I used to be very dogmatic about the
  • 47:13 - 47:15
    way I was working and the rules I wanted
  • 47:15 - 47:17
    to follow and something happened to me and
    I
  • 47:17 - 47:21
    kind of changed the way I looked at it.
  • 47:21 - 47:21
    Are you done?
  • 47:21 - 47:22
    B.H.: We're done?
  • 47:22 - 47:24
    M.A.: We're getting close to be done. OK.
    Can
  • 47:24 - 47:26
    you still answer the question? Please?
  • 47:26 - 47:29
    B.H.: Not, not very quickly. You know. I think
  • 47:29 - 47:31
    it's just seeing, you have to, you kind of
  • 47:31 - 47:33
    have to go through- I had to go through
  • 47:33 - 47:35
    this process of seeing failure on both sides.
    So
  • 47:35 - 47:40
    seeing failure from not applying any structure
    and not
  • 47:40 - 47:43
    revisiting things and trying to improve them,
    and then
  • 47:43 - 47:45
    seeing failure in a different form from trying
    to
  • 47:45 - 47:47
    things like - I'm sure all of us have
  • 47:47 - 47:50
    run into a project or a person who's over-applying
  • 47:50 - 47:52
    patterns. Like that, you know. I think I definitely
  • 47:52 - 47:54
    went through that phase when I frst learned
    about
  • 47:54 - 47:56
    patterns and thought everything was a nail
    that could
  • 47:56 - 47:58
    be fixed by them.
  • 47:58 - 48:00
    So once you sort of, it's like a pendulum.
  • 48:00 - 48:01
    It swings both ways. And then like you kind
  • 48:01 - 48:04
    of find the middle and that, that was I
  • 48:04 - 48:05
    guess how it happened for me.
  • 48:05 - 48:07
    M.A.: So Aaron, the question's slightly different,
    because I
  • 48:07 - 48:08
    know you still-
  • 48:08 - 48:10
    A.P.: Factory pattern. It's all you need.
  • 48:10 - 48:12
    B.L.: Composite. Delegate. Forwardable.
  • 48:12 - 48:14
    M.A.: So what would be your advice to somebody
  • 48:14 - 48:17
    who wants to improve the quality of their
    code,
  • 48:17 - 48:19
    but understand that they want to go further
    than
  • 48:19 - 48:21
    just the rules. What can they do?
  • 48:21 - 48:23
    A.P.: So, for me, personally what I did is
  • 48:23 - 48:27
    I practiced a lot. I love programming. I program
  • 48:27 - 48:29
    because, I like, my job is a programmer because
  • 48:29 - 48:30
    I love programming.
  • 48:30 - 48:32
    M.A.: Can you just explain what you mean by
  • 48:32 - 48:32
    practicing?
  • 48:32 - 48:32
    A.P.: Practicing.
  • 48:32 - 48:34
    M.A.: real quickly, like, what do you mean
    by
  • 48:34 - 48:36
    that? Do you just write code and you're the
  • 48:36 - 48:37
    only one looking at it?
  • 48:37 - 48:40
    A.P.: Hmm. A lot of time, yes. I mean,
  • 48:40 - 48:41
    a lot of time, yes, but one of the
  • 48:41 - 48:44
    main things I did is I found, so, I
  • 48:44 - 48:46
    found jobs and I started working with people
    at,
  • 48:46 - 48:49
    like, at our Ruby group, and then finally
    got
  • 48:49 - 48:52
    jobs with people. But I, I would actively
    seek
  • 48:52 - 48:55
    out people who were better than me. All the
  • 48:55 - 48:57
    time. Is what I would do. Is just, I
  • 48:57 - 48:58
    just keep trying to find someone who's better
    than
  • 48:58 - 49:00
    me and then make an effort to work with
  • 49:00 - 49:02
    that person so I can learn from them.
  • 49:02 - 49:04
    So a lot of times it's just practicing on
  • 49:04 - 49:06
    my own, but also a lot of time is
  • 49:06 - 49:08
    practicing with someone who s better than
    me.
  • 49:08 - 49:12
    M.A.: All right. Well thank you very much.
  • 49:12 - 49:19
    A.P.: Thank you.
Title:
Ruby Conf 2013 - Bad Ruby code doesn't exist
Description:

more » « less
Duration:
49:46

English subtitles

Revisions