-
-
Notifications
You must be signed in to change notification settings - Fork 735
Do we need a model (class) for our parse objects? #702
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
Comments
To my knowledge, it makes no difference but makes the code look cleaner in some instances. Making a model (or subclass as it's called in the documentation), you just define getters and setters that call getXXX and put. |
Oh yeah, I wanted to provide more explanation on why you want to make a subclass. For one, a ParseObject is more vague than a subclass, let's use Event as an example subclass. If the user sees the variable is a ParseObject, it could be anything from the database. An event, child, game score, whatever classes you have in the database. Additionally, a Parse object gives no information about what fields are in it. Since you call getXXX("key name"), any strings could be valid key names. However, if you define a subclass and create getters and setters, you are telling the developer or viewer that these fields are present in the class. |
I store my key values in a constant class in my app. and I of course do checks to make sure it exists. Usually its when we have a query, so if the query returns 0, then were all good with a quick object.size() check. If it made the app faster than I probably would have went with it. how do we pin a query? when should we pin/unpin? right now my app goes to a splash screen to main (see if they are registered) and then to login register (if they aren't signed in). would I pin everything to that user in main activity for the rest of the app loads faster? I noticed when the application hits the onDestory() everything takes forever to load back up within pinning. |
Feel free to continue discussion, just closing out since the issue is resolved. Pinning/unpinning is done when things need to be saved locally. If the right place for you to do that is within your splash screen, then you can do it there. It is really up to you on what the right time is to pin things. Speed doesn't change based on when you pin/unpin within the application really. And you don't really pin a query, you pin a ParseObject. So, this is another reason you probably want to subclass. Do some testing and see if it is faster to reload the key values via pinning or via calls to the server, sometimes pinning can be slow. See #279 |
@Jawnnypoo pretty much cleared it up but I want to make an important distinction that took me some research to discover. Pinning/unpinning uses the local datastore (LDS) and saves the objects. It's almost like having a local database on the device where you don't have to do Network queries. Queries are not saved in LDS, but rather ParseObjects like mentioned. However, if you just want to speed up a specific query and don't want to bother with LDS, then use caching for the query. Each time you perform a query with caching, it takes the JSON results of the query and stores that String in a map where the key is the query. If you change one part of the query such as a limit or filter, then the key changes and the network will need to be queried for the data. |
Lets say I am storing a persons name and age in the database (MongoDB). Do I NEED to have a model for it -> Constructor, setters and getters?
I usually just make a query call, which would loop through the list of ParseObject's and get do something like.
textView.setText(object.getString("personsName"));
Does it make it a faster query if I used a model?
The text was updated successfully, but these errors were encountered: