<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lail Brown on Medium]]></title>
        <description><![CDATA[Stories by Lail Brown on Medium]]></description>
        <link>https://medium.com/@lailbrown?source=rss-7c820352f1cd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VESJFhOARvF6GtPGql8FVA.png</url>
            <title>Stories by Lail Brown on Medium</title>
            <link>https://medium.com/@lailbrown?source=rss-7c820352f1cd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 03:52:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lailbrown/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Crystal Ball Development]]></title>
            <link>https://medium.com/@lailbrown/crystal-ball-development-3815a4b5e7e8?source=rss-7c820352f1cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/3815a4b5e7e8</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[product-development]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Lail Brown]]></dc:creator>
            <pubDate>Mon, 10 Sep 2018 19:31:24 GMT</pubDate>
            <atom:updated>2019-07-18T12:54:50.470Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*52awYlsnkNAAu8HoA3S3Iw.png" /></figure><h3>Crystal Ball Application Engineering</h3><h4>The difference between understanding that problems will exist and knowing how they should be solved</h4><p>Recently, I was speaking with a developer/friend who reminded me of a challenge that we’ve both witnessed in others and deal with ourselves during product development, planning, and design. I’d like to call it crystal ball development.</p><p>It’s a fancy name for what essentially comes down to trying to solve your problems too soon.</p><p>When we’re being nice about this, we might call this <em>pre</em>factoring — simply trying to set ourselves up for success later on down the road. And of course, this makes sense — up to a point. I’m talking about over-engineering, or even guessing your way down the product roadmap too early on.</p><p>Id like to take this opportunity to remind you just how easily software development can go off track, especially early on when every choice you’re making could have huge ramifications over the lifetime of the product. It really boils down to making decisions you don’t need to make, based on information you don’t have yet. <em>That’s a bad idea.</em></p><h4>Example time</h4><p>Once upon a time I worked at a startup with a product that included only a handful of essential user interactions. Among those was an absolutely core interaction of building up a large body of content within the app. We correctly identified this as a top priority going in, and built appropriate tools to aid our users. Queue golf-clap.</p><p>In those early days we also saw a problem just over the horizon. Our future successful user was going to have a huge library of content, and eventually they were going to need power-tools to wrangle all that stuff. This was a pretty safe bet. Users were going to ask for it. It was just a matter of time.</p><p>So, like he clever folks that we were, we build those tools. Within a few dedicated weeks we shipped the best cross-content editor we could imagine, one that allowed users to make all sorts of changes to multiple items at once. It was really cool, and was sure to solve a whole category of user problems just down the road.</p><p>The truth however, was that we severely jumped the gun and shot ourselves in the foot in at least two ways. So let’s say we shot ourselves in two feet. Ouch.</p><h4>Oops 1: Our users didn’t need it yet</h4><p>As an engineer or designer, launching a cool feature feels great. What doesn’t feel great is deploying to production, opening up your metrics dashboard to watch the early numbers come in and seeing tumbleweeds. Nothing. Nada.</p><p>In our example case, our users would catch up and eventually go in search of a solution to their content wrangling problems. When they did, they found the tool we’d built in anticipation of the moment, and they learned to use what we’d built for them. It mostly worked. I mean, we’ve done this before — we’re pros, and really good guessers.</p><p>But oops, we missed some truths about what the customers actually needed. We hadn’t done any real user research because we couldn’t. There hadn’t been any users that were experiencing the problem that we could have asked.</p><p>Once our users had caught up to us, we heard about how the tools we’d built weren’t quite right. If we’d change it, tweak it just a bit, it could be perfect. We’d already provided our opinion on the solution, everything the users asked for was framed in that context. Some key assumptions were now baked in to the initial solution that could never be exorcized without pressing reset for our users who had taken the time to learn the tool we’d built.</p><h4>Oops 2: We built it all wrong</h4><p>The second problem turned out to be more mechanical in nature, but no less harmful to the product and to the business. We built our feature with the best tools we had on hand at the moment. We were still just coming out of MVP mode, and hadn’t found our perfect long-term tech stack that was going to make living with the software manageable over the long haul.</p><p>So the features were built with code that was hard to maintain and even harder to iterate against. If we’d waited six months, all of those engineering choices could have been made in a better context, and an eventual refactor could have been avoided. As a developer, if you’ve ever found yourself hitting commit on a line of code without believing somebody was going to need to use this as soon as it’s deployed, something has gone wrong.</p><h4>The cure that kills</h4><p>It seems harsh to say that in six months any solution you come up with today would be almost as likely to hurt as it would be to help. That may be the overly pessimistic take, but that is the risk and the stakes of the bet you are making. The only thing worse than a bad legacy system is a bad legacy system that didn’t need to exist but is now core to your business.</p><p>It’s key to remember that every line of code you write not only expands what your software can do, but it also solidifies your restraints. It’s a constant trade-off that’s always worth keeping in mind when evaluating whether or not to begin work on that next PR. If you wait to write code when you are ready to directly solve a problem you are currently experiencing, you’ll be much more likely to come out ahead in the deal.</p><p>Counterintuitively, we don’t get better at this simply because we become better developers. I believe we may get <em>worse</em>. That’s because we understand the types of problems that are likely to arise. We’ve been bitten by these prospective issues in past projects, and the pain lingers. We’re the ones with incentive to try to guess what our problems will be this time and take measures to circumvent the situation. How might we go about making our lives easier this go around? How can we save ourselves hours and days and weeks of lost work if we just accurately place tomorrow’s bets today? All of that is a pressure that builds as we progress through our craft, not one that retreats as we gain experience.</p><p>I’m not arguing that you need to wait until the last possible moment to commit to any choice that affects your product development or that you need to have perfect knowledge of every variable going in. Life is rarely that simple. But we all need to be aware of the risks we introduce when we make a commitment, and that we consistently ask ourselves if we need to make any given choice right now, and err on the side of not committing solutions to problems we don’t actually have.</p><p>It may sound like I’m arguing against a “default to action” mindset, that I’m arguing for a procrastination culture. I’m not. I’m only saying this: <strong>make sure you are defaulting to the right action</strong>. Part of that means stop gazing into the crystal ball and take a look around at what is happening right now, and prioritize solving those issues you are best equipped to address today. Those shiny problems will come for you eventually, ready for you to weave your magic. Or better yet, they won’t.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3815a4b5e7e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reactjs: Class Components and Functional Components]]></title>
            <link>https://medium.com/@lailbrown/reactjs-class-components-and-functional-components-5f00edbd5d92?source=rss-7c820352f1cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f00edbd5d92</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Lail Brown]]></dc:creator>
            <pubDate>Fri, 03 Mar 2017 20:08:01 GMT</pubDate>
            <atom:updated>2019-03-11T16:29:10.176Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b8iZKtlDRxMUMKQHyO2bFg.png" /></figure><p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p><p>UPDATE: This article was written before React 16.8 and the release of hooks. I’m choosing to leave the article live in hopes it can help those working with legacy code, or anybody who just wants a primer contrasting the basics of class-based and functional components. I’m not going to write my own intro to hooks as there are already several great rundowns by others, and the <a href="https://reactjs.org/docs/hooks-intro.html">official docs</a> are great.— LB</p><p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p><p>Anyone who spends time studying React code examples from around the web will quickly face several ways to define components. Knowing the difference between each and when to use one versus the other is not always obvious at first, so let’s take a quick look at class components and functional components, and the various ways they are created.</p><h3>Class Components</h3><p>If you’ve been running with React since the olden days (well, 2015-ish), this may be the component format you are most immediately familiar with. Using React’s <em>createClass</em> factory method, a literal is passed in defining the methods of your new component. The only required method is <em>render</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a91f4598f0f9b113cbf3bc6bace52ab6/href">https://medium.com/media/a91f4598f0f9b113cbf3bc6bace52ab6/href</a></iframe><p>Easy-peasy, and with its own unique benefits to boot, but arguably more “secret sauce” than any of the other techniques we’ll explore. The good news is that you could live your life using just this format. The bad news is that, increasingly, that’s a sub-optimal choice.</p><p>Along with the rise of ES6, React v0.13 introduced a new way to define class components that leveraged the new <em>class</em> keyword and module syntax. This reinforces the “React is just javascript” message that was somewhat obscured with the factory approach. The modern, ES6 pattern looks something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/169dd76d907287c1fe95ff2c8ffa83ad/href">https://medium.com/media/169dd76d907287c1fe95ff2c8ffa83ad/href</a></iframe><h4>How they’re similar</h4><p>All told, these two styles of creating components result in fairly equivalent returns (we’ll get to the differences in a minute). While the render function in the examples above is the only required method in both cases, because these components are classes, we are free to include other methods within our class object: both our own arbitrary functions (think <em>handleClick</em>, or <em>formatText</em>) and a handful that are given special significance. It’s probably fair to say that the most important of these special methods are the lifecycle functions, such as <em>componentWillMount</em>, <em>componentDidUpdate</em> and their brethren. The <a href="https://facebook.github.io/react/docs/react-component.html#the-component-lifecycle">React docs</a> give a great overview of the entire family, but all told the lifecycle methods allow us plenty of ways to tie our own behavior into each of the steps our component will pass through when being rendered, updated and removed.</p><p>The other headline feature of class components is that they are capable of maintaining their own internal state. If you are working with Flux/Redux, you might eschew this option in favor of an outside store to hold your application state. However, for vanilla React apps or in specific cases, it can still be useful to let state be maintained within the component context where it’s used.</p><h4>How they’re different</h4><p>But these two methods of creating class components aren’t entirely equivalent. In the move toward a more standard approach, the ES6 class based method gives up a couple of niceties that were packed into classes generated with <em>React.createClass</em>.</p><p>Let’s take a look at how you might find yourself setting up your class in each of the two approaches:</p><h4>Using the React Factory Method</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/357b713b3f2f9f698306fb9385502362/href">https://medium.com/media/357b713b3f2f9f698306fb9385502362/href</a></iframe><h4>Extending the React Component Class</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d580466126bcc6b118f99a6a516eb9d/href">https://medium.com/media/5d580466126bcc6b118f99a6a516eb9d/href</a></iframe><p>Most immediately, there is a significant difference when it comes to defining state and default props. The first example, built with the <em>createClass</em> factory, comes with handy <em>getInitialState</em> and <em>getDefaultProps</em> methods that simply require objects to be returned that will then be available elsewhere within the class as <em>this.state</em> and <em>this.props</em>.</p><p>On the other hand, things get a little more interesting in the second example, built as an ES6 class. First we have our initial state, which is an assignment within a constructor function. That’s a bit different, but not a particularly thorny change. Slightly more onerous are your default props, which are now defined via a <em>defaultProps</em> attribute. Though you’ve <a href="https://github.com/facebook/react/issues/3725">got a few options</a> if you are rolling ES7, the most common pattern is to assign <em>defaultProps</em> outside of your class. If you are setting up <em>propTypes</em>, you’ll find the same differences apply there as well.</p><p>There are other important changes that are demonstrated in the constructor function in the second example. The first is the call to <em>super(props)</em>, which passes your incoming props up the inheritance chain and calls the constructor of the parent Component class. Calling super in the constructor is important, as you’re overwriting the inherited constructor with your own when you add your setup. Passing props is a best practice because it makes props available elsewhere in the constructor, though it <a href="https://discuss.reactjs.org/t/should-we-include-the-props-parameter-to-class-constructors-when-declaring-components-using-es6-classes/2781">isn’t strictly needed</a> if you aren’t touching props until later in your class. Still, it’s easy to miss if you or another developer are adding to your constructor later, so it’s good practice to consistently provide props.</p><p>To round out the example constructor, we set our <em>myFunction</em> to bind <em>this</em>, ensuring that the context can be accessed in the method we’ve defined. Context management in javascript is something that no sane person enjoys, and the good news is that React largely handles it for us when it comes to methods it knows about, like the lifecycle methods. When setting your own methods, it still requires a nudge, and so we set it up from the constructor, using <em>.bind(this)</em>. Speaking of the lifecycle methods, we’ve ignored them here in our examples for sake of simplicity and because setting them up isn’t substantively different between the two approaches.</p><p>Class components give you a lot of room to tap into the magic of React and build upon the framework it provides. But they aren’t the best choice for every situation. With great power comes greater complexity, and so sometimes it’s appropriate to reach for something a bit more svelte.</p><h4>Functional Components</h4><p>React 0.14 delivered a new shorthand for creating simple stateless components. These are often known as Functional Components because they’re just regular old pure javascript functions that return React elements. In its simplest form, a functional component looks like</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee2cf58b6d673a30c4f1c13dba3ae85e/href">https://medium.com/media/ee2cf58b6d673a30c4f1c13dba3ae85e/href</a></iframe><p>This is beautifully compact and “pure” in the sense that the same input always yields the same output. A component formated like this cuts much of the cruft associated with class components, and in this form can rely on implicit return, cutting the whole thing down to just a few lines. There is a slightly beefier version that defines <em>return</em> explicitly and allows you to add your own arbitrary methods:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc4cf4b8e791c28b92a49dae01fb42d0/href">https://medium.com/media/bc4cf4b8e791c28b92a49dae01fb42d0/href</a></iframe><p>However, this terseness comes at a cost. This function will be consumed and rendered by React, but it’s not constructed with or extended from React, and therefore doesn’t get to inherit all of goodies of a React class component that we’re used to. Functional components lack the ability to maintain their own state, and they get none of React’s lifecycle methods.</p><p>This, of course, means that functional components aren’t appropriate for every use case. However, it’s often worth examining how you are architecting a growing React project so that you can use as many functional components as possible. Even in existing apps, it’s often possible to start at the tips of the “branches” of your component tree and work backwards treating many components as purely presentational and moving logic toward the center.</p><h4>And the winner is! Well, That depends…</h4><p>Now that we’ve seen the available formats that your React components can take, which format should you use? There is no simple answer that can be applied 100% of the time. Like any other situation, generally less code wins. That would point us toward functional components, and when you can get by without state and lifecycle, functional components should be the first format you reach for. Not only is the “signal to noise” ratio better when looking at functional components, organizing your React app to use functional components generally discourages antipatterns, like holding state in too many places at once.</p><p>But of course, it’s never that easy, and there are still many cases where class component remain appropriate. I find it’s often best to start new components as simple implicit functional components and then “upgrade” them as needed.</p><p>Once a component is ready to graduate into a full-fledged class component, I would suggest reaching for the ES6 class format rather than the older <em>createClass</em> format. <a href="https://facebook.github.io/react/blog/2015/03/10/react-v0.13.html">Facebook has stated</a> that they plan to eventually deprecate the old format.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f00edbd5d92" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>