Results 1 to 2 of 2
Thread: MDD - Mock Driven Development
- 10-06-2012, 01:26 AM #1
Member
- Join Date
- Oct 2012
- Posts
- 1
- Rep Power
- 0
MDD - Mock Driven Development
I'm a 10 year Java veteran and try to be very open to changes in the way the language is used. However, I've recently been introduced to a new pattern which I'm having trouble seeing as necessarily a good thing. I'll call this pattern Mock Driven Development (MDD).
Basically, it's a form of OO but removes any and all programming patterns which are not conducive to making any and all code mock-able in unit tests. While I'm all for mocking being used as a powerful way to simplify unit tests, basing your entire programming patterns off of the abilities of the concept of how mocking is done seems to raise my "anti-pattern" red flag.
One example is that since *most* mocking frameworks don't really support mocking static/final/private methods all that great MDD says to never use them. So what you end up with is code that looks like this:
Because having private or static methods inside your service is inherently bad, you end up instantiating and, IMO, spraying all sorts of objects around (most of which are callable). It lends itself towards a much more functional and callable way of programming. Don't get me wrong, I'm hip to the whole functional way of doing things, but to impose this kind of wide-spread development due to the initial mantra of "if it can't be mocked then don't do it" seems too dogmatic for me.Java Code:ServiceDoSomethingDelegate delegate = new ServiceDelegate() { public void delegate(...) { // do delegation } }; service.doSomething(obj, delegate);
Am I just being a cranky old fart of this, or has anyone else seen patterns emerge like this?
- 10-08-2012, 11:12 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: MDD - Mock Driven Development
Does the technique honestly say "no private methods"?
I can understand limiting static methods to fairly simple things (eg the Math class), though not entirely removing them, but private ones? Sorry, that's silly.
There is a style that does feel private methods should be unit tested, but I'm definitely not in that group, and have never worked anywhere where that applied. After all, private methods are inherently very volatile, so having unit tests for them would be a nightmare. Refactoring (it strikes me) would become a serious chore.
Having said all that, I do write stuff with a view to testing, and since I'm usually using Spring in some shape or form then that tends to be a natural result.Please do not ask for code as refusal often offends.
Similar Threads
-
Please help me with Mock Objects.
By fatabass in forum New To JavaReplies: 1Last Post: 09-12-2012, 01:27 AM -
Significanlty lower development costs in high quality development
By espeo in forum Reviews / AdvertisingReplies: 5Last Post: 04-23-2010, 06:08 PM -
develop mock ups
By karthikeyan_raju in forum NetBeansReplies: 0Last Post: 10-19-2009, 03:58 PM -
Mock exams for SCWCD 5
By Enthuware in forum Java SoftwareReplies: 3Last Post: 04-24-2009, 03:14 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks