Msaada: Android App Hosting & Deployment

Software Engineer

JF-Expert Member
Dec 20, 2014
344
137
Nina android app ambayo inategemea .NET web service kuchota data kutoka kwenye database.

Sasa inapotokea nina badilisha au re-design baadhi ya web service components najikuta nalazimika kufanya mabadiliko kwenye mobile app, kisha na update changes.

User ambaye hatakuwa ame update kwenye latest version basi hatoweza kupata service alizokuwa anapata mwanzoni.

Je strategy ipi nzuri ambayo nawezakuitumia ili ku decouple mobile app from webservice? Kusiwe na ulazima wa kufanya changes kwenye mobile app pindi napofanya changes kwenye backend.

Pamoja
 
Nina android app ambayo inategemea .NET web service kuchota data kutoka kwenye database.

Sasa inapotokea nina badilisha au re-design baadhi ya web service components najikuta nalazimika kufanya mabadiliko kwenye mobile app, kisha na update changes.

User ambaye hatakuwa ame update kwenye latest version basi hatoweza kupata service alizokuwa anapata mwanzoni.

Je strategy ipi nzuri ambayo nawezakuitumia ili ku decouple mobile app from webservice? Kusiwe na ulazima wa kufanya changes kwenye mobile app pindi napofanya changes kwenye backend.

Pamoja

Mkuu labda utupe mfano, ukibadilisha nini inakulazimu kubadilisha na mobile app nzima?
 
Version your API
api/v1/login/uname/password

Then ikibadillika unatendeneza version2
api/v2/login/uname/password/country

Mtu anayetumia Mobile app ya kwanza atatumia v1 na akiupgrade anatumia v2.
Ukishaona matumizi ya version1 ni madogo. Remove the API na uwasaidie waliobaki ku migrate to v2.

That is the pro way to do it!
 
Version your API
api/v1/login/uname/password

Then ikibadillika unatendeneza version2
api/v2/login/uname/password/country

Mtu anayetumia Mobile app ya kwanza atatumia v1 na akiupgrade anatumia v2.
Ukishaona matumizi ya version1 ni madogo. Remove the API na uwasaidie waliobaki ku migrate to v2.

That is the pro way to do it!

Thanks mkuu

Nilijaribu attribute routing (.NET) nikawa napata null request/response data, nikaona isiwe shida, nika switch back kwenye default routing.

Ngoja ni apply approach yako mkuu.
 
Thanks mkuu

Nilijaribu attribute routing (.NET) nikawa napata null request/response data, nikaona isiwe shida, nika switch back kwenye default routing.

Ngoja ni apply approach yako mkuu.
Unatumia WebApi/MVC5 au Old WebService?
 
can you share sample code ambayo inarudisha mrejesho Null?

Kwa ufupi tuu, kuna logic ya kupokea Feedback data kutoka kwa end user:

Code with attribute routing:

[RoutePrefix("api/feedbackmobile")]
public class Feedback_MobileController : ApiController
{
[Route("{userid}/{subject}/{body}/{telephone}/{email}")]
[AcceptVerbs("GET", "POST")]
public int postFeedback(string usedid, string subject, string body, string telephone, string email)
{
bool inserted = false; // track crud status
if (inserted)
{
//
// detailed code removed
//
return 1; // successfully inserted into relational database
}
return 0; // nothing inserted
}
}


Code without attribute routing:
public class Feedback_MobileController : ApiController
{
[AcceptVerbs("GET", "POST")]
public int postFeedback(string usedid, string subject, string body, string telephone, string email)
{
bool inserted = false; // track crud status
if (inserted)
{
//
// detailed code removed
//
return 1; // successfully inserted into relational database
}
return 0; // nothing inserted
}
}


Hii code ambayo haina attribute routing, inafanya kazi vizuri.

Nikiweka attribute routing inazingua. Nilipojaribu ku drop some parameters mfano userid (very long string-mobile device identity), ikafanya kazi vizuri. Nilidhani itakuwa issue ya maxurllength, maxparameterlength... issue, then nikaweka very large value ya hizo configuration paramters lakini same issue ikawa bado ipo.


Pamoja
 
few things
1. Use controller camel case not dasherized
2. Do not prefix whole controller. It kills flexibility and causes much subtle issues
3. Do not handle more than on verb in single action. Breakdown your action so that one handles POST (creating data by REST standards) and GET which should fetch data.
4. Use EF for database Ops wherever possible.
5. Namespace your code

Here is a sample code with some of the points adhered to:

Code:
public class FeedbackMobileController : ApiController
{
    [Route("api/V1/feedbackmobile/someAction/{userid}/{subject}/{body}/{telephone}/{email}")]
    public int postFeedback(string usedid, string subject, string body, string telephone, string email)
    {
        bool inserted = false; // track crud status
        if (inserted)
        {
            //
            // detailed code removed
            //
            return 1; // successfully inserted into relational database
        }
        return 0; // nothing inserted
    }
}
 
few things
1. Use controller camel case not dasherized
2. Do not prefix whole controller. It kills flexibility and causes much subtle issues
3. Do not handle more than on verb in single action. Breakdown your action so that one handles POST (creating data by REST standards) and GET which should fetch data.
4. Use EF for database Ops wherever possible.
5. Namespace your code

Here is a sample code with some of the points adhered to:

Code:
public class FeedbackMobileController : ApiController
{
    [Route("api/V1/feedbackmobile/someAction/{userid}/{subject}/{body}/{telephone}/{email}")]
    public int postFeedback(string usedid, string subject, string body, string telephone, string email)
    {
        bool inserted = false; // track crud status
        if (inserted)
        {
            //
            // detailed code removed
            //
            return 1; // successfully inserted into relational database
        }
        return 0; // nothing inserted
    }
}

1. CamelCase: sawa nitafanya hivyo
2. No Prefix: Okay, nitafanya hivyo mkuu
3. Nilitumia GET/POST verbs ili niweze ku-test api kwa kutumia web browser kabla sijaanza ku-code mobile-client
4. Natumia EF almost kila CRUD ops
5. Namespace: Sawa, nimekupata

Shukrani kwa mchango wako mkuu.
 
Back
Top Bottom