<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bernardino Guerrero on Medium]]></title>
        <description><![CDATA[Stories by Bernardino Guerrero on Medium]]></description>
        <link>https://medium.com/@bernardino.guerrero?source=rss-2bc6c0ffe8d0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Uc7X3B_QS7lxN1SK2qd3_A@2x.jpeg</url>
            <title>Stories by Bernardino Guerrero on Medium</title>
            <link>https://medium.com/@bernardino.guerrero?source=rss-2bc6c0ffe8d0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:44:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bernardino.guerrero/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Property Testing with Swift: A Guide for Developers. Pa]]></title>
            <link>https://medium.com/@bernardino.guerrero/property-testing-with-swift-a-guide-for-developers-pa-6415e1f0b3f3?source=rss-2bc6c0ffe8d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6415e1f0b3f3</guid>
            <category><![CDATA[property-testing]]></category>
            <dc:creator><![CDATA[Bernardino Guerrero]]></dc:creator>
            <pubDate>Fri, 10 Feb 2023 04:56:38 GMT</pubDate>
            <atom:updated>2023-02-13T04:34:06.365Z</atom:updated>
            <content:encoded><![CDATA[<h3>Property Testing with Swift: A Guide for Developers. Part 1</h3><p>As software developers, ensuring that our code is reliable, maintainable, and scalable is a top priority. One technique that can help achieve these goals is property testing. In this article, we’ll explore what property testing is, how it can be used in Swift, and some of the benefits it offers, with references to relevant literature.</p><p>What is Property Testing?</p><p>Property testing is a software testing technique that verifies the behavior of a program by generating random inputs and checking if they satisfy specific properties. These properties are usually defined in terms of the expected output of a function or the behavior of a data structure.</p><p>The goal of property testing is to uncover edge cases and hidden bugs that other testing techniques, such as unit testing, might not detect. This is achieved by generating numerous random inputs and testing them against the specified properties (Gill and Quick, 2015).</p><p>How Property Testing Works in Swift</p><p>Swift provides several libraries and frameworks that support property testing, such as SwiftCheck and Quick. These libraries allow developers to write test cases that can automatically generate large sets of inputs and validate that their output satisfies specific properties (Foong and Collins, 2020).</p><p>For example, a property test for a sorting algorithm could verify that the algorithm&#39;s output is always sorted in ascending order, regardless of the input. This can be done by generating a random set of numbers and checking that the output of the sorting algorithm is indeed sorted. If the output is not sorted, the test will fail, and the developer will be notified of the issue (Gill and Quick, 2015).</p><p>Benefits of Property Testing in Swift</p><p>There are several benefits of property testing in Swift, including:</p><ol><li>Uncovering edge cases and hidden bugs: Property testing can uncover edge cases and hidden bugs that other testing techniques might not detect. This is because it generates numerous random inputs and tests them against specified properties (Gill and Quick, 2015).</li><li>Improving code quality: Property testing can help improve code quality by detecting and fixing bugs early in the development process. This reduces the risk of unexpected failures in production and helps ensure that the code is reliable and maintainable (Foong and Collins, 2020).</li><li>Improving code confidence: By running property tests, developers can ensure that their code works correctly for all possible inputs. This helps to reduce the risk of unexpected failures in production and ensures that the code is scalable and maintainable (Gill and Quick, 2015).</li></ol><p>Conclusion</p><p>Property testing is a valuable technique for testing Swift code and ensuring its quality and reliability. By generating large sets of random inputs and testing them against specified properties, developers can detect and fix bugs early in the development process and reduce the risk of unexpected failures in production (Foong and Collins, 2020).</p><p>Whether you’re an experienced Swift developer or just starting out, property testing is a technique worth exploring. With the support of libraries and frameworks like SwiftCheck and Quick, it’s easy to start writing property tests and improving the quality of your code.</p><p>References:</p><ul><li>Foong, K., &amp; Collins, K. (2020). Swift Programming: A Comprehensive Guide. O’Reilly Media, Inc.</li><li>Gill, S., &amp; Quick, N. (2015). Swift Testing: Best Practices and Techniques. Packt Publishing Ltd.</li><li><a href="https://github.com/typelift/SwiftCheck">SwiftCheck</a></li><li><a href="https://www.youtube.com/watch?v=hXnS_Xjwk2Y">Don’t write tests</a>!</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6415e1f0b3f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comparativas entre Struct y Class en Swift]]></title>
            <link>https://medium.com/nearsoft-jobs/comparativas-entre-struct-y-class-en-swift-8f9378aba8f6?source=rss-2bc6c0ffe8d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f9378aba8f6</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[nearsoft]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Bernardino Guerrero]]></dc:creator>
            <pubDate>Mon, 21 May 2018 17:27:25 GMT</pubDate>
            <atom:updated>2018-05-21T23:34:51.861Z</atom:updated>
            <content:encoded><![CDATA[<p>Una de las preguntas más comunes en una entrevista de iOS (e.g. <a href="http://nearsoftjobs.com/open-position">Nearsoft open jobs</a>) es respecto a las diferencias y similitudes entre una clase y una estructura en Swift.</p><p>Realmente, en Swift las estructuras y clases comparten más similitudes que diferencias. Primero que todo en Swift, una clase y una estrutura de datos se se declaran utilizando las palabras reservadas <strong><em>class</em></strong> and <strong><em>structure</em></strong> respectivamente como se muestra a continuación en <strong>figura 1</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JaAu5NA08m5nlwCuCKcKpQ.png" /><figcaption><strong>figura 1</strong>. Ejemplo de definición de una clase y una estructura en Swift.</figcaption></figure><p>A continuación listamos algunas <strong>Diferencias</strong>:</p><ul><li><strong>Estructuras:</strong> generan automáticamente incializadores por nosotros, mientras que en las <strong>clases</strong> no lo hacen. <strong>figure 2</strong>.</li><li><strong>Estructuras: </strong>son “<strong>value</strong> types” y las clases are “<strong>reference</strong> types”. Más adelante explicaré esto con más detalle.</li><li><strong>Estructuras:</strong> <strong>no</strong> manejan <strong>herencia</strong> (no puedes heredar comportamiento de otras estructuras) mientras que las <strong>clases</strong> <strong>sí</strong> soportan herencia simple.</li><li>Los <strong>de-inicializadores</strong> son funciones que se ejecutan justo antes de que la instancia de una clase sea destruida o liberada, aunque <strong>ARC</strong> nos ayuda con las tareas de memoria, en las clases siempre es importante liberar cualquier recurso que estemos manejando. Las estructuras no soportan esto y no tiene sentido puesto que son “Value Type”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U_wRKGnWlO6qm-49itGj6A.png" /></figure><p><strong>Similitudes</strong>:</p><ul><li><strong>Propiedades:</strong> Ambos pueden usar propiedades para almacenar información (Stored properties)o para calcular (Computed properties) o establecer valores de manera indirecta para otras propiedades.</li><li><strong>Métodos:</strong> Son funciones que definen comportamiento. Lo anterior es importante por que en Swift las estructuras y las enumeraciones pueden definir métodos, algo que en Objective-C no es posible. Ambos soportan métodos de instancia y métodos de tipo (Type Methods).</li><li><strong>Inicializadores:</strong> Funciones que sirven para preparar o configurar los valores iniciales o Stored properties para las instancias de las clases, estructuras o enumeraciones. Los inicializadores son llamados cada vez que queremos crear una instancia de un tipo particular y pueden o no tener parámetros. Aqui podemos hablar de incializadores por default, por conveniencia, requeridos o “Failable”. “Failable initalizer” son funciones init seguidas por el signo ?, ejemplo: init?().</li><li><strong>Subscript sintaxis:</strong> Son atajos acceder o establecer valores para una clase, estructura, enumeración a través de un indice usando notación de []. Para definirlo se usa la palabra reservada subscript(…) con un número de parámetros según convenga.</li><li><strong>Protocolos:</strong> Definen contratos de métodos, propiedades y cualquier otro requerimiento que se adapte a una funcionalidad en particular. Clases, estructuras y enumeraciones, pueden conformar Protocolos.</li><li><strong>Extensiones:</strong> Permite agregar funcionalidades a los tipos existentes, tanto métodos como computed properties. Las extensiones no permiten declarar Stored Properties. Las extensiones también son ampliamente utilizadas para conformar protocolos para algún tipo de dato.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HBhUyLN4jm11mDbynF5xJQ.png" /><figcaption>figure 3. Las instancias teamStr y teamCls son creadas de una estructura y una clase, respectivmente. Observe cómo se quiere cambiar el nombre utilizando la función chageNameBy, sin embargo, teamStr mantiene su nombre simplemente como Mexico.</figcaption></figure><h3>Diferencia de Tipos</h3><p>Regresemos a las diferencias. Como se comentó anteriormente, la principal diferencia es que estructuras son <strong>Value Type</strong> (tipo Valor) y las clases son <strong>Reference Typ</strong>e (tipo referencia). Tipo valor significa que cuando se crea una instancia de una estructura y se asigna a otra instancia o se pasa como parámetro a una función, realmente se crea una copia, tal que, cualquier modificación no afecta la instancia original.</p><p><strong>Tipo referencia</strong> significa que cuando creamos un objeto de una clase y se la asignamos a otra instancia o la pasamos como parámetro de una función, se pasa una referencia a la memoria de la instancia original, por lo que cualquier cambio en cualquier parte de nuestro programa afectará la instancia original.</p><p>Un ejemplo de lo anteior se puede ver en la figura 3. La instancia de la estructura <strong>no puede cambiar</strong> ninguna de sus propiedades una vez que se crea (recuerda es un value type).</p><p>NOTA. Las funciones pueden usar la palabra reservada <strong>inout</strong> para forzar cambios en los parámetros que son del tipo valor.</p><h3><strong>¿Debo usar Estructuras o Clases?</strong></h3><p>La respuesta no es simple y recuerda que siempre se pueden combinar, algo más a tener en cuenta es que <strong>“Las instancias de estructuras siempre son pasadas por valor, y las clases con pasadas por referencia”,</strong> lo que significa que son adecuados para diferentes tipos de tareas.</p><p>Mantén en cuenta que en Swift muchos de los tipos básicos como arreglos, diccionarios y string son implementados como estructuras.</p><p>Puede que encuentres interesante esta discusión en <a href="https://stackoverflow.com/questions/24232799/why-choose-struct-over-class/24232845#24232845"><strong>Stack Overflow</strong></a><strong>.</strong></p><p>Finalmente te invito a que revises este interesante post <a href="https://agostini.tech/2017/09/03/structures-vs-classes-in-swift/"><strong>heap and stack</strong></a>, el cuál puede ayudarte a entender mejor las estructuras y las clases.</p><p>Espero que hayas encontrado útil esta información. Puedes encontrar el código fuente del playgroud en el siguiente link: <a href="https://github.com/quantumB/Structures-and-Classes-Swift-Introduction">Código fuente</a>.</p><h4>Berna Guerrero, Software Engineer @Nearsoft</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f9378aba8f6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nearsoft-jobs/comparativas-entre-struct-y-class-en-swift-8f9378aba8f6">Comparativas entre Struct y Class en Swift</a> was originally published in <a href="https://medium.com/nearsoft-jobs">Nearsoft Jobs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Protocolos Equatable y Comparable]]></title>
            <link>https://medium.com/protocolos-comparable-y-equatable-en-swift/protocolos-equatable-y-comparable-4894ba0e2779?source=rss-2bc6c0ffe8d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/4894ba0e2779</guid>
            <category><![CDATA[protocolo]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[protocol]]></category>
            <dc:creator><![CDATA[Bernardino Guerrero]]></dc:creator>
            <pubDate>Tue, 31 Oct 2017 18:05:28 GMT</pubDate>
            <atom:updated>2017-10-31T18:05:28.966Z</atom:updated>
            <content:encoded><![CDATA[<h3>Equatable.</h3><p>Si nosotros queremos comparar dos tipos de datos como String, Double, Int o cualquier otro tipo de dato nativo, tenemos el operador binario <strong>== </strong>que hará el trabajo requerido.</p><p>Ejemplo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*rV7z62pPpUyvurmN6TDfGA.png" /></figure><p>Pero ¿qué pasa, si nosotros queremos <strong>saber,</strong> si dos objetos de un tipo de dato creado por nosotros son iguales?, por ejemplo, del tipo de dato <strong>Cliente</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*4AuS28bWeS4yYqZxlp7ztg.png" /></figure><p>Lo primero que veremos es al compilador llorando 😂: “<strong>binary operator ‘==’ cannot be applied to two ‘Cliente’ operands</strong>”. De acuerdo: ya! no llores, vamos a solucionarlo. Lo primero que hay que hacer es conformar el protocolo <strong>Equatable.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*T5BdKVJJyiYGeoLUmAItwg.png" /></figure><p>Ahora si! una expresión del tipo cliente1 == cliente2, ya no dará problemas (yeh! 👏) y seremos capaces de saber si un cliente es igual a otro. Nótese que hemos implementado la función <strong>func == </strong>en una extensión.</p><p>Si nosotros en este punto ejecutamos el código, veremos que se imprime <strong>“Explícale los beneficios de ser tu cliente”, </strong>porque cliente1 y cliente2 <strong>no son</strong> iguales.</p><p><strong>IMPORTANTE: </strong>cuándo conformamos el protocolo <strong>Equatable</strong> es requerido que la implementación de <strong>==</strong> sea una relación de equivalencia (ehh? 🤔), es decir, que cumpla con las propiedades de reflexividad, simetría y transitividad. Vamos a meter al escenario unas cuantos objetos más de nuestra estructura cliente.</p><ol><li><strong>Reflexibidad</strong>: cliente_<strong>A</strong> == cliente_<strong>A</strong></li><li><strong>Simetría</strong>. cliente_<strong>A</strong> == cliente_<strong>B</strong> <strong><em>implica </em></strong>cliente_<strong>B</strong> == cliente_<strong>A</strong></li><li><strong>Transitividad</strong>. cliente_<strong>A</strong> == cliente_<strong>B</strong> <strong>&amp;&amp;</strong> clienteB == cliente_<strong>C</strong> <strong><em>implica </em></strong><em>cliente_</em><strong><em>A == </em></strong><em>cliente_</em><strong><em>C</em></strong></li></ol><p>En mi experiencia todo lo anterior se traduce a que debemos tener cuidado al comparar cada una de las propiedades de las clases en el cuerpo de <strong>func ==(lhs: Cliente, rhs:Cliente) -&gt; Bool</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36184d4bc1cc7f9bb40540b52e750667/href">https://medium.com/media/36184d4bc1cc7f9bb40540b52e750667/href</a></iframe><h3>Comparable</h3><p>Hasta este punto, nuestras objetos del tipo Cliente son capaces de saber si son iguales a otros. Vamos a suponer que necesitamos saber si un cliente es más antiguo que otro, para ello, se agregará a la estructura una popiedad de tipo entero llamado antiguedad (antigüedad).</p><p>Ojo sólo podemos saber si un cliente es igual a otro, comparando todas sus propiedades, pero no podemos usar ningún otro operador binario para saber si es mayor que, mayor igual que, menor, menor igual que.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc67515848f17bc30c2d1241d9f387bc/href">https://medium.com/media/fc67515848f17bc30c2d1241d9f387bc/href</a></iframe><p>Nuevamente haremos llorar al compilador y para corregirlo vamos a conformar el protocolo Comparable:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42d32addef4a7b1293cfcfeb382f9aaf/href">https://medium.com/media/42d32addef4a7b1293cfcfeb382f9aaf/href</a></iframe><p>Listo, ahora veremos que el resultado será (para nuestro ejemplo): “El cliente B es más antigüo”. Cómo te podrás imaginar implementar los otros operadores es realmente trivial, de todas maneras te dejo el link al repositorio, en dónde podrás encontrar toda la implementación.</p><p><a href="https://github.com/quantumB/Protocols/tree/master">quantumB/Protocols</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4894ba0e2779" width="1" height="1" alt=""><hr><p><a href="https://medium.com/protocolos-comparable-y-equatable-en-swift/protocolos-equatable-y-comparable-4894ba0e2779">Protocolos Equatable y Comparable</a> was originally published in <a href="https://medium.com/protocolos-comparable-y-equatable-en-swift">Swift en español</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>