I recently watched this youtube tutorial on the Null Object design pattern. Even though there were some errors in it: such as the NullCar that doesn't do anything creates an infinite loop, the concept was well explained. My question is, what do you do when the objects that can be null have getters, and are used in your code? How do you k...
When using Null Object pattern, how would you 'check' if a situation is invalid?
for e.g
when there's no item found in the repository, display message 'not found' to the user.
Do I have to do a glorified null check?
if obj.equals(new NullObject()) { showNotFound(); }
if obj.ID.equals( INVALID_ID) { showNotFound(); }
Those techniqu...
Is there a specific design pattern that describes the scenario where a non-abstract default implementation is provided that implements all or some of the methods on the interface with empty, NO-OP implementations. This being done with the intent of alleviating subclasses with the burden of implementing methods that they themselves may no...
Why does Fowler PoEAA p. 498 define the null-object pattern in the following way (sample shortened, language is c# but doesn't matter):
public class Customer
{
public virtual string Name {get; set;}
}
public class NullCustomer : Customer, INull
{
public override Name
{
get { return "ImTheNull";}
// setter ommitted
}
...
When a controller detects that a DTO passed to it is null should it instantiate an instance of the DTO (cf the Null Object Pattern), or should it simply throw an exception there and then?
Thanks
...