• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jess and Mock Objects

 
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ernest , I think I've got a reason for starting using Jess.
Mock objects in Test Driven Development.Well, it is a bit simpler than using EJBs and Aspects. What do you or anyone else think of this idea ?
My only concern is that one might end up scripting and not thinking OO first.
regards
[ September 05, 2003: Message edited by: HS Thomas ]
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you clarify a bit more what you are suggesting? I can't immediately see much overlap between Jess and mock objects. Are you suggesting using mock objects to aid Jess development, or somehow suggesting using Jess to aid mock object development?
Baffled
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Frank.
Well, the latter.


Mock Object - How do you test an object that relies on an expensive or complicated resource. Create a fake version of the resource that answers constants.
Databases are expensive to start ,difficult to keep clean and ....
Mock Objects encourage you down the path of carefully considering the viability of every object , reducing the coupling in your designs....
What if the Mock Object doesn't really behave like the real object ?
You can reduce this strategy by having a set of tests to be applied to the real object.

from Kent Beck's TDD.


Jess is also a powerful Java scripting environment, from which you can create Java objects and call Java methods without compiling any Java code.

from Jess , the Rule Engine for the JavaTM Platform.
An additional saving on resources,wouldn't you agree ?
Anyway, it could be useful if you don't have a fully-formed database to begin with.

regards
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually , another concern is that I may end up designing for a Rules Engine when the intention wasn't to do so.
regards
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it's an interesting idea. If you needed a mock object with fairly complex behavior -- or one whose behavior changes for each test method -- then I can see where implementing mocks using Jess could be useful. I think it might be more useful for mocking up a whole subsystem, with different failure modes, say, to have something with enough complexity. But anyway, yes, I suppose it could be a handy way of creating scriptable, "smart" mock objects. Although I do all my development test-first, this isn't something I've ever tried!
[ September 05, 2003: Message edited by: Ernest Friedman-Hill ]
 
Frank Carver
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It does sound somewhat of a heavyweight approach, to me at least.
I fear that the effort in creating and configuring a mock subsystem using someting like Jess might be better spent refactoring the application not to need such complex mock behaviour in the first place.
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If there's a bottle-neck to using a common database , a team may prefer to use mock objects to sort out the design first. Something along the lines of having individual databases, but with the power of using objects instead. It depends on the application , of course. A data-driven design may be better off using databases. A responsibility-driven or OO design may be better off using mock objects.
I just thought as Jess uses less resources and therefore the test-driven design flows more smoothly.
Refactoring ? Hmmm . It's all in the head ,really isn't it, once you understand the process. I imagine even a script can be refactored.
Can't it ?
And is complexity bad, always? Once someone gets their head round the complex design ( in small doses mind you) it may be clear as mud. And you won't want any Tom, Dick or Harriet to alter the complexity and then let it all fall apart.
Why do a complex problem in 20 simple classes when a few classes contains the complexity rather well. A problem made too simple by breaking it down into too many smaller steps and the whole point is lost. As someone pointed out to me in Programming Diversions - N players need N-1 matches- sufficed rather well.
Jess and Mock Objects are worth a try together, I think.

regards
[ September 05, 2003: Message edited by: HS Thomas ]
 
Do not threaten THIS beaver! Not even with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic