OOP #18

toop

We learned about the Encapsulation in OOP which is implemented by the six access modifiers for data and methods (public, private, protected, internal, protected-internal, private-protected [requires c# 7.2]) and the three modifiers for class (public, internal, private), how to add-reference from one project to another, Getters/Setters, for-each loop

modifiers2

UML:

access

More topics covered:

    • What are modifiers?
    • How to install c# 7.2
    • How to compile to c# 7.2
    • Default access modifiers (class/data/functions)
    • ILDASM “private ansi” is actual internal for class
    • private class
    • Circular reference  between projects
    • Creating two projects and add reference > solution
    • Using Setters to filter wrong data (i.e. negative height)
    • Static data could be used as configuration
    • Avoid repetition of values by using a bool[ ] array

Links:

 

21 NOV 2019

toop

We learned about static-data, static-methods, const, read-only, class data fields initialization step

Constantvsreadonly

static

More topics covered:

    • How to access static/const
    • Access static using a derived class
    • Creating static methods – design considerations
    • Const is replaced during compilation
    • Using static/const fields to define an array size
    • .NET Object class static methods
    • Static method can only call another static method

Links:

 

OOP #16

toop

virtual

We learned about ctor overloading, method overloading, using this keyword to call from one ctor to another, using this keyword to refer to class data fields, calling specific base ctor by using base key word, class Object, virtual methods

More topics covered:

    • All classes inherit from Object class
    • Using this.[field-name] in ctor, for example:
      Person(int id) { this.id = id; }
    • : this , for example:
      Person(int id) { this.id = id; }
      Person(int id, string name) :
              this(id) { this.name = name }
    • : base , for example:
      Person(int id) { this.id = id; }
      Employee : Person
      Employee(int id, string name) :
             base (id) { this.name = name }
    • Creating our own custom virtual methods
    • +Override our own custom virtual methods
    • Virtual vs. abstract
    • Passing arguments to console application using Command Prompt
    • Adding readme.txt into GITHUB folder

Links:

 

OOP #15

toop

ildasm

We learned about Common Intermediate Language (CIL), IL Disassembler (ILDASM.exe), IL Assembler (ILASM.exe), Class Constructors, default Constructor

More topics covered:

  • Adding ILDASM to Visual Studio 2017 Tools menu
  • Investigating our .NET class code using ILDASM
  • ctor key-word
  • Creating few ctors in the same class
  • Debug/Release configuration
  • Bin/Debug + Bin/Release folders
  • Creating auto generated constructor in Visual Studio 2017
  • Command Prompt (CMD)
  • Running our Console Application using the  Command Prompt
  • Users: guest, user, administrator
  • Converting executable .net file  (.exe) to Intermediate Language (IL) using ildasm.exe
  • Modifying Intermediate Language (IL) code using notepad
  • Converting Intermediate Language (IL) back to executable .net file  (.exe) using ilasm.exe, and run it again

Links:

 

18 NOV 2019

toop

We learned about inheritance, abstract classes, abstract methods, calling base.ToString(), class inside another class, array of classes, class as parameter type of a method

More topics covered:

  • Creating nested new: derived class inside parent class
  • Creating method which accepts a parent base class (shape). this allows you to send any derived class (i.e. circle, rectangle)
  • Abstract class – usually adding “Base” postfix, i.e. ShapeBase
  • Creating array of classes, create new items of each class inside
  • Polymorphism

Links:

14 NOV 2019

toopWe learned about the Object Oriented Programming (OOP) concept. we learned about classes, objects, data, functionality, inheritance, abstract, new, ToString

More topics covered:

  • Creating new Class
  • override ToString()
  • [DebuggerDisplay]
  • Object Initializer

Links: