Primeros pasos para empezar a programar y desarrollar software

Una de las primeras cosas que tienes que hacer es dejar las excusas a un lado, esto es primordial de otra manera te convencerás muy pronto de que no vale la pena seguir y solo perderás tu tiempo.

Una cosa que a mí me ha servido es escribir mis metas cuando empiezo con un proyecto, pero además de esto, también escribo las cosas que podrían empujarme a parar con el proyecto, las excusas.

Escribe una lista de excusas para evitarlas

Yo te recomiendo una lista simple de las cosas que normalmente piensas cuando te dan ganas de parar con un proyecto, por ejemplo:

  • No tengo tiempo
  • Es muy duro, no sé lo que estoy haciendo
  • Y que si no funciona?
  • No tengo motivación

Estas son algunas de las excusas que a lo largo de mi carrera me he inventado para reanimarme y parar mis proyectos. Tengo muchas más, pero estas son las que son comunes para varios de nosotros.

Escribir estas excusas y agregar una nota para responder a cada una de estas es una buena idea para que cuando se te presente cualquiera de estas en la mente, tengas una razón para convencerte de no parar y seguir adelante. Por ejemplo:

  • No tengo tiempo: Tiempo siempre hay, solo hay que darle la prioridad suficiente a nuestros proyectos, y reducir la cantidad de Netflix.
  • Es muy duro, no sé lo que estoy haciendo: Siempre que aprendes algo nuevo, te sentirás como un tonto/a en un principio, está bien, nadie es un experto para nada en un principio, y no hay nadie que lo sepa todo.
  • ¿Y que si no funciona? ¿La pregunta que te debes hacer es, y que pasa si no lo hago? ¿Si no trato? Como dice el dicho “Fallaras el 100% de los tiros que no intentaste”.
  • No tengo motivación: Esto es algo normal, ni te creas que estarás motivado todo el tiempo, nadie lo esta. Durante la vida de un proyecto, siempre hay latas y bajas, y la clave está en continuar, un paso a la vez.

Escribe metas a corto plazo que quieres obtener

Escribir metas a corto plazo que quieres obtener te ayuda a mantenerte enfocado. En un principio, cada vez que empezaba un proyecto solo tenía la meta final, o lo que yo pensaba que era la meta final en mente. Hacer esto no me ayudaba, ya que perdía el control de las cosas que tenían que suceder a corto plazo para poder lograr la gran meta.

Escribir y asignarte metas a corto plazo te ayuda a mantenerte enfocado, algo que es muy útil con proyectos largos y difíciles. Además, pensar y escribir metas cada semana (por ejemplo), te ayudará a evolucionar tu proyecto y te dará la flexibilidad de cambiar tus tareas conforme vas avanzando. Es normal que los proyectos acaben siendo muy distintos a lo que te imaginabas en un principio.

Ejemplo de metas a corto plazo cuando tu gran meta es aprender a programar:

Primera semana:

  • Instalar y configurar un editor de código o IDE, y aprender como utilizarlo.
  • Elegir un lenguaje de programación y aprender los comandos básicos.
  • Aprender como se organiza un proyecto de software utilizando el editor de texto o IDE que hayas instalado.
  • Bajar una aplicación de software open source y revisar el código fuente.

    Esta lista de arriba es un ejemplo de lo que podrías darte como tarea para aprender en tu primera semana, y es solo un ejemplo.

Elige un editor de código

El editor de código será tu herramienta principal como programador, y es por esto que te debes tomar tu tiempo y decidir cuál editor de texto te gusta más. En general, el editor de texto de Microsoft, VS Code, es muy popular, pero hay quienes prefieren o necesitan el editor más completo llamado Visual Studio.

También hay otros editores de código muy populares como:

En lo personal, te recomiendo empezar con VS Code, ya que es totalmente gratuito, es muy poderoso, y funciona muy bien con los lenguajes y librerías modernas.

Una vez que hayas elegido tu editor de código, te recomiendo que lo configures correctamente y que también aprendas como utilizarlo. Mientras más conozcas tus herramientas de trabajo, tu trabajo será más eficiente y agradable. Por ejemplo, si decides usar VS Code, te recomiendo este paquete de lenguaje de Español para hacer tu experiencia con VS Code más grata y en tu idioma.

También, puedes mejorar tu productividad y experiencia con VS Code instalando extensiones.

La configuración de texto de código depende en el que hayas elegido, puedes buscar por guías para hacer esto, hay muchas disponibles en la internet.

Elige un lenguaje de programación

Existen mucho programas de programación, muchísimos. Por esta razón, recomiendo pensar primero en la razón por la cual quieres aprender programación, la elección del lenguaje dependerá mucho de esto.

Por ejemplo, si quieres aprender a crear sitios y aplicaciones Web, el lenguaje que quieres aprender primero es probablemente JavaScript, y también el HTML (lenguaje de marcas de hipertexto), y CSS; estos son la base de los sitios en Internet.

Si tu interés en aprender programación es primordialmente para obtener un trabajo como programador, entonces te sugiero que veas cuáles son los lenguajes de programación más necesitados por empresas buscando por programadores.

