Using Multiple Databases With iOS App - database

I have an iOS app that currently stores and pulls its data in/from SharePoint lists via a web service. I want to have the option in settings for the app to also use another database or cloud database i.e. parse.com
I don't want to have to put if statements all throughout my code to test whether the app is set up to use either of the repositories.
What's the best way in an iOS app to architect it to use multiple repositories/databases to store and retrieve the data used in the app?

Build a data manager class that handles the logic. I would go so far as to create one for each service you are attaching to. They can all inherit from a single base class and share the local cache code (which I am assuming is Core Data based on your tags). Then on launch you can instantiate the one you want to use.
I would NOT use a Singleton as suggested. Better to use Dependency Injection and be able to tear down and build up a new data manager if you switch between services while your application is running. Using a singleton would be a poor design decision.
If you localize all of your network code into a single class (something I was speaking about last year as a Network Controller) you can then easily switch between services by keeping your interfaces the same.

Related

Is a restful service needed to access/update a database?

I have a MySql database set up and a mobile app that should be able to write/read to and from the database.
The data being stored will be posts, comments, votes, etc.
Eventually, I might create a website that uses the same database.
My question is, do I need some sort of middleman (restful) service running or can I just connect straight to the MySql db from the client code (either the mobile app or website)?
Introducing a REST api into the middle would be much beneficial in a lot of ways.
Improve generalization and reuse. (REST api can be used by both mobile client and web client, no need to do the same work twice)
Can maintain business logic centrally. (If there's a logic to change or a bug fix, no need to correct in 2 places)
Can be easily exposed to any other app/client which would need the set of operations provided by the api.
Extending and maintenance of the app would be much simplified and would take minimum effort.
Especially with the mobile application, where you have much less control of updates, it seems better to use some middle-ware to connect to your database.
Say for instance your website needs a little change in the database that would break an active version of the mobile application. A web service could catch that for you.
What about a new version of your mobile app that needs a change. Again a web service can handle that for you.
This is all about cutting dependencies and keep the complete ecosystem adaptable.
Whether this is a rest or any other type of web service is a completely different discussion.

Managing multiple WCF services in one project

Currently I am working on an ERP Project, Using Entity FrameWork and WCF at server side and WPF at client side. Since it is a big project , we have a lot of entities.What we did so far is, Created Service contracts for each Entities and exposed with multiple endpoints.The Problem is we had to add Service Reference for each Service and we are feeling difficult to manage these web services.
1.Is this a proper way ?
if yes,
2.Is there any way to allocate these web services (in classes or folders)..?
Thanks in advance.
You don't want to keep generating the proxy classes in the client.
Just move the POCO classes and contracts to single assembly which you can reference in the server and client. Then create the necessary channels in the client with ChannelFactory.
ChannelFactory(TChannel)
If you are dealing with many services you can create routing service which will behave like facade. Once you have routing service defined then all requests are going to be sent towards routing service and then, based on some criteria, provided to specific service. You are dealing with only one service so if any change in sub-services occures, for instance endpoint's address is altered, then such a change needs to be reflected only in routing service.
Finally i got how to deal with multiple Services
i am considering to use svcutil.exe in order to create proxy classes.
so that we can arrange those classes in folders, and also we can
get more control over proxies

Grails - switching data sources based on User

We are developing a Grails web application, where different users (customers) need to be pointed at different databases containing only their organization's data. Unfortunately, the separated databases are a requirement, and we are being asked to be able to have only 1 web application for everybody.
However, Grails expects only a single datasource pool connecting to one database.
We want to be able switch database connections, per session, based on the user that is logged in, where the different connections are read in from properties files during the BootStrap init().
So far, we have been unable to find a solution that does not seem to have race conditions, there is no plugin we can find, and it doesn't seem to be a popular issue.
Our most promising was creating a custom dynamic data source, set up in Bootstrap to define a map of organization->dataSource, and utilizing a closure defined in Bootstrap to find the appropriate dataSource before GORM behavior, but this seems to cause race condition when there is latency.
Does anyone have an idea how this switching can legitimately be performed?
Thanks
Considering Grails is built upon Spring your best bet is to develop your own resolvable datasource.
Dynamic datasource routing
Example of datasource routing
It's not clear in your question if you're deploying your application once, and trying to configure the DataSource used by User, or if you just want to configure by deployment.
If it's just per deployment, Grails allow you to externalize the configuration. You can set this to use a file in the classpath or in a static location.

Backend for iOS app

My question is how do i get information from a server to my iphone app. let's assume I have completed my current project I'm working on that only needs data to be uploaded to my application.
I understand there is a database or server I must create but how do I go about creating or modifying one for my needs.
I mainly want to store login information from one user and allow users to search for people who have entered login information (name) to add to a friends lists within the current app.
i think in your case you can use Django-tastypie for backend will be good choice.since using django you can develop it in quick time and the tastypie has api services which can used easily for retrieval and sending data
you can go through this
http://django-tastypie.readthedocs.org/en/latest/
Take a look at services like Stackmob or Parse. These types of service could make it really easy for you to get the server side part of your application up and running. These services would act as your database and also provide an easy api for you to access the server side pieces.

What is best way to keep constants separated from Salesforce apex code?

If I need to keep some config separated out from code then what should be the best approach? I have some Web Services that needs to be invoked from Apex class. Web Services URL vary based from where it was invoked i.e if Apex code is deployed on Sandbox then it needs to invoke http://www.sandbox.com/XXX while if in Production then it needs to use http://www.production/XXX.
Custom settings are what you want to use. This way you can have different configuration values in your sandbox and production orgs. Also, custom settings are cached at the application level, so accessing them is very fast.
Here is some more documentation about how to access custom settings from Apex code.

Resources