tell-dont-ask

Aren't Information Expert / Tell Don't Ask at odds with Single Responsibility Principle?

It is probably just me, which is why I'm asking the question. Information Expert, Tell Don't Ask, and SRP are often mentioned together as best practices. But I think they are at odds. Here is what I'm talking about: Code that favors SRP but violates Tell Don't Ask, Info Expert: Customer bob = ...; // TransferObjectFactory has to use Cu...

Simple Scenario, How to Incorporate Tell Don't Ask?

I'm trying to model a basic scenario involving a Person and a Seat. A Person has a Status property: Sitting or Standing. A seat has a Seated property that specifies the Person that is currently sitting in it. Also, a Seat is special in that it only "accepts" certain people to sit in it. I know it sounds strange for a Seat to "accept" som...

Does "tell, don't ask" apply to user input validation?

I somehow must have overlooked the "tell, don't ask" OOP principle all these years because I just learned about it a couple days ago for the first time. But the context was a discussion about validation code that had been moved out of an ASP.NET web form page and into a data/business object, and there was no "Validate()" method, just a ...

Good case for Tell, Don't Ask

Say I have two objects: Map Table At the moment I have something like this: Map.MapTable(Table tab); <- Static MapTable method. which checks if the table is mappable and then maps it but also has to check for null table. Would it make more sense to do this: Table tab = new Table(); Map mymap = tab.MapTable(); That way the table...

Can I use mvc without getters and setters?

If I don't want to expose the state of my object, but I still need to display it (in HTML, XML or JSON let's say), how would I go about doing that in an MVC environment. Does it make sense to have an export method which exports a dumbed down immutable object (a "data class" if you will). What about adding in a render method which talks...

How to think "Tell, don't ask" in this simple example?

How would you adhere to the "Tell, don't ask" principle (henceforth "the principle") in the following simple scenario? In a Tetris game, I have Board, BlockGrid and Piece classes relevant to the following example: public class Board { private var fallingPiece:Piece; private var blockGrid:BlockGrid; ... public function mo...

Tell don't ask and shared state between tasks

In this simple example (ofcourse my real world problem is a tad more complex, although the basics are the same), how do I enforce tell dont ask to the max? Id like to maximize tell dont ask in the process method, in its current state its harder to mock and test. public class Processor { public void Process() { var data =...