Paradigmas no JavaScript #90
Replies: 4 comments
-
@enieber, você não precisa escolher entre um paradigma ou outro, você pode e deve escrever seus plugins, classes e sua arquitetura utilizando orientação a objetos e utilizar aspectos funcionais para trabalhar com iterações e transformações de forma mais eficiente e mais clara. Gosto muito de estruturar serviços que consomem |
Beta Was this translation helpful? Give feedback.
-
O poder do JavaScript está aí, em ser multiparadigma e permitir com que você trabalhe com todos, dependendo do seu problema. Além de POO, temos o pattern de composição, que se baseia do esquema de "duck typing" e é bastante defendido por Eric Elliot nos posts do JavaScript Scene, no Medium. |
Beta Was this translation helpful? Give feedback.
-
@enieber acho que o grande caminho aí é procurar entender os paradigmas de programação numa perspectiva mais científica mesmo, pra depois entender como um ou outro te ajudam a resolver problemas do cotidiano do front-end de uma ou outra forma, bem como suas implicações. Mas sendo aqui um pouco mais pragmático, acho essencial compreender os conceitos de herança prototipal e como eles se comparam às formas clássicas de herança de objetos (também é uma boa dar uma estudada em como herança clássica tem sido abordada pela comunidade javascript). O Eric Elliot tem bons posts relacionados no Medium, como o @danguilherme já linkou. Recomendo os que tratam do que ele chama de "Os 2 pilares do javascript". Também acho legal a série "Javascript Objects" do David Walsh. Com relação à programação funcional, eu vejo muita gente abordando o paradigma de forma superficial no JS. Acho que o caminho aqui talvez seja ir além do map/reduce e compreender o paradigma funcional de forma mais completa. Eu, particularmente, resolvi me aprofundar um pouco mais em programação funcional à partir do aprendizado de uma linguagem de programação puramente funcional (escolhi Haskell). Me parece que só assim você consegue deixar de pensar apenas em sintaxe funcional pra absorver um pouco mais do pensamento e da filosofia por trás. Ainda assim, se tu não quiser sair do universo javascript, eu recomendo o Functional JavaScript: Introducing Functional Programming with Underscore.js. |
Beta Was this translation helpful? Give feedback.
-
@enieber acredito pessoalmente que nenhuma ferramenta seja melhor que outra. Apenas que uma delas vai ser mais adequada a uma situação especifica do que as outras, ou até mesmo que devam ser combinadas. E esse me parece ser bem o caso, já que em JavaScript podemos coexistir traços de OOP com FP. Um exemplo bem cotidiano de um traço forte da FP no JavaScript é o próprio Programar orientado a objeto pode parecer complexo e sem muito sentido no começo, mas depois que entendemos os conceitos básicos de classe e herança podemos avançar para os Design Patterns de POO e aí as coisas começam a ficar mais objetivas, na minha opinião. Sobre funcional, esse link me ajudou bastante a entender como funciona "por debaixo dos panos" e o que podemos fazer com ela http://reactivex.io/learnrx/. O primeiros exercícios são ótimos! |
Beta Was this translation helpful? Give feedback.
-
Pessoal, comecei a estudar programação orientada a objetos e acabei não vendo um porque de se utilizar o paradigma OOP no front end. Achei um pouco complexo.
Quando assisti a palestra do Andre Staltz falando de FP consegui entender melhor a pegada do Functional Programming.
Com o surgimento de inumeras ferramentas front end para se trabalhar com o paradigma funcional fiquei na duvida de como começar a utiliza lo no dia a dia.
Minha duvida maior é, usar OOP ou FP no Front end?
Beta Was this translation helpful? Give feedback.
All reactions