Yet another time it comes up. But now, after functional programming being commonplace, we at least know the answer to the "why" question. Consider the "classical OOP" method signature: email.send() vs "the anemic way" emailSender.send(message: Email) If there is only one way to send email (SMTP), things works fine. But let's assume we have to implement another way (e.g. Mailgun API). In the "anemic" case everything i…
> Which changes Email::send signature, which leads to breaking API changes and extensive manual refactoring of the entire codebase. Only if you decide to change the signature, there are other ways to achieve the same result.
Your DI framework is killing your code
11–20 of 59 posts
Re: Your DI framework is killing your code
#12Yet another time it comes up. But now, after functional programming being commonplace, we at least know the answer to the "why" question. Consider the "classical OOP" method signature: email.send() vs "the anemic way" emailSender.send(message: Email) If there is only one way to send email (SMTP), things works fine. But let's assume we have to implement another way (e.g. Mailgun API). In the "anemic" case everything i…
Re: Your DI framework is killing your code
#13I can't help but disagree with so many of the things he says. I won't even go into things like "Does your customer know what an OrderPriceStrategyFactory is for? No, then it’s not a real thing. Its some bullshit you made up.", but statements like "If we change how we contact customers then only the customer needs to change, not also the ReportBuilder" sound overly simplistic to me. The whole point would be that nothi…
If you're trying to model the inner workings of a business, you probably don't want to be starting with the customer's view of it...
Re: Your DI framework is killing your code
#14Earlier quoted context omitted.
> Which changes Email::send signature, which leads to breaking API changes and extensive manual refactoring of the entire codebase. Only if you decide to change the signature, there are other ways to achieve the same result.
For example?
Re: Your DI framework is killing your code
#15Earlier quoted context omitted.
> Which changes Email::send signature, which leads to breaking API changes and extensive manual refactoring of the entire codebase. Only if you decide to change the signature, there are other ways to achieve the same result.
For example?
Re: Your DI framework is killing your code
#16Earlier quoted context omitted.
> Which changes Email::send signature, which leads to breaking API changes and extensive manual refactoring of the entire codebase. Only if you decide to change the signature, there are other ways to achieve the same result.
For example?
Re: Your DI framework is killing your code
#17Says who?
I say the point of good OO design is to have very clear focused responsibilities for classes, very clear layers of abstraction, and concretely declared dependencies.
This way I know my business logic doesn't sprawl, is discoverable, can be replaced modularly, and tested extensively and throughly.
This author sounds like he has no idea what it takes to actually build a maintainable code base of domain-driven business logic.
The fact that he actually thinks "Order.SubmitForPicking(), UserAccount.UpdatePostalAddress(), and Basket.CalculatePriceIncludingTaxes()" are examples of good OO design is LAUGHABLE. This approach couples your data layer with your business logic, negates the ability to use mocks, and makes refactoring WAY harder than it needs to be.
Re: Your DI framework is killing your code
#18"One of the properties of good OO design is that code that operates on data is located close to the data." Says who? I say the point of good OO design is to have very clear focused responsibilities for classes, very clear layers of abstraction, and concretely declared dependencies. This way I know my business logic doesn't sprawl, is discoverable, can be replaced modularly, and tested extensively and throughly. This…
On the other hand, I'm not sure the perspective is quite as important as it used to be. Modern dynamic languages make it harder to do bad things in memory, and passing value objects around is pretty much the arterial life force of the entire Internet. In any case one thing is sure: the more pieces of code that know the internal structure of a bit of data the more dependencies there are, and the harder the program is to work on. So to the extent you can have that knowledge in one place - the implementation of an interface - you're better off.
Perhaps more importantly, OO purism just seems a little anachronistic to me today. I think the key things that OO had to teach us have been mostly absorbed, and we've moved on. It's still there, but now it's part of the fabric of the art and not as obtrusive as it was in the 90's.
Re: Your DI framework is killing your code
#19Yet another time it comes up. But now, after functional programming being commonplace, we at least know the answer to the "why" question. Consider the "classical OOP" method signature: email.send() vs "the anemic way" emailSender.send(message: Email) If there is only one way to send email (SMTP), things works fine. But let's assume we have to implement another way (e.g. Mailgun API). In the "anemic" case everything i…
With currying, you do away with OO and parameter initialization altogether.
@curry
def SMTPSender(host, message):
...
emailSender = SMTPSender(host='localhost')
# partially evaluated fn with `host` fixed
emailSender(message=message)Re: Your DI framework is killing your code
#20Earlier quoted context omitted.
For example?
"GetMailPolicySingleton()->SetSendingMechanism(Email::SMTP)" ;)