jeudi 8 novembre 2018

java best practice or are there any design patterns to keep data filed which hasn't a direct relationship with that class

I just want to pass the value with the object but that value is not completely related to that object. Let's say there is an object call Request Data

public class RequestData
{
  private int requestId;
  private String status;
 .......
}

I want to pass is this request need to save only or print only or both save and print likewise there are several actions. When I pass this request data to another class to validate this requestData, I want to identify is it coming from save or print or save and print call. For that, basically, I can add an attribute to that RequestData class. But according to my learning in OOP, We should keep attributes related directly to that objects as attribute of that object.

Then what is the best practice or are there any design patterns to keep data filed which hasn't a direct relationship with that class.

Aucun commentaire:

Enregistrer un commentaire