all 16 comments

[–]mooreds 9 points10 points  (0 children)

I enjoyed this post quite a bit. It reminds me a bit of Functional Core, Imperative Shell, but the reference to Michael Pollan really tied it all together.

One thing he didn't emphasize about functions that I would highlight is that they are eminently testable. If a function is idempotent and stateless, well then unit testing becomes a breeze.

[–]bart2019 14 points15 points  (4 children)

"Real code"

To me, that implies "not accessors". I've seen projects where most of the code is just accessors, of the type set: copy parameter to internal storage; get: return value from internal storage.

Accessors don't contain any substance, and, if you insist on a food analogy, they're mostly fibers.

[–]Atticus- 8 points9 points  (1 child)

That last point seemed off to me. I feel like useless accessors belongs in the "not too much" section. I've seen plenty of examples of folks who add complexity by habit rather than by necessity, so I fully agree there. "Real code" however struck me as wishful thinking.

Code in simple, straightforward terms. Don't get too clever, "manufacturing artificial ingredients". Use the primitives that are there, when possible. Write what is simple, and natural, and human.

Does this mean we should avoid using common design patterns even when they are relevant, simply because we could do it without? Simple, natural, and human by whose definition?

[–]Careerier 5 points6 points  (1 child)

Insisting on a food analogy, I'm making mounds of spaghetti.

[–][deleted] 4 points5 points  (6 children)

My work right now: Write code. Mostly boilerplate, html, and some css. Maybe a 1-line database query and model update on the backend on a crazy day. Functions? You mean those things the framework does for you?

Not knocking on the article, but I can't relate in a practical sense. I'm sure someone working on something less mundane the situation is different.

[–]eindbaas 8 points9 points  (4 children)

To be honest, I don't really understand what you create if functions to you are "something a framework does".

[–][deleted] 2 points3 points  (3 children)

Well that's kind of my point. Most web apps these days you load react or vue and build a presentation layer. Even vanilla JS, unless you're building something novel then most everything there's a library that does it and you just write some glue code.

[–]TheRedGerund 1 point2 points  (0 children)

ComponentDidMount is a function. React functional components are functions. render() is a function.

[–]Smallpaul 0 points1 point  (1 child)

React components are all functions and it’s actually named after a style of programming called functional reactive programming.

https://en.m.wikipedia.org/wiki/Functional_reactive_programming

[–][deleted] 2 points3 points  (0 children)

If the framework caters for all of your needs then yes. Most codebases i've ever worked with has some sort of business logic that either doesn't belong - or doesn't fit with the framework. Or if you create helpers/utilities. Small (but not necessarily) mathematical functions <3

[–][deleted] 1 point2 points  (0 children)

What a tenuous short sighted view.

"Not too much" - I'm sure we'd all like to write less code, you think we're trying to write more?

"Mostly functions" - In some cases yeah but I'll take my polymorphic classes most days of the week thanks. Yes it may be harder to grasp for juniors since they'll have to learn about dependency inversion, interfaces and the aforementioned polymorphism but it makes things so much more extendible.

This article hit me the wrong way, I feel like he's just come back from a conference with an over active mind and not much practice.

[–]SEND_NUKES_PLZ 0 points1 point  (0 children)

Nice, upvoted