Yesterday I posted about four nearly identical functions that I thought could (and should) be reduced to just one somehow. Reducing it to one would be far less code to maintain if I find a faster way of doing it, or have to fix something. I found a good answer, but it’s not what I thought it would be.
The four functions:
1) Return open cases before a certain date
2) Return open cases after a certain date
3) Return closed cases before a certain date
4) Return closed cases after a certain date
I can replace all of those with thee functions:
1) Return open cases
2) Return closed cases
3) Return cases between certain dates
Or, I can roll the “is case open/closed” function into one somehow. Or, I guess I can roll all four into one function that needs to be passed a few parameters, like:
def CaseThatIsOpenedOrClosedBetweenDate(self, CaseOpenStatus, startdate, enddate)
I wanted to avoid doing stuff like that in the “library” so that the reports I create using functions in the library would be super easy to read.