Till now I have seen everywhere that the steps to create Null Object Pattern, for example in BST to remove null checks, are as follows:
-
Create an interface Node
-
Create two classes implementing the interface Node. One of which will be real_Node and other will be null_Node.
-
Using those classes, null checks can be removed in BST class while creating the tree.
Now I want to know that, are there other ways to do this, e.g., Can we implement Null Object Pattern without interface using only classes, i.e. in the above step (1.) can we use Node class instead of Node interface
Aucun commentaire:
Enregistrer un commentaire