3 Minutes with Kent

3 Minutes with Kent

By Kent C. DoddsTechnology
Download on the App Store

3 Minutes with Kent episodes

  • The nuance of promotion, incentives, ulterior motives, and the benefit of the doubt

    Hello there friends, so I've just been thinking about incentives and

    companies and and the yeah, like what what motivates people to have
    different opinions and stuff like that. And I want to use myself as an
    example here because I think it's a there's a lot of nuance with the way
    that we kind of automatically think that people are have ulterior motives.

    So, I created epic react to teach people how to learn react. And so my

    question is did did I create epic react?And then say hey everybody it's
    React is amazing and like is my ulterior motive in telling people that
    react as awesome and they should use it so that I can sell courses or did I
    discover react and I got really excited about it and I and I just think
    that it's a fantastic way to build it web applications and so as a result
    of this I create epic reacts as well as all of my other material and stuff.

    To convince people to use it just because I think that it's a really great

    framework. And then I finance my my free work by selling.Epic React I can
    tell you that it's the latter but how do you know. You can't really trust
    my word for it because my I could have an ulterior motive.

    And I think this is the sort of thing that's really new on. So just to give

    you another example, let's say that there's somebody who's really bullish
    on a particular stock. They maybe it's Apple or something. And so, they
    they create a YouTube channel that just goes all on on and on and on about
    how great Apple is.

    Now our did they create like what order did this happen in did they create

    the channel and then they say,Wow this is a great way for me to get people
    to buy the stock. I'm gonna pump the stock up and then I'll my purchase of
    the stock will be worth a lot.

    Or is it a kind of more of a combination where they are really bullish

    about Apple so they buy a lot of stock and they're like man. I just this is
    such an awesome company. I'm also going to start this YouTube channel to
    talk about why I think it's such a you know, a great investment or
    whatever.

    So anytime you see somebody who seems to have a conflict of interest.It's a

    very very possible that that conflict of interest is the entire reason that
    their motivated to behave in the way that they're behaving or speak and say
    the things that they're saying. It's entirely possible that there's that
    bias and that's controlling everything.

    But keep in mind like kind of walk history back a little bit and and think

    okay, maybe they really have this solid conviction and that's what made it
    motivated them to go and buy the stock or what motivated them to create
    this thing and pump it up because they already had that conviction and they
    don't maybe have an ulterior motive.

    3 min
  • Smart watches, smart rings, and Progressive Web Apps

    Hey there friends. Have you heard of progressive enhancement or progressive

    web apps? Well, I thought of a real world thing that kind of resembles what
    this actually means and what it doesn't. So, you know how like there's all
    these memes of like I got a smart thermostat and now it's broken because my
    internet went down or something like that and so now I'm like steaming hot
    like why did I do this and and we have the same sort of thing with my watch
    and so I have a smartwatch.

    It's a,Nice one. It's a fossil I guess. And then I also have an aura ring

    and both of them are useful in their own different ways. But when my watch
    breaks or if it runs out of battery, which is more often, it doesn't break
    very like ever. But when it runs out of battery, I'm no longer able to even
    tell the time.

    So, it's like totally a break. It's useless as just like a break on my

    wrist. That is not great. But when my ring runs out of battery,That's also
    not great but it's still functions as a ring. And so in this context
    progressive enhancement would be like my ring will always function as a
    ring but it progressively enhances in that when it has battery it also
    functions as a way of taking my my pulse and different things like that.

    Whereas with the watch if it doesn't have power, it doesn't do anything.

    It's it's not serving its purpose at all unless I suppose if you just like
    appearing like you have a watch but it's basically.Other than that. And so
    when we're talking about progressive enhancement or progressive web apps,
    we're talking about taking advantage of the tools and capabilities of the
    web and all the modern and cool stuff but not exclusively not at the
    exclude exclusion of functionality for browsers that don't support those
    modern features.

    And so we progressively become a even more capable web app when those

    features are available. And so in my contacts with the,Watch in the ring
    that the extra feature that's available is power. And with the watch it
    doesn't progressively enhance, it just doesn't work at all without that
    extra feature of power.

    Whereas with my ring it functions as a ring just fine whether or not it has

    power and then if it does then improgressively enhances to do a lot of
    other cool things. But anyway, that's kind of what I think about
    progressive enhancement progressive web apps. It's kind of an interesting
    thought.

    And yeah, shout out to remix particular for taking this.So seriously. I

    hope that's helpful to you have a wonderful day.

    3 min
  • TypeScript is testing

    https://kcd.im/trophy

    https://kentcdodds.com/blog/eliminate-an-entire-category-of-bugs-with-a-few-simple-tools

    TypeScript is tests. Tests are type script. So type script is just a way to

    give yourself more confidence. Sure, it helps you in your workflow, it
    makes you a faster as you're developing because you have autocomplete and
    stuff like that. And testing does the same thing as well as you
    refactoring, you know that you didn't break anything you get a much faster
    feedback when you you're running your tests as you're working on things.

    And both of these also make the initial code take longer. So it takes more

    time to think.About the types that you're writing takes more time to
    actually write the tests. And they can also be an enormous time sink where
    you spend a ton of time working on a task or a ton of time working on the
    on the types and then you've later realized that you don't need that code
    at all so you just throw all that work away.

    So, I I find that typescript and testing are way more related than they are

    or similar than they are different. And I think this is a good thing
    though, the whole goal is to be more confident in the changes that
    were.Making in the application that were shipping. And the cool thing about
    TypeScript is that it eliminates an entire category of bugs.

    I actually have a blog post about that. And it also eliminates an entire

    category of tests, which you're probably not writing but maybe you should.
    So one of the things about code coverage is that it doesn't what we really
    actually need is data coverage or use case coverage because you may have a
    function called ad that accepts two numbers and add.

    S them together and you could write a couple of tests for that if you

    wanted to but you're probably not writing like it's not very normal for
    people to write a test that says what happens if I pass a string what
    happens if I pass a boolean but you know, what a you might have a test that
    says what happens if I don't pass the arguments or something and because
    there are some defaults.

    But and that and because there are defaults you're going to want to cover

    that. But we've very often don't do a whole lot of defensive programming
    and runtime and type assertions of.You know, what the arguments that were
    passed? Maybe you do that for some of your functions, but probably not all.

    And so you can you don't get a much confidence in in that aspect. And you

    you could but it's just way easier to just use a type to language like
    TypeScript and then that entire category of bugs in the entire category of
    tests don't need to be written. So type script is tests.

    3 min
  • TypeScript: Why I prefer `Array<Type>` over `Type[]`

    Good morning or afternoon or whatever it is for you friends, it's morning

    for me. I wanted to talk about how I type a raise in TypeScript, so there
    are two ways that I'm aware of that you can type an array and of course I
    guess there are a couple ways depending on what type of an array you want
    to make but just like a regular array you can either specify the type and
    then immediately thereafter with no space a open and closing bracket like
    the the syntax for an array and the alternative is there is a built-in.

    Array type which is a generic and you say array and then open bracket no

    that what are these angle brackets that's what is called an open angle
    bracket and then the type of that's in the array and then a closing angle
    bracket and I prefer the latter. I like using the generic array and the
    reason that I prefer that I I think that I just like just kind of preferred
    to that from the beginning, but I think the reason that I prefer using the
    generic array is because I don't,Like reading my type and then getting to
    the end and be like, oh this is an array of those things so I I see we've
    got um user and then I see the opening closing bracket and I say oh no,
    actually it's not a user it's an array of users, whereas if I use the
    generic I can see oh we've got an array and the things that are in the
    array are users and so I'm when I'm reading from left to right it just
    seems to make more sense to me to to read it in that way, it's kind of like
    in English it.

    I I like how in Spanish and you have the,If you have like an exclamation

    you're going to have that upset upside down exclamation point I don't know
    what that's called but you have that upside down exclamation point at the
    beginning of the sentence so you know ahead of time that the thing you're
    about to read is an exclamation rather than getting to the end of the
    sentence and being oh yeah, I'm supposed to be like excited about in saying
    this or something like that when I'm reading a book my kid or something and
    so I kind of see that in the same way and that's why I prefer using the
    generic over the the special syntax for specifying arrays, it is a little
    bit more type.

    Of being or more characters but I actually don't care too much about that

    and then that comes with the benefit of switching from a regular array to a
    read-only array, you know being a bit easier and stuff like that so anyway.
    I just thought that would be something I'd share today.

    I hope you're having a wonderful day and I'll chat with you soon.

    3 min
  • Don't bundle and minify your published npm packages

    https://twitter.com/kentcdodds/status/1394420201542668289?s=20

    So the other day I tweeted about how I really want people to stop minifying

    and bundling what they send to NPM. And just to clarify I it's fine if you
    want to minify and bundle as one of the things you distribute as part of
    your package, but it shouldn't be the only thing and there are a couple of
    reasons and what I do for my packages is I actually do have a UMD module
    that is bundled and I have a minified version of that as well.

    So we have two of those and then I've got an ESM.R version which is like

    fake ESM right now eventually I'll get around to making a native VSM
    supported version. And then a common JS and those are the the four formats
    that I shipped to NPM. So the reason that I really really don't want people
    to exclusively ship minified code is even with source maps can it can be
    really difficult to debug and especially when we're talking about libraries
    that I'm interacting with well even even transitive dependencies.

    I like to be able to.Stick a console log in there or to step through with a

    debugger and it's just really difficult to do that if you've minified your
    code and in particular what motivated me to tweet this in the first place
    was I was working with a library that minified everything and it ended up
    minifying its implementation of an abort signal and so the constructor name
    was incorrect and node fetch actually checks the constructor name to know
    if what you've passed is an abort signal which we could argue about whether
    that's necessary or not, but the fact is that it does and becauseThey were
    minifying it totally is unusable which is a less super annoying.

    So that's notification then on the bundling side of things this can get to

    be a real problem like if for example your bundling a particular library
    and I'm already using that library in my project MPM can't dedupe that and
    do means it says, oh you're using this library in this other dependency
    uses that library too.

    So we'll just have them both use the same files and therefore we don't have

    to send.That code to the browser twice so we don't have to require that
    code and evaluate it in person all that stuff. And so there are arguments
    that people make about bundling as like performance improvement so like you
    could do that with some tools and and that could be useful but it could
    also be a big problem because then I can't like change the versions of the
    things that I'm using and I don't have any control over that.

    So there are a lot of issues there in general. So, please don't bundle

    don't minify it's better this way. Let meDo that.

    3 min
  • Sharing server/client validation logic with @remix_run

    Hey friends, so I'm working on this little remix app and just something

    about remix that I just this so cool the fact that your server and client
    side code run is written in the same file if in case you didn't know that
    that's that's what you do and it's really cool for validation so you can
    start by validating just a hundred percent on the server and remix makes it
    quite nice to be able to do that and that's where your validation should
    absolutely.

    100% go by default that's like if you're gonna do it anywhere do it right

    there, but having client side validation can be nice for you know, showing
    error messages and stuff and so because the client side and silver side
    code is written in the same file, you don't want to like duplicate that
    that logic and so you just extract it to a function and then in the server
    you call that function and the client you call that function and when remix
    shakes out all of the stuff that function will appear in both places, but
    you don't have to write it twice and so.

    I'm just writing out a form right now and I had a a maximum length for a

    particular field and so I can just put that variable outside of everything
    and make sure that I only have one specific place where I say what the max
    length of this is gonna be and then I just use it in the client and in the
    server all in that same one file.

    I don't need to like put in a different module and import it or anything

    it's all just right there and I just think that's awesome that I I'd share
    that with you remix is just my friends it is something else. IFeel super
    productive working with this and yeah I the cool thing is that it's I feel
    like it's both pretty quick to get at for it to become familiar so it
    doesn't take the long for it to become easy relative to other stuff that
    I've worked with but it also seems so simple and so therefore I can build
    simple applications with it and and and and I I mean, I haven't written an
    application in a million lines of code with remix and,You think but I feel
    like this would scale well to that based on the experience I have in
    writing and working on enormous applications, so yeah anyway remakes it's
    it's awesome and I know that I gush over it but there's a reason it's not
    it's certainly not because Ryan and Michael are paying me in fact I paid
    them to be able to use it so there's there's no conflict of interest there,
    they're my friends, so they're there's a full disclosure but this thing is
    out of this world, so if you haven't taken a lucky remix yet and give a
    good look at it.

    See ya.

    3 min
  • Tests the tests by making them fail

    https://kentcdodds.com/blog/make-your-test-fail

    Hello there friends. I'm just driving now. I was thinking about a blog post

    that I wrote a while ago. I think it was called break your tests or
    something like that, but the idea is that it's just really easy to write a
    test that passes and so you feel really good about it this this especially
    happens if you're testing after you've already implemented something if
    you're doing TDD this is maybe less of a problem, but it's really easy to
    write a test that's green and we're happy with it and,So we commit it and
    we move on and then we later find out that that test wasn't running to
    completion or it was the it wasn't testing what we thought it was testing
    wasn't making the right assertions or something and so it wasn't actually
    doing what we thought it was and so then the thing that we were intending
    to test ends up breaking in that test doesn't doesn't save us from that and
    so what I suggest that you do is you take the time to actually try and make
    the thing that you're testing break, so you simulate a failure this could
    be.

    I'm pretty much like any any step of the process of what it is that you're

    testing maybe you're making a request to get some data and then you're
    displaying that data in your asserting that the data is displayed properly
    and so you could just comment out the code that updates the state or
    something like that and so it's normally very easy and it's a manual check.

    I don't think that there would be a whole lot of use in like at this point

    you're testing the tests and I don't see a whole lot of benefit and like
    how far do you go, do you test the test the test the test?It's just sorry
    cracking myself up um yeah so like at some point you have to say okay,
    we're good with just doing a manual verification of this and so that's
    that's what this is is just a manual verification that yes this is indeed
    testing what I think it is and I verified that by commenting out the
    implementation or changing the implementation and in a certain way to make
    sure that the test will catch me if I mistakenly change the implementation
    in this way, so yeah, as you're writing your test for your software, I
    suggest that you break the test and I will.

    Add a link to the blog post where I dive into this little in a little bit

    more detail at the top of the notes for this episode so you can go take a
    look at that. I hope you have a wonderful day and we will chat with you
    later bye.

    3 min
  • Cypress Driven Development for recording audio

    Friends I'm out and about today so we might hear some like music in the

    background and stuff but yeah today I wanted to talk about cypress driven
    development. I was working on something that I'm working on for the new
    website where you can submit a recording of a question and then I'll be
    able to answer it's gonna be really cool but it's all like in browser
    recording stuff and lots of what I was testing was like required me to have
    to record something and then to continue on through the the work.

    Or the flow and that was super annoying to have to you know, make a change

    and then go through that whole flow again and so I was like, well, this is
    the perfect situation for cypress different driven development so I made
    like a I don't know ten lines cypress function or or test that went through
    that I did have to do a couple fancy things to make it so that cypress
    would accept a fake wave file as input which I made a maniacal laugh and I
    found online but uh, yeah, once I had that I'll set up it was really.

    Cool every time I made a change to anything I would just have cypress rerun

    it would rerun automatically and and then I could look at the terminal
    output or the console output and get a good idea of what what was going on
    so yeah I was really it was like nail on the head for cypress driven
    development.

    I don't think that it's always necessary but especially when you're working

    on workflows and stuff and like this is the sort of thing that hot module
    replacement like yeah, maybe that work okay, but just is not going to do it
    for you.For this sort of thing like I never really trusted how much of a
    replacement and so the and this is the one situation where people say, oh
    yeah how much replacements really nice if you're like what you're working
    on is pretty far into some workflow or something that you don't want to
    have to do over and over again, well, sometimes you do need to refresh for
    one reason or another and having cypress just get me back into that state
    and like a half a second yeah that's awesome and it's like a real actual
    experience so if you've not tried cypress driven development.

    I suggest that you give it.A shot because it's really helped me be really

    productive and at the end of it. I'm I may actually be able to use this as
    a test as an actual test to keep me confident so there's that I hope that's
    interesting and helpful and useful to you and hope you have a spectacular
    day you take care and all talk to you later.

    3 min
  • The KCD Discord Bot "Thanks" command

    Hello friends So today a friend of mine on the KCD Discord is named Rupert.

    I'm not sure. I'm pretty sure that's how you say their name. But I created
    their very first poll request for open source. I wasn't aware it's the
    first poll request but they did a great job.

    And it was for the KCD Discord bond. And so the discord has a lot of cool

    things you can do with it and one of them is they're a bunch of commands
    that you can give. One of those commands is the thanks command where you
    can give somebody extra kudos to say thank you and we'll record.

    The that in a thanks channel so you can look at and see all the people

    who've received gratitude and who've given gratitude and then it will log
    that in a github gist. That's our storage mechanism for this bot. And and
    actually, I think this is the only thing that requires storage that we have
    but um, it's ends up being just this giant JSON object.

    And so we've had this for a while Marco built it initially and it was cool

    because you could say thanks ranked top and it would give you the top.10
    people who'd received the most thanks. But I wanted to also have a rank for
    the people who give the most gratitude as well because I think it's a nice
    to to have that.

    So he Rupert made the a change to also allow you to say thanks gratitude

    ranked top and that would give you the the top 10 most grateful people in
    the server. And it was just kind of a way to recognize people who are
    making our community special and and grateful thankful.

    And,Yeah, so I just kind of wanted to talk about that just a little bit and

    say, hey, you know gratitude is important and it's helpful and in fostering
    a community that I want to be a part of and hopefully you do as well. And
    by giving a just the little bit more recognition for people who are
    grateful, but also the people who are being thanked, so the people who are
    doing helpful things.

    I think goes a long way to making people more encouraged to continue to do

    helpful and,And good things and and also to be more grateful. So and
    gratitude has been scientifically proven to improve people's overall
    happiness. So if you're a grateful person, you're happier. So go be
    grateful today, and if you're a member of the KCD discord, then go say
    thanks to somebody using the Thanks command.

    And if you're not then joined because it's a cool place to hang out. All

    right. I hope you have an awesome day and we'll talk to you later.

    3 min
  • How to prepare for meetings that convince people

    So let's say that you want to convince your coworkers to try a new tech or

    something like a new library or whatever and you think it's a really good
    idea but people aren't convinced. So what typically happens is you want to
    prepare a couple of ideas and stuff and bring it to a meeting and say,
    okay, here's here's what I think and why I think this is a good idea.

    And then people will present their reasons why they they don't think it's a

    good idea. And people may come to the meeting kind of predisposed to
    disagree and and want to just say,No this is just extra work that you're
    making me do and and so as soon as somebody gives a reasonable good
    argument against you against your idea for everybody else that just is like
    the thing that they can latch on to and if you're not prepared to deal with
    that then then you just lose everything.

    So this is what I do and what I've done to convince members of my team that

    my idea is a good one. And that is first you have to like that obviously
    you have to really believe that it is a good idea and you wouldn't want to
    present something that's not necessarily a good idea.

    But then,What I have done is I will reach out to everybody who's going to

    be coming into the meeting all the decision makers, but also just the
    people who are going to show up so even people that may not be making the
    decision they just might voice a concern of some kind.

    And I will just ask them what are their preconceived issues that they have

    with this idea? And I'm just talk a little bit about it not. We're not here
    to have an argument or anything about the merits of the idea. We're just
    here to gather their hang-ups with it.

    And do that with everybody who's coming to the meeting so that you can

    prepare and bring up their arguments before they have a chance to bring
    them up and and you bring it up in such a way that you can immediately
    address it and say now some of you were worried about this, let me explain
    why that's not a problem.

    Or you may not even need to bring that up. You can just solve that problem

    before they before mentioning the problem in the first place. As part of
    your presentation, this will go miles to help you convince people that your
    idea is a good one and help alleviate concerns and they're concerned.

    The real and you need to address them But if you want to have success and

    convincing people you want to avoid the mob mentality where one person
    shares something that's like now this is not going to work for this reason
    and everybody just latches on and they won't listen to your explanation.

    And maybe you'll get caught off guard too in that situation. And so by

    asking ahead of time you are made aware of things that you may not have
    considered and you make sure you address those and it's also possible that
    you can cancel a meeting because you realize that oh actually this isn't a
    good idea because of these concerns.

    So anyway, this is something that's helped me in the past. I hope it helps

    you and I hope you.

    3 min

About 3 Minutes with Kent

From the publisher's feed

๐Ÿ‘‹ Hi there! I'm Kent C. Dodds (https://twitter.com/kentcdodds). This is a (week)daily podcast where I give 3 minute thoughts about web development.