Skip to content

Instantly share code, notes, and snippets.

View ggMartinez's full-sized avatar

Gonzalo Martinez ggMartinez

  • UTU - Trillonario
  • Montevideo
View GitHub Profile
@ggMartinez
ggMartinez / switchIsBad.md
Last active July 25, 2022 13:35
Porque no usar Switch?

Porque no usar Switch?

El maldito Switch

Cuando escribimos codigo, a veces usamos la sentencia Switch/Case. Es tentador. Nos enseñaron que "son buenos". "Soluciona" un problema de "forma eficiente".

Es parte de los lenguajes, esta ahi y funciona. Pero siempre recuerden: que algo funcione, no quiere decir que este bien hecho o sea correcto.

El problema con Switch/Case, es que no es mantenible. Es imundo. Es profano. Es sucio. Es muy 1990. Switch viola un lote de buenas practicas modernas de desarrollo, acuerdos internacionales, derechos humanos y acuerdos intergalacticos.

@ggMartinez
ggMartinez / connection.cs
Created September 25, 2021 06:51
SOLID principle - Single responsability - Good example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
namespace MyDataManipulationApp{
@ggMartinez
ggMartinez / badExample.cs
Last active September 25, 2021 06:54
SOLID principle - Single responsability - Bad example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
namespace MyDataManipulationApp{
@ggMartinez
ggMartinez / transaccion
Last active July 16, 2020 01:52
Ejemplo Transaccion VB.NET
Public Sub Agregar()
Comando.CommandText = "SET AUTOCOMMIT = OFF"
Comando.ExecuteNonQuery()
Comando.CommandText = "LOCK TABLES PERSONA,PERSONA_TEL READ"
Comando.ExecuteNonQuery()
Comando.CommandText = "START TRANSACTION"
Comando.ExecuteNonQuery()