Algunos lenguajes que son populares en este momento, son buenos para principiantes, y tienen mucha demanda laboral son los siguientes (no están en orden de popularidad):

  • JavaScript
  • Java
  • Python
  • C#
  • Swift
  • Go
  • PHP

Pero en realidad, mientras aprendas un lenguaje de programación y entiendas las mecánicas y fundamentos de cómo diseñar y crear aplicaciones con este será suficiente. Una vez que obtienes experiencia como programador, aprender un lenguaje no es tan difícil, la sintaxis será diferente, pero existirán muchas similitudes.

Aprender como crear y organizar un proyecto de software

Este punto se refiere a cómo organizar los archivos para que sea fácil trabajar con el código de tu aplicación de software. Cabe mencionar que esto puede ser algo muy básico, pero también se puede convertir en un dolor de cabeza, ya que existen muchas opiniones sobre cómo organizar los archivos en un proyecto de software.

Mi recomendación es tratar de seguir las mejores prácticas existentes para esto, y hacer modificaciones como lo necesites.

Aquí está un ejemplo de como está organizado una aplicación para un Blog creada con Ruby on Rails y utilizando el editor de código VS Code.

En la imagen de abajo puedes ver cómo la aplicación está contenida en un directorio con el nombre “blog”, y dentro de este existen otros directorios que describen los tipos de archivos que contienen.

Por ejemplo, dentro del directorio “blog” tenemos un directorio llamado “app” para la aplicación y dentro de este están el resto de los archivos.

Este es un ejemplo simple y muy claro de cómo puedes organizar tu código fuente para que sea más fácil trabajar con este. Además, te ayudará a diferenciar rápidamente el tipo de archivo y para que son utilizados:

screenshot of example Rails application

Baja una aplicación de fuente abierta “Open Source” y utilízala como una guía.

Esto es algo que siempre les recomiendo a todas las personas que les estoy ayudando a aprender programación. El beneficio de esto es obvio, es básicamente como leer libros y revisar cómo están escritos cuando quieres ser un escritor.

Existen muchas aplicaciones de fuente abierta que puedes bajar a tu computadora y usarlas como guía para aprender. Un lugar ideal para encontrar estas aplicaciones es GitHub, ahí encontrarás aplicaciones escritas con varios lenguajes de programación y distintas librerías de JavaScript.

Si estás interesada/o en aprender programación de sitios de Internet o aplicaciones Web, otra opción es bajar una planilla de HTML, existen varios lugares en donde las puedes encontrar. Un lugar que te recomiendo en este momento es Start Bootstrap.

¡Esto es todo por hoy amigos, hasta la próxima, échenle ganas!

magnifying glass on white paper

Debugging life

A simple idea on how we can log our lives to help us troubleshoot them later

In programming, we use the term debugging to describe the exercise of testing and digging into the code’s details and inner functions to find out the source of an issue. For example, debugging can occur by running the code and reading values in variables as the application runs, review database connections, analyze errors, review requests, and responses to and from an API, etc. Also, you can look at logs with details of application events such as errors to aid the debugging.

How do we use the same idea but instead of debugging software, we debug our lives? I like the idea of it. To try it, I am focusing even more on writing notes about my day, things that come to mind, and ideally whenever there is an event that makes me feel good, sad, angry, peaceful, etc. I want to remember these things, and one way of doing it is by writing them down.

When troubleshooting a software program, you need to reproduce an issue by running through the same steps multiple times to try and catch any information that might help you find the problem. As a software engineer, I can do this because we store information about events such as errors and other information about the application’s state before, during, and after an error occurs. This information is what allows us to debug the software.

In our lives, we cannot replay our day unless we are in the movie Groundhog Day (a great movie, by the way). But if we have information about our day, such as notes, calendar entries, etc. We can use that information to go back and help ourselves remember the events and our feelings on a specific day and time. Having this information might help us remember certain moments better and maybe even find out why we did something or feel a certain way today or in the future. That’s the life debugging part. It will help you replay a day in the past with the help of your notes. These notes might help you remember the why and how of something that happened in the past.

I don’t keep a formal diary or journal, but something that I have been doing for a while is writing notes about things I learn, things I do, and how I feel about them, and I do it in a concise form, just a few words or a sentence. It’s helpful and more effortless than keeping a diary. It’s a logbook. I use a Moleskine daily diary for this. It’s small but includes one page for each day of the year. I find it perfect for logging my day, it’s my logging system, and it works well.

Remembering things is very important, and the older I get, the more I realize that capturing some of the events in your life and how you feel most days is beneficial. Most of us expose ourselves to an incredible amount of distractions, there are many tasks in front of us every day, and unless you try to capture some of them in a permanent form, your mind won’t have the space or capacity to store them. So writing things down helps a lot.

I want to think that at some point, I’ll go back to my logbook and will read it to help me with something in the future. However, this might never happen. But by writing things down in a logbook, I seem to be more in touch with my feelings, and I’m able to recognize the good and bad things that happen many times during a day, every day. It helps me think.

