@manhng

Welcome to my blog!

Write Clean Code

October 6, 2018 23:01

Write Clean Code (edit)

https://github.com/thangchung/clean-code-dotnet

https://www.codingblocks.net/software-development-tips-and-tricks/

Ternary Operator Example (? :)

return value = 10 ? true : false;

Null Coalescing Operator Example (??)

return artist ?? new Artist() {};

Prefer String interpolation

string temp = $"Name: {name}, Age: {age}";

Use expression bodied Methods

public string GetMessage() => return "Hello World";
public string Name => "Afzaal Ahmad Zeeshan"; 

A few things you should know prior to reading this guide:

  1. Improvements to C# that were made in its 6th version
  2. LINQ in .NET framework
  3. Asynchronous programming and Task object in C#
  4. Unsafe programming in C#, which allows you to go into memory management

Curly braces + Check null

public void Draw(Shape shape)
{
    if (shape == null)
        throw new ArgumentNullException("shape");

Tips & Tricks

October 3, 2018 16:24

Tips & Tricks (edit)

inurl: tips-tricks

https://gokulraja.wordpress.com/category/tips-tricks/

T3 Templates

https://www.codeproject.com/Articles/21162/Template-Based-Code-Generator

T4 Templates

https://www.tritac.com/blog/code-generationscaffolding-with-visual-studio-t4-templates/

http://paginaswebpublicidad.com/questions/40657/tuy-chon-gian-giao-tuy-chinh-asp-net-mvc-5-t4-templates

Dapper By Eample

https://www.tritac.com/blog/dappernet-by-example/

Generate SQL script (.SQL) from XML Schema (.XSD)

http://mssql.tools/Download.aspx?Id=118

JavaScript

http://crockford.com/javascript/

https://johnresig.com/blog/simple-javascript-inheritance/

OOP in JavaScript

  • Work effectively with JavaScript
  • JavaScript Built-in Functions
  • Prototype-based OOP
  • Class-based OOP
  • Pseudo-classes
  • Pseudo-elements

https://alistapart.com/article/prototypal-object-oriented-programming-using-javascript

In JavaScript, almost "everything" is an object.

  • Booleans can be objects (if defined with the new keyword)
  • Numbers can be objects (if defined with the new keyword)
  • Strings can be objects (if defined with the new keyword)
  • Dates are always objects
  • Maths are always objects
  • Regular expressions are always objects
  • Arrays are always objects
  • Functions are always objects
  • Objects are always objects

All JavaScript values, except primitives, are objects.

JavaScript defines 5 types of primitive data types:

  • string
  • number
  • boolean
  • null
  • undefined

Built-in methods

var message = "Hello world!";
var x = message.toUpperCase();

Adding a Method to an Object

person.name = function () {
return this.firstName + " " + this.lastName;
};

Prototype-based OOP

var genericAnimal = Object.create(null);

genericAnimal.name = 'Animal';

Class-based OOP

function Person(name) { ... }

var adam = new Person('Adam');

Categories

Recent posts