Friday, March 20, 2015

3/19/15 - NSF Meetup and Refactoring

At NSF yesterday, I got a chance to talk to Kevin about some design questions I had relating to the Librifox code. Since I don't have a lot of experience with stuff like storing UI state, I wanted to get his input on our current approach. After talking to him, I think it makes sense to move the bookCache directly into the UIState object, so that it is 'insulated' from the rest of the code. I think that this makes sense, because we never really use bookCache outside of the context of UIState, so the two are clearly linked. This would also allow us to have more control over what code can do to the bookCache by moving it out of global scope.

I also asked Kevin what he thought of my approach to our XMLHttpRequest code. I was worried that having a base function that is referenced by other functions which pass in specialized strings might not be a good thing to do, but he said that this was definitely a valid design pattern. The getDataFromUrl method is essentially a template, and the three specific methods pass in specialized parameters to customize the specific steps that are taken to launch the request.

I also wanted to make sure I added in this quote from a guy named Tony Hoare that Kevin sent me a while ago after my "bad code vs. good code" post.
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." 

1 comment: