You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesión a prueba de IA

Antes: $249

Currency
$209
Suscríbete

Termina en:

1 Días
14 Hrs
17 Min
52 Seg

Como crear un modelo de datos

11/26
Resources

What is client-server communication in mobile applications?

In the development of mobile applications, communication with servers, specifically through APIs, is fundamental. This interaction establishes the exchange of data necessary for the application to function correctly. They are defined in conjunction with both the backend and mobile frontend teams. In this process, it is decided which data is received and which is omitted.

Data transfer is usually done in the JSON (JavaScript Object Notation) format, a format widely known for its simplicity and comprehensibility. JSON becomes the standard due to its efficiency in structuring and transmitting data.

How to design an effective data model?

Designing a data model for an API requires precision. Let's imagine an application where we see a list of courses, each with its image, name and description. Here we must ask ourselves: which data is really essential?

  • Essential data: The name of the course, the ID (for visual changes) and the URL are essential.
  • Unnecessary data: Details such as the professor, if available, IDs of graduate students, or the information of each of them, are not strictly necessary for the main list.

Concentrating on including only vital data helps improve the efficiency of the application, ensures faster loading and reduces resource consumption.

{ " courseID": "123", " courseName": "Advanced Programming", " imageURL": "http://example.com/image.jpg"}

When should data be omitted?

Omitting data is key to optimizing performance. Often, unnecessary information is overloaded, such as complete lists when it is sufficient to keep an accurate count.

For example, sending a full array of graduated students is much less efficient than simply sending the total number of graduates.

{ " graduatedStudentsCount": 230}

This not only saves bandwidth, but also minimizes the processing load on mobile devices, which despite being increasingly powerful, are limited compared to servers.

What mistakes to avoid when structuring JSON?

When structuring and using JSON, certain practices should be avoided at all costs. For example, passwords should never be included in API responses, as this is a significant security risk. Equally unnecessary is sending details such as emails or photos of the teacher when they are not relevant to the current view or functionality:

  • Fatal error: including passwords within JSON.
  • Irrelevant details: Emails, ratings or information that is not used.

Instead, simply use unique identifiers and strictly required data. Finally, it is essential to collaborate closely with the backend team to ensure that the data requested and delivered aligns with functional and non-functional requirements.

How to improve API performance?

To improve API performance, it is crucial to seek consensus with the backend team. This involves reducing logic and data processing on the client, working on optimizing the server to deliver only the necessary information.

This collaboration not only improves the relationship between the development teams but also ensures that the mobile application is faster and more efficient, providing the end user with a seamless and positive experience.

By applying these principles, developers can propose significant improvements to APIs and work together to achieve maximum performance. The goal should always be to make applications more agile without compromising security or functionality. Remember, constant learning and practice are critical to mastering effective API design - go ahead and apply this knowledge to your projects!

Contributions 3

Questions 1

Sort by:

Want to see more contributions, questions and answers from the community?

Para crear un modelo de datos en formato JSON, debes seguir los siguientes pasos:

Identifica las entidades y sus relaciones: Identifica las entidades que estarán involucradas en tu modelo de datos y las relaciones entre ellas. Por ejemplo, si estás creando un modelo de datos para una tienda en línea, las entidades podrían ser “producto”, “cliente” y “pedido”, y las relaciones serían “un pedido pertenece a un cliente” y “un pedido contiene varios productos”.

Define las propiedades de cada entidad: Para cada entidad, define las propiedades que deseas incluir en tu modelo de datos. Por ejemplo, para la entidad “producto”, las propiedades podrían ser “id”, “nombre”, “precio”, “descripción” y “existencias”.

Define el tipo de datos para cada propiedad: Para cada propiedad, define el tipo de datos que deseas utilizar. Los tipos de datos comunes en JSON son: string, number, boolean, array y object.

Define las restricciones y validaciones de cada propiedad: Para cada propiedad, define las restricciones y validaciones que deseas aplicar. Por ejemplo, si la propiedad “precio” solo puede tener valores positivos, debes definir una validación para asegurarte de que siempre sea así.

Define las relaciones entre las entidades: Para cada relación entre entidades, define cómo se relacionan entre sí. En JSON, las relaciones se pueden definir utilizando identificadores únicos que hacen referencia a otras entidades.

Una vez que hayas creado tu modelo de datos, puedes guardar los datos en un archivo JSON. Un archivo JSON es un archivo de texto que utiliza una sintaxis simple para representar datos estructurados. Las características de un archivo JSON incluyen:

Sintaxis simple y legible: Un archivo JSON es fácil de leer y entender, incluso para aquellos que no están familiarizados con la programación.

Ligero y fácil de transmitir: Un archivo JSON es un formato de datos muy ligero, lo que lo hace fácil de transmitir a través de la red.

Soporte para anidación y estructuras complejas: JSON admite anidamiento y estructuras complejas, lo que lo hace ideal para almacenar datos estructurados.

Compatible con muchos lenguajes de programación: JSON es compatible con muchos lenguajes de programación diferentes, lo que lo hace fácil de usar en diferentes proyectos y aplicaciones.

Fácil de manipular y transformar: JSON es fácil de manipular y transformar, lo que lo hace ideal para el intercambio de datos entre aplicaciones y sistemas.

Esta es mi respuesta para el ejercicio 2:

{
    "courses": [
        {
            "id":12,
            "courseImageUrl": "https://imgv3.fotor.com/images/blog-cover-image/Image-Upscaler-4.jpg",
            "colorBackgroundCourse": "#23232"
        },
        {
            "id":142,
            "courseImageUrl":
            "https://imgv3.fotor.com/images/blog-cover-image/Image-Upscaler-askdpoio0.jpg",
            "colorBackgroundCourse": "#23232"
        },
        {
            "id":67,
            "courseImageUrl":
            "https://imgv3.fotor.com/images/blog-cover-image/Image-Upscaler-609823j.jpg",
            "colorBackgroundCourse": "#23232"
        }
    ],
    "infoTeacher": {
        "teacherName": "Cristian Jiovany Villamil",
        "teacherProfileImageUrl": null,
        "teacherId": "12093398",
        "teacheProfileColorColor": "#443434"
    },
    "backgroundColor": "#443434"
       
    }
Si el JSON contiene toda esa información porque en la Web si muestra los datos, lo mejor es crear métodos nuevos en la API para enviar la información al mobile?