Do everything in Java…

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Sun Dec 7 05:47:08 PST 2014


On Saturday, 6 December 2014 at 07:56:48 UTC, Paulo Pinto wrote:
> On Saturday, 6 December 2014 at 01:53:03 UTC, Rikki Cattermole 
> wrote:
>> On 6/12/2014 5:45 a.m., Dicebot wrote:
>>> In my opinion OOP is very unfriendly for testing as a 
>>> paradigm in
>>> general. The very necessity to create mocks is usually an 
>>> alarm.
>>
>> I really need to start saving quotes. This is definitely a 
>> keeper!
>
> Except that in procedural code that option doesn't even exist, 
> so no testing without going to the network.

Not really. In procedural code you don't have that much coupling 
between data and behaviour which makes creating "mocks" as easy 
as filling the struct instance fields and passing it as an 
argument.

However I was not speaking about plain procedural/imperative 
paradigm as better alternative but functional and generic ones. 
First one helps with eliminating state in general. Second one 
allows to use the very same mocks in much more light-weight way 
because no runtime binding is necessary - no dependency injection 
stuff and unnecessary interfaces, just using stub policy is 
enough.


More information about the Digitalmars-d mailing list