Pre requisitos:
Las herramientas que necesitamos tener instaladas en nuestra maquina antes de empezar el tutorial son:
Node: https://nodejs.org/en/
ASP.net Core SDK (https://www.microsoft.com/net/download/core)
OR
Visual Studio 2017 (https://www.visualstudio.com/es/vs/whatsnew/) Esto instalara tambien las herramientas de ASP.NET Core. La version Community es de uso gratuito.
Podemos realizar todo el tutorial desde el simbolo de sistema, Pero prefiero mostrarles usando el 'Visual Studio Code' ya que me parece una herramienta excelente, gratuita y liviana, Asi que necesitaran bajarse el 'Visual Studio Code' si quieren hacerlo de esta manera.
Developer 'Extraordinaire'. .Net C#, PHP, JavaScript, SQL and IT enthusiastic. Also happily married father of four and avid book reader. This is my bilingual blog, please enjoy.
Tuesday, March 21, 2017
ASP Net Core y Angular 2 Facilmente
Etiquetas:
.NET,
Angular,
ASP.NET Core,
C#
Tuesday, March 7, 2017
Get Rid of 'Magic Strings'
'A magic string is an input that a programmer believes will never come externally and which activates otherwise hidden functionality.'
Basically is the term use to identify hard-coded strings inside our code. This strings are sometimes necessary in a program or at least can not be avoided in some situations (like dealing with legacy code).
The main problem with magic strings is that they are error prone, especially if used in more than one place, because we could mistype the magic strings and we will not get any compilation error or warning.
There are a couple of ways to deal with this.
Estas usando las propiedades de clases correctamente ?
Ultimamente estoy viendo mucho codigo escrito asi:
Tienes tus miembros privados, y creaste las propiedades publicas para ellos, Y estas feliz y sigues con tu vida. Pero te pregunto, hay algun problema en lo que vemos aqui ? Tomate un momento para pensarlo.
Veras, uno de los propositos de las propiedades es el de proteger los miembros privados. Pero si no hay anda de codigo en el getter o el setter de la propiedad, entonces no estamos protegiendo nada realmente, simplemente estamos pasando los valores al miembro privado tal como llegan.
Este es un error comun, creamos la clase e inmediatamente, casi inconsientemente, creamos las propiedades para nuestros miembros privados. Porque nos enseƱaron asi o porque programamos como robots. No va a causar ninguna excepcion y ciertamente puedes usarlas sin problemas si tienes validaciones en alguna otra parte, Pero no estas aprovechando las ventajas de uno de los objetivos de las propiedades.
Monday, March 6, 2017
Deshacerse de las 'Magic Strings' en C#
'Una magic string es un input que el programador cree que nunca vendra de una fuente externa y que activa funcionalidad que de otra manera estaria oculta.'
Basicamente el termino se usa para identificar a las cadenas existentes directamente en nuestro codigo (hard-codeadas). Testas cadenas sona veces necesarias en una aplicacion o al menos a veces no pueden ser evitadas en algunas situaciones (como cuando tenemos que lidiar con codigo antiguo).
El principal problema con las Cadenas Magicas es que son propensas al error, especialmente si son usadas en ams de un lugar de la aplicacion, porque podriamos aquivocarnos al teclarla y no tendriamos ningun error de compilacion o advertencia.
Hay un par de maneras de resolver esto.
Thursday, February 9, 2017
Are you using class properties correctly ?
I am getting used to see properties implemented this way:
So you have your private members, and you created the properties for those, so you are happy and go on with your life. But I ask, Is there anything wrong in what we see here? Take a minute to think about it.
You see, the purpose of the properties is to protect the private members. But if there is absolutely no code in the properties getter or setter, then we are not really protecting anything, we just pass the values to the private member as they come.
This is a common mistake, we create a class and immediately, almost unconsciously, we create the properties for our private fields. Because we were taught this way. It will not cause any exception and certainly you can use it without problems is you have validations elsewhere, But then you are not taking advantage of one of the purpose of properties.
Now suppose our age variable has to have valid range, Or that for reporting purposes you have to see a 'Not Available' when a person does not have an address registered. You could do this:
See, now we are really using the properties for something meaningful. This is just a small example. What do you think about that ? It certainly got ME thinking.
Subscribe to:
Posts (Atom)
