One can visualize Encapsulation as the method of putting everything
that is required to do the job, inside a capsule and presenting that
capsule to the user. What it means is that by Encapsulation, all the
necessary data and methods are bind together and all the unnecessary
details are hidden to the normal user
Encapsulation may also refer to a mechanism of restricting the direct access to some components of an object, such that users cannot access state values for all of the variables of a particular object.
Above two extracts i have taken from two different places.
Why they mention word user here?
I believe a user is someone who is using the product.Example. For an android app user is someone who is downloading and using the app..He/she only has access the the product functionality and not the code running behind it.So how is encapsulation hiding unnecessary details from user.Instead it's hiding implementation details inside one class from another using private?
"Users" here means other programmers who are going to use your code/API/library.
This is not an uncommon or unusual choice of words. If you want to refer to the users who are downloading and using the app, people usually use the term "end user".
Related
I have the structure below. A document in Firebase with the types Map, int and String. On the application screen, I have a specific widget to add a user and I have another widget to add the Address Map separately. So I thought of the following solution: I create an Address class with the attributes I need (city, street) and use those attributes to be able to save what the user types in the form of the screen. Then I do the conversion to map and save this information inside the user as an update.
Is this a good solution or is there a simpler way? Is it more interesting to have a sub-collection instead of a Map of address?
Don't do what seems more "interesting". Do what satisfies the needs of the queries you need to perform on this data. This is the only real rule of data modeling for Firestore, because if you make a decision that doesn't work for the use cases you expect, then you will have a lot of work to do to change it.
I don't see anything here that needs a subcollection.
Do what your application requires. If you feel your application will need a certain structure of data going forward then try to plan for this. But don't over-engineer too early in the development cycle.
Working with Firebase for the first time and looking for advice of setting up the right structure for my project which is basically an "offers/coupon" type starter project.
The scenario is this:
I have a node containing a list of all offers available to users
This list of offers is displayed to users after successful Firebase authentication
When a user redeems an offer, I want to be able to count/record that activity in their child node under user and hide that offer so that they cannot see it again once used.
My question is what would be the best way to do this given that offers may be added, may expire, or may change at some point in the future. So, in effect, the user should receive the list of most updated offers, minus the ones he/she have used in the past.
a) would it be more effective to have a master list of offers, and then run a cloud/server function to clone this list for each new user an track that way
Firebase Structure 1
or
b) Keep a master list of offers in one node, then track user specific offer usage
Firebase Structure 2
Appreciate your guidance
The second solution is better because you'll save bandwith. This practice is called denormalization and is a common practice when it comes to Firebase. The first solution is not good becase every time you want to display the users you donwload unnecessary data. If you want to read more details about how you can structure a Firebase database in a efficient way, please read this post, Structuring your Firebase Data correctly for a Complex App. Also, you can take a look a this tutorial, Denormalization is normal with the Firebase Database, for a better understanding.
Second solution is much good. Because in first one we are having redundancy of data in our database. And second one obviously removing that cause.
But instead of using true or false because it is only showing you, "it's available or not", so you can use a string type parameter as "expired", "going to expire" and "updated" or whatever sooo. So it. Will be able to trace all you information related to offer for particular user. I think this is your requirement also.
Happy coding.
So an assignment requires me to only use 2 screens, both for displaying data upon login (which, for now, is done within the app).
I've currently been logging in and grabbing the data in the main startup activity, but would it be better to accomplish this in an Application class? I only need it to login once, and grab data which is a list of planes, from that 'user'. I also need that list of planes for 2 other activities to display data from, so I need a way to access it from everywhere. I've read that putting such objects in an Application class is more trouble than its worth and would just like to know pros/cons or alternate suggestions for this task.
By the current method (login being done in the main activity's onCreate), the login occurs multiple times, which is not ideal.
I am not at liberty to post the code as it is part of an assignment, and there are strict rules about 'helping your peers' should someone come across this, thanks!
I think you can store data in session management in android
after that you use any where in your app if you want that code
ask me i will give you
http://www.androidhive.info/2012/08/android-session-management-using-shared-preferences/?
I am creating an android app that can be used by common users and also admin.
Suppose, if admin adds a new place name, that name should be added to database and when common user uses the app, he should be able to see the place name that is added.
I used MySqlLite database. But the problem is that if the app is uninstalled all data is lost. So I want some persistent data storage in which all the places that are added by admin are saved permanently.
Regards,
Sindhu
With the data being needed across multiple devices, your only option is to create/use a backend API.
Parse would have been a good choice but since that is getting shut down soon then it wouldn't be wise to use that.
Take a look at these alternatives here
You could also write one yourself, but unless you have some experience in that sort of thing then it will take some time to learn.
This is a question about Application design rather than how-to-do specific actions.
I am a student taking a beginner's course in Android Development. I am designing a program which initially requires the person to login, then at a later time they may choose to display a record of all the users that have logged in previous sessions.
As of right now, there are two parts of my app: LoginField Activity which takes the login data from the EditText field, and which is then supposed to write that information to an external .dat file of some kind so that the information will persist across launches, and a LoginHistory Activity which is supposed to display this history in a ListView.
I have toyed with creating a separate class for the ArrayAdapter logic - an ArrayAdapterController class (?) - but was uncertain how to pass information back and forth between it and the two Activities.
so - my questions are these:
since the information needs to persist across sessions what is the
best method to do this? it does not have to be secure for the moment
as this is only a student project.
does it make sense to make a separate Controller class to handle the information that will be passed between Views/Activities?
apologies for the general nature of this question - as you can see I am an MVC novice.
You've asked a general question, so the best I can do is give you a general answer. You want to use the AbstractAccountAuthenticator class. The documentation there should give you a good jumping off point for you. Furthermore, the SampleSyncAdapter provides a comprehensive (but complex) example of using the authenticator with a full on REST Web Service.