Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-device architecture

I'm at the moment trying to make up a "core" for my multi-device project.

The project is all about a web application, that authenticates the user by facebook login, and then exposes a set of new actions they can do - ex. Get all records in the database thats related to their facebook id etc.

The core should be understood by following devices:

  • PC
  • IPhone
  • Android
  • Windows Phone 7

Now how would you make up the core?

  1. Would you make it a WCF service that returns JSON?

  2. Would you make it a bunch of Controllers that returns JSON?

  3. And how would you ensure that the user is who he/she says, when querying the core? Should I pass along the accessToken thats generated by facebook each time?

As you might have noticed, I've absolutely no idea at all how to do this.

Thanks in advance.

like image 885
ebb Avatar asked Oct 10 '22 19:10

ebb


1 Answers

Not sure if I understand your question correctly, but...

First, you will have to define, or probably decide, what the "Core" is? or what the Core should be - what will be the functionality that Core will perform. Ideally, when we say Core, it essentially means, a layer that performs basic or atomic operations.

Over that Core you can spawn the device wrappers(IPhone, PC, etc) that builds a query to be sent to core, for instance.

You can use WCF Data Service to constitute a data layer. And your core can perform business operations/etc, and communicate with the Data Service.

For instance, what I instantly can think of is:

  1. a Core, that performs core operations - for isntance talking to Datalayer
  2. DeviceWrapper(DeviceAndriod, DeviceIPhone, DeviceWeb, etc), that wraps different devices. For example, a mixture of Factory/Builder pattern. Think about factory of Devices, and Builder for types of views.
  3. TextRenderer, based upon the device settings, renders the text.

One way could be, lets decide:

The Core, will be a "library" that will perform basic operations:

  • Authentication
  • Authorization
  • Select records
  • Perform Action 1
  • Perform Action 2

Therefore,

  • STEP 1: Write a Controller that will provide authenticate/authorization; for instance, call the Core.Authenticate(), and Authorize();

  • STEP 2: Based upon the user agent call ICore.RenderView(agentType), this may return you the view/html to be rendered.

User may perform an action, your Controller may call Core.PerformAction(); which in turn may return the link to the page to be redirected, for instance.

--UPDATED--

This update is in response to your comment.

Now, in this(your comment) case, you are talking about client ends.

Lets clear up a bit. There is server and there are client sides.

Up till now, we were talking about Server side, which primarily is concerned with:

  1. How the requests from different user agents will be processed by the server.
  2. How the text will be rendered with respect to different devices.

Client ends could be:

  1. A web browser, in this case you don't need any client app to be developed
  2. A, lets say, Silverlight app for Windows Phone
  3. An android app for Android phone
  4. So on so forth.

Decide what this "client app" will do. For instance, in your case:

  • User shall login via fb id.
  • User shall be able to perform certain operations.

Note that, you may want to consider smart clients (using web services, rather than asp.net web pages).

Also, the type hinting in WCF can add a lot of unnecessary overhead in the JSON response for large collections. Therefore, if you even remotely believe that you might want multiple types of end-points (SOAP, etc.) at some point in the time, then WCF is the way to go.

like image 140
KMån Avatar answered Oct 14 '22 01:10

KMån