How to reduce the cognitive load of your code – CODE & BLOG. Low bug count, good performance, easy modification.
Clean code is high-impact, and is perhaps the main reason behind the existence of the proverbial 10x developer. And yet, despite it’s importance, it eludes new developers. Literature on the subject usually amounts to disconnected collections of tips. How can a new developer just memorize all that stuff? “Clean Code“, the greatest exponent in this matter, is 960 pages long! I believe it’s possible to construct a simple mental framework that can be used with any language or library and which will lead to good quality code by default. Keep your personal quirks out of it You read some article which blows your mind with new tricks. The problem is that people just want to fix their bugs and move on.
Don’t personalize your work in ways that would require explanations. Don’t code “your way”. Divide and conquer it Complex code can often be clarified through modularization, and there are more ways to do this than just creating more functions. // Is this a good comment? The best code is highly readable.
Code is read hundreds of time, but written once. We all know this! So we document our code. We write short blurbs at the line, method, class, package, application levels. But there's a fine line between useful and useless comments. Stop documenting getters / setters. Object-Oriented Programming is Bad. Joe Duffy - The Error Model. Midori was written in an ahead-of-time compiled, type-safe language based on C#.
Aside from our microkernel, the whole system was written in it, including drivers, the domain kernel, and all user code. I’ve hinted at a few things along the way and now it’s time to address them head-on. The entire language is a huge space to cover and will take a series of posts. First up? The Error Model. The basic question an Error Model seeks to answer is: how do “errors” get communicated to programmers and users of the system? One of the biggest challenges in answering this question turns out to be defining what an error actually is.
9 Anti-Patterns Every Programmer Should Be Aware Of. A healthy dose of self-criticism is fundamental to professional and personal growth.
When it comes to programming, this sense of self-criticism requires the ability to detect unproductive or counter-productive patterns in designs, code, processes, and behaviour. This is why a knowledge of anti-patterns is very useful for any programmer. This article is a discussion of anti-patterns that I have found to be recurring, ordered roughly based on how often I have come across them, and how long it took to undo the damage they caused. Some of the anti-patterns discussed have elements in common with cognitive biases, or are directly caused by them. Links to relevant cognitive biases are provided as we go along in the article. And before starting, let's remember that dogmatic thinking stunts growth and innovation so consider the list as a set of guidelines and not written-in-stone rules. 1 Premature Optimization.
Application Architecture for Building User Interfaces. Flux is the application architecture that Facebook uses for building client-side web applications.
It complements React's composable view components by utilizing a unidirectional data flow. It's more of a pattern rather than a formal framework, and you can start using Flux immediately without a lot of new code. Flux applications have three major parts: the dispatcher, the stores, and the views (React components). These should not be confused with Model-View-Controller. Controllers do exist in a Flux application, but they are controller-views — views often found at the top of the hierarchy that retrieve data from the stores and pass this data down to their children.
Flux eschews MVC in favor of a unidirectional data flow. We originally set out to deal correctly with derived data: for example, we wanted to show an unread count for message threads while another view showed a list of threads, with the unread ones highlighted. Why composition is often better than inheritance. An important question in code structure is whether to make classes work together through composition or inheritance.
The "has a" relationship versus the "is a" relationship. Object-Oriented Programming: A Disaster Story. [Edit: I’ve greatly expanded on these ideas in a 45 min. video.]
Over my whole programming experience, I've gone back and forth on the question of object-oriented programming, yay or nay. In this last year, though, I've finally settled conclusively in the nay column, and this is my attempt to articulate exactly why. Functors, Applicative Functors and Monoids - Learn You a Haskell for Great Good! Haskell's combination of purity, higher order functions, parameterized algebraic data types, and typeclasses allows us to implement polymorphism on a much higher level than possible in other languages.
We don't have to think about types belonging to a big hierarchy of types. Instead, we think about what the types can act like and then connect them with the appropriate typeclasses. An Int can act like a lot of things. It can act like an equatable thing, like an ordered thing, like an enumerable thing, etc. Typeclasses are open, which means that we can define our own data type, think about what it can act like and connect it with the typeclasses that define its behaviors. Functors redux We've already talked about functors in their own little section.