Let me explain it through pseudo code.
Class Document { //Has some properties //Getter setter methods }
Class InputParser{ public List<Documents> initializeDocuments(Json input) {
/*
I will have to parse the Json input into the List of Document class and then initialize all the items in that list.
The initialization can be based on 2 scenarios: 1. If the Json input doesn't contain any object of Document class, the initialize function should create a document object and initialize it with default values using the below function which is clear to me.
- But if the Json input contains one or more objects of Document class with some attributes already defined and some attributes that need to be defined by default values (keeping in mind to not override the attributes which are already defined with default values and only initialize those attributes which are null/empty in the input. So, what's the most suitable,efficient and beautiful way to do it?
*/ }
private Document initializeWithDefaultValues (Document document) { //Initialization of default values will be here. } }
submitted by /u/ABasit106
[link] [comments]
from Software Development – methodologies, techniques, and tools. Covering Agile, RUP, Waterfall + more! https://ift.tt/3wk0jda