In my project, I have a log and I am processing it in 2 phases. In the first phase I parse it, do some processing and store the values as attributes of a class. In the second phase I do database operations in which some of the attributes from the first phase are required. What is the correct way of passing these attributes so that they are shared between the service logic of first phase and dao logic of second phase. The count of these attributes is nearly 15-20 so according to me I have below mentioned ways of doing it:
-
Write a function to copy the attributes of the class of first phase to an object of second phase - Problem - On adding one more such attribute I will have to add it to this function which can make new bugs arise if a future developer forgets it.
-
Make the first phase object an attribute of second phase object - Problem - In this internally the getter and setter of the first phase will be invoked to obtain the values. But all the attributes of the first phase are not required in second phase, so either I make a separate class of the attributes which are to be passed to repository else all the attributes will be visible to the repository which is not a correct way of doing this.
Which design pattern should I follow to accomplish this task in a better way.
Aucun commentaire:
Enregistrer un commentaire