Java tips, observations, bugs and problems from the world of Spring, Weblogic, Oracle, MySQL and many other technologies...
Showing posts with label Tell Don't Ask. Show all posts
Showing posts with label Tell Don't Ask. Show all posts
Tuesday, 13 March 2012
Disassembling Tell Don't Ask
In my last blog I defined Tell Don’t Ask (TDA) using a simple shopping cart example. In it the shopping cart was responsible for working out the total cost of the items in the cart as opposed to the client asking for a list of items and then calculating the total cost itself. The TDA example is shown below:
Thursday, 8 March 2012
Defining Tell Don't Ask... well almost...
I’ve been wanting to write about ‘Tell Don’t Ask’ for some time now, mainly because it’s often espoused as the ‘right’ way to design a program and I've seen lots of Java code that doesn't use it. ‘Tell Don’t Ask’ isn’t a new idea, it’s been around for some time under other guises: in the OO world I’ve seen it called “Objects Do Things” and a long time ago when I was a Windows SDK C++ programmer it was called “Objects Aren’t structs”.
The big idea is that object A tells object B what to do and object B tells C as shown in the diagram below:
The big idea is that object A tells object B what to do and object B tells C as shown in the diagram below:
Labels:
Java,
Object Orientation,
OO,
Tell Don't Ask
Subscribe to:
Posts (Atom)