Maybe one day, I’ll be able to upgrade my brain to a version that will include a feature to capture this information reliably without the need to write things down. Maybe it will even have more storage, so it’s easy to save everything in there and without any compression. But in the meantime, writing things down in this logbook is a hack that works for me, and this is how I do my life app work for me. What about you? How do you capture your day and important moments?

Don’t forget about character casing when comparing strings!

There are many issues I’ve experienced during the many, many years I’ve worked as a software developer. But one of the most recurring issues is, without a doubt, the mismatching of words due to character casing.

There are solutions to the character casing mismatch problem. For example, you can make your strings all lower case or upper case before comparing them. There are also many programming languages that have features to help with string comparisons.

The problem when comparing strings and case sensitivity

The issue is no longer the lack of solutions to avoid this problem. The problem is that these solutions require that you, the developer, be proactive by being alert and aware of case sensitivity when making string comparisons. For example, in C#, you have the StringComparer class, which includes properties like StringComparer.OrdinalIgnoreCase to help you ignore the character’s casing when comparing strings.

As a developer, you have to be alert and know when to ignore character casing. While there are many simple ways and tools built into programming languages, sometimes knowing when to do this might not be obvious.

For example, if you call GroupBy in C# and select the value you want your list to be grouped by, it will consider values such as “Abc” and “ABC” as unique, which might not be what you want to do.

In most cases, if you group a list of items by a specific string value, your intention is probably to treat the same values “Abc” and “ABC” as the same. Therefore, you’ll want to ignore the casing as the values are the same in this context.

Issues like the one with GroupBy in C# can go unnoticed until it causes problems. For example, I ran into this issue and didn’t realize the mistake until I tried to add the values of that grouped list to a dictionary and failed. The dictionary attempted to use the values “Abc” and “ABC” as the dictionary key, but it failed since these aren’t unique.

What can you do to avoid casing issues when comparing strings?

So what can you do about this? Code defensively. Every time you compare strings, consider character casing sensitivity and avoid it easily by converting all your strings to upper case or lower case before comparing. Second, be aware of the use cases where you are calling a built-in function such as GroupBy or ToDictionary as functions like this might be case-sensitive within your programming language.

With the programming language C#, you can use overloads that explicitly specify the string comparison rules for string comparisons. It works in this language by calling a method overload that has a parameter of type StringComparison.

In the example below, I’ll be using StringComparison.OrdinalIgnoreCase for comparisons for culture-agnostic string matching. The example shows you how not ignoring case sensitivity might give you unexpected results.

Examples in C#

Let’s declare a list of books with author names written using different casing

var books = new List<Book>()
{
new Book { Name = "Programa en donde sea", Author = "Ricardo" },
new Book { Name = "Empieza a programar", Author = "ricardo" },
new Book { Name = "Xyz", Author = "Joe" },
new Book { Name = "Despues de la programacion", Author = "RICARDO" },
new Book { Name = "Blah", Author = "Foo" }
};

Let’s group the list of books by Author, but since we are not doing anything to ignore case sensitivity, the result is not what’s expected – It returns five records instead of three as it treats all variations of the name Ricardo as unique values.

var notAUniqueListOfBooks = books.GroupBy(b => b.Author);

Now let’s group the same list of books by author, but this time let’s add a parameter to make the string comparison case insensitive. The result is only three records, that’s because it treats all the variations of the Author name Ricardo as the same value.

var aUniqueListOfBooks = books.GroupBy(b => b.Author, StringComparer.OrdinalIgnoreCase);

Let’s now create a dictionary from the list of books. This dictionary will use the Author value as the key, and both the book’s name and author as the value. The result is five items in the dictionary, again, because it treats each instance of the author name Ricardo as a unique value due to the difference in the casing.

var notAUniqueBookDictionary = books.ToDictionary(b => b.Author, b => b);

Finally, we’ll try to create a dictionary following the same attributes above, but this time, we’ll pass the parameter StringComparer.OrdinalIgnoreCase to make sure the comparison is case insensitive.

The result of this last one is an error with the following message:

“An item with the same key has already been added. Key: ricardo”

This is because since we are ignoring the casing in Author, we cannot create a dictionary as the key values are required to be unique and by ignoring the case of the different variations of the value Ricardo, these are no longer unique. They all end up being the same exact value.

var aUniqueBookDictionary = books.ToDictionary(b => b.Author, b => b, StringComparer.OrdinalIgnoreCase);

Finally, using the examples above, if you wanted to group by Author, and then create a list of all of their books including the name and author values then you could try using ToLookup, and pass the StringComparer parameter to make sure the string comparison in a case insensitive.

var aUniqueLookup = books.ToLookup(b => b.Author, b => b, StringComparer.OrdinalIgnoreCase);

The above will give you a dictionary where the key is the Author name and the value is a list of books including name and author. Also, by passing the StringComparer.OrdinalIgnoreCase parameter, we are making sure that the result is a unique list of values.

This is the result of our book list when converted into a Lookup object in C#. There are three keys, all unique, and under each key, we have a list of books that corresponds to the book’s author representing the Key value.

I hope this is useful, the code I used to test the examples above is all available here if you want to play with it and explore changing the values, parameters, etc. Cheers and happy coding!