Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making ModelClass non-static #54

Closed
amalolan opened this issue Apr 22, 2020 · 4 comments
Closed

Making ModelClass non-static #54

amalolan opened this issue Apr 22, 2020 · 4 comments
Assignees

Comments

@amalolan
Copy link
Collaborator

amalolan commented Apr 22, 2020

So, to run unit tests for backend methods, without having to worry about code on the ModelClass side, I decided to template the backend classes. That way, I thought I could easily unittest backend and also use our current workflow (where we tell you what changes we want in ModelClassExt, and you implement them when possible in ModelClass).

Now, as I started writing unit tests, I've realized that though it is still possible to do so without any modifications, it is going to lead to a lot of extra code on the testing end. See this , this , and this if you'd like to learn why.

To me, the quickest fix looks like making all methods and functions in ModelClass non-static. And honestly, that sounds like a good code design decision even without considering testing. I mean, we are practically using ModelClass as an object. We have an initializing function, and we have a close() function. From what I can tell, the change should be easy as well.

  1. find and replace static with virtual in model/modelclass.h (virtual functions help overload without issues)
  2. Change any static function calls of ModelClass:: to this->
  3. move initialization of database and db, query to constructor which would be ModelClass(std::string databaseFilePath)
  4. On backend, we could even remove templating and take in the ModelClass object into the Controller's constructor. And similarly, we would replace T:: with this->modelObject.

Let me know what you think. I might be completely missing something.

@amalolan
Copy link
Collaborator Author

I have converted all the code in backend to the non-static version in the branch nonstatic. You can take a look at it. Let me know if you don't want to make the changes. Otherwise, let me know when you're free. We can work on changing the current ModelClass to this implementation together.

@leksoborashvili
Copy link
Collaborator

there would be no problem for the backend.

@iamyevesky
Copy link
Owner

Could this be closed now?

@amalolan
Copy link
Collaborator Author

@iamyevesky After the meeting, can you push all your changes to testing? I can make everything non-static and have it ready in a few hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants