Classes are not the problem. I would focus on the methods, do they behave like pure functions? Refactor those that don't.
For new projects you might want to start making a dedicated space where you have all your pure functions. The idea here is that you have a place where everything is pure and nice, and another where you can bend the rules a little bit.
I'm a self-taught dev focused on websites and Python development.
My friends call me the "Data Genie".
When I get bored, I find tech to read about, write about and build things with.
Thanks, good point. Refactoring the methods that do too much and are hard to test will help achieve some of my FP goal while still using classes.
My concern is that I will fall into OOP thinking and pitfalls by using classes, so am hoping to change the mindset for new projects.
One of the bad things I've about OOP is developers tend to put way too many methods on a class it makes sense conceptually to put the methods for updating employee and representing employee in the same class. But these are separate responsibilities and so should be in different modules and also should not depend on each other and should rather be dumb - just processing data they get.
I like the idea of pure functions in one section and less pure in another. Like where the IO gets handled.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Classes are not the problem. I would focus on the methods, do they behave like pure functions? Refactor those that don't.
For new projects you might want to start making a dedicated space where you have all your pure functions. The idea here is that you have a place where everything is pure and nice, and another where you can bend the rules a little bit.
Thanks, good point. Refactoring the methods that do too much and are hard to test will help achieve some of my FP goal while still using classes.
My concern is that I will fall into OOP thinking and pitfalls by using classes, so am hoping to change the mindset for new projects.
One of the bad things I've about OOP is developers tend to put way too many methods on a class it makes sense conceptually to put the methods for updating employee and representing employee in the same class. But these are separate responsibilities and so should be in different modules and also should not depend on each other and should rather be dumb - just processing data they get.
I like the idea of pure functions in one section and less pure in another. Like where the IO gets handled.