Learnings: INTRO to the series and GETTING STARTED w/ functional programming with Ramda/Rambda
Unsplash - https://unsplash.com/photos/FzFH41IucIY

Learnings: INTRO to the series and GETTING STARTED w/ functional programming with Ramda/Rambda

I am excited to finally start sharing updates about my learning progress at the new place. Here I have been exposed to a huge new world, where there's lots of backend in frontend (BIF) code mixed with traditional modern frontend practices, and I already know I will have to ramp-up in several fronts.

My goal posting this here publicly is to force myself to develop a log of structured learnings. Sure I will probably forget most, but let me go over some of the things I will look into future posts:

  • Storybook - several interesting (and probably fairly advanced) usages
  • ???React-Redux, Redux-Saga, Redux-Thunk - This is certainly the most complex implementation I have faced so far. ???Excited!!!
  • Functional programming libraries and patterns - this one here covers RAMDA/RAMBDA
  • Server-side rendering - Intense use of Express/Hapi and related tools to make a very complex page load extremely fast
  • edit 1: TDD with Jest and Enzyme for the React ecosystem (sorry not Cypress yet).
  • edit 2: CSS-in-JS approaches, specifically emotion (https://emotion.sh/docs/introduction) (and maybe styled-components?) and a design-units (https://github.com/romanlv/design-units) (is this borrowing from atomic design concept?)
  • Node in general (can't wait to dive deeper)
  • Modern ES6 in real life - I know this might look super silly at first, but I can guarantee that using generator functions and yield is not applied everyday if you don't know what you are doing. I will be more than happy to share some of these use cases as I go over them

Functional programming

As promised, here it goes the first snippet of knowledge:

Don't forget: Immutability and side-effect free functions. This is the goal!

If we try to run a function that translates something after retrieving it, and finally stores somewhere, we might code something like saveToLocalStorage(translate(getResponse())). Can you see this is a bit convoluted?

What about we try x.pipe(getResponse(), translate(), saveToLocalStorage())?

Or maybe it was something like x.pipe(multiply(8), add(256), convertToOctal())?

Ramdas’ math functions add, multiply, and divide all take 2 parameters, but we are only passing the first parameter in, and the second value will get passed in through the pipe.

The feature that allows us to get this behaviour is called Currying.

Note 1: pipe() applies the function in the exact order showed. The inverse order would be achieved with compose().

Note 2: functions in the pipe must be unary -> meaning it takes only one argument.

Note 3: Most of my references come from here and here.

That's it for now. Thanks for reading. Let's continue on this journey later, and leave a like so I know you might be interested and supporting me.

要查看或添加评论,请登录

社区洞察

其他会员也浏览了