Archives

Archives / 2016 / April
  • C# and continue operator in cycles

    Hello everybody,

    today I want to write a notice about word continue in C#. 

    So, how it look like:

    for( int i = 0; i < 10; i++ )

    {

         if(i == 5)

         {

              continue;

         }

        //do some other staff

    }

    In this code, //do some other staff will be executed only 9 times, because for fifth it is written as continue. Continue can be compared to situation, when you bust some boxes, but then you see, that some box doesn't feet to your needs. Then you'll say to C# compiler, skip the box, and continue to bust another boxes. more

  • Saving of typing in TypeScript

    Hello everybody,

    today I want to show two ways of declaring properties in TypeScript.

    Take a look at the following TS code:

    class Animal {

        name: string;

        constructor(name: string) {

            this.name = name;

        }

    }

    Here we declared class Animal, with public property name, and we initialized it in construction. But in TS there is another way of shortcutting this way:

    class Animal {

        constructor(public  name: string) {

            this.name = name;

        }

    }

    With TypeScript you can not only pass members for initialization, but also to declare paramethers of constructor as members of class and also configure access modifiers. more

  • TypeScript notes

    Hello everybody,

    today I want to make some notes of type script, or if to spell it correctly TypeScript.

    So, few words about TS.

    File extensions for TypeScript is .ts. 

    TypeScript is superset of javascript which means that TypeScript understands javscript code. Also for execution TypeScript gots trasplied to javascript. 

    What means transpilation? If to take analogy from C#, it looks like this:

    wonderfulProgram.cs -> C# compiler -> wonderfulProgram.dll 

    Now let compare it with TypeScript:

    wonderfulProgram.ts -> TypeScript compiler ->  wonderfulProgram.js

    Another important part of TypeScript is strong typing:

    JavaScript

    TypeScript

    var x;

    x = 67;

    x='some string'

    x = … more

  • TypeScript Interfaces

    Hello everybody,

    today I want to add another post, about interfaces in TypeScript.

    So, if to put simply, interface is something like declaration of purpose or even some kind of promise. Consider it like your class gives promise that he will implement members of that interface. 

    For exampl interface may look like this:

    interface IBookManager{

    managerName: string;

    photo: string;

    getBooks: any[];

    takeBook(book : string): void;

    }

    It gives us assurance, that class inheritor will implement for us needed properties and methods as well. 

    more

  • CQRS in in C# most trivial possible example

    Hello everybody,

    today I want to make compendium of CQRS for very simple case.

    So, at one of the projects I seen following way of implementing code:

    public class WriteModel

    {

    //common properties

    public int SomeEntity {get;set; } // ID of some entity

    }

    public class ReadModel : WriteModel

    {

    public string AdditionalProperty {get;set; }

    }

    and that way of implementing it was proudly named CQRS. To be honest I wasn't very agreeable on that part, so I decided to hear opinions of other people, not only mine understanding of what I read in book.

    And I'd like to save one of the comments not only at stackoverflow, but also at my web site.

    So, what's wrong with … more