Traning Basic Concepts
Traning Basic Concepts
programming (C#)
Object-oriented programming (OOP) is a computer programming model that organizes software design
around data, or objects, rather than functions and logic. An object can be defined as a data field that has
unique attributes and behavior.
https://www.techtarget.com/searchapparchitecture/definition/object-oriented-programming-OOP
C# is an object-oriented programming language.
https://en.wikipedia.org/wiki/Object-oriented_programming
C# is an object-oriented programming language.
Procedural programming is about writing procedures or methods that perform operations on the data,
while object-oriented programming is about creating objects that contain both data and methods.
https://www.w3schools.com/cs/cs_oop.php
The four basic principles of object-oriented
programming are
Abstraction Modeling the relevant attributes and interactions of entities as classes to define an
abstract representation of a system.
Encapsulation Hiding the internal state and functionality of an object and only allowing access
through a public set of functions.
https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/tutorials/oop
Abstraction
Abstraction can be implemented using abstract classes in C#. Abstract classes are base classes with
partial implementation. These classes contain abstract methods that are inherited by other classes that
1. The abstract class is created using the keyword abstract and some of the methods of the abstract
3. The abstract methods in the abstract class are implemented actually only in the derived classes.
4. If all the methods in the abstract class contain the keyword abstract, then that class is known as
https://www.knowledgehut.com/tutorials/csharp/csharp-abstraction
Encapsulation
What Does Encapsulation Mean?
Encapsulation, in the context of C#, refers to an object's ability to hide data and behavior that are not
necessary to its user. Encapsulation enables a group of properties, methods and other members to be
https://www.techopedia.com/definition/3787/encapsulation-c#:~:text=Encapsul
ation%2C%20in%20the%20context%20of,a%20single%20unit%20or%20obje
ct.
Encapsulation
Encapsulation is used to restrict access to the members of a class so as to prevent the user of a given
class from manipulating objects in ways that are not intended by the designer. While encapsulation
hides the internal implementation of the functionalities of class without affecting the overall
functioning of the system, it allows the class to service a request for functionality and add or modify its
https://www.techopedia.com/definition/3787/encapsulation-c#:~:text=Encapsul
ation%2C%20in%20the%20context%20of,a%20single%20unit%20or%20obje
ct.
Inheritance in C# and .NET
This tutorial introduces you to inheritance in C#. Inheritance is a feature of object-oriented
programming languages that allows you to define a base class that provides specific functionality (data
and behavior) and to define derived classes that either inherit or override that functionality.
https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/tutorials/inheritan
ce
Polymorphism in C#
The name polymorphism implies one word having many forms. In programming, this means that an
object can have multiple functionalities. Polymorphism is one of the fundamental concepts in object-
oriented programming.
There are mainly two types of polymorphism i.e static polymorphism and dynamic polymorphism.
Static Polymorphism
Static polymorphism or early binding involves linking a function with an object during compile time.
The two major techniques to implement static polymorphism are function overloading and operator
https://www.knowledgehut.com/tutorials/csharp/csharp-polymorphism
Polymorphism in C#
Function Overloading
In function overloading, there can be multiple definitions for the same function name. All of these
definitions may differ by the number of arguments they contain or the type of these arguments.
At the compile time, the number and type of arguments passed are checked by the compiler and on that
basis a function is called. There is an error if there is no function matching the parameter list.
https://www.knowledgehut.com/tutorials/csharp/csharp-polymorphism
Interface
Interface (C# Reference)
An interface defines a contract. Any class or struct that implements that contract must provide an
implementation of the members defined in the interface. Beginning with C# 8.0, an interface may
define a default implementation for members. It may also define static members in order to provide a
single implementation for common functionality.
In the following example, class ImplementationClass must implement a method named SampleMethod
that has no parameters and returns void.
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/interface
Abstract
The abstract modifier indicates that the thing being modified has a missing or incomplete
implementation. The abstract modifier can be used with classes, methods, properties, indexers, and
events. Use the abstract modifier in a class declaration to indicate that a class is intended only to be a
base class of other classes, not instantiated on its own. Members marked as abstract must be
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/a
bstract
Sealed (C# Reference)
When applied to a class, the sealed modifier prevents other classes from inheriting from it. In the
following example, class B inherits from class A, but no class can inherit from class B.
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/se
aled
Generic
Generic classes and methods
Generics introduces the concept of type parameters to .NET, which make it possible to design classes
and methods that defer the specification of one or more types until the class or method is declared and
instantiated by client code. For example, by using a generic type parameter T, you can write a single
https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/types/generics
Using
Using statement (C# Reference)
Provides a convenient syntax that ensures the correct use of IDisposable objects. Beginning in C# 8.0,
the using statement ensures the correct use of IAsyncDisposable objects.
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement
Boxing and Unboxing
Boxing is the process of converting a value type to the type object or to any interface type implemented
by this value type. When the common language runtime (CLR) boxes a value type, it wraps the value
inside a System.Object instance and stores it on the managed heap. Unboxing extracts the value type
from the object. Boxing is implicit; unboxing is explicit. The concept of boxing and unboxing underlies
the C# unified view of the type system in which a value of any type can be treated as an object.
boxing-and-unboxing
Mutex Class
mutex
Semaphore Class
Limits the number of threads that can access a resource or pool of resources concurrently.
semaphore
Iterators Class
Almost every program you write will have some need to iterate over a collection. You'll write code that
examines every item in a collection.
iterators
try-catch-finally
(C# Reference)
A common usage of catch and finally together is to obtain and use resources in a try block, deal with
exceptional circumstances in a catch block, and release the resources in the finally block.
For more information and examples on re-throwing exceptions, see try-catch and Throwing Exceptions.
For more information about the finally block, see try-finally.
try-catch-finally
SOLID
● Single responsibility principle - Class has one job to do. Each change in requirements can be
done by changing just one class.
● Open/closed principle - Class is happy (open) to be used by others. Class is not happy (closed) to
be changed by others.
● Liskov substitution principle - Class can be replaced by any of its children. Children classes
inherit parent's behaviours.
● Interface segregation principle - When classes promise each other something, they should
separate these promises (interfaces) into many small promises, so it's easier to understand.
● Dependency inversion principle - When classes talk to each other in a very specific way, they
both depend on each other to never change. Instead classes should use promises (interfaces,
parents), so classes can change as long as they keep the promise
https://simple.wikipedia.org/wiki/SOLID_(object-oriented_design)
SOLID
● Documents -
Solid - Document
DRY
The term "don't repeat yourself" was coined in 1999 by Andy Hunt and Dave Thomas in their book
The Pragmatic Programmer. They defined it as "Every piece of knowledge must have a single,
unambiguous, authoritative representation within a system."
https://zapier.com/blog/dont-repeat-yourself/
YAGI
"You aren't gonna need it"[1][2] (YAGNI)[3] is a principle which arose from extreme programming
(XP) that states a programmer should not add functionality until deemed necessary.[4] Other forms of
the phrase include "You aren't going to need it" (YAGTNI) [5][6] and "You ain't gonna need it"
(YAGNI).[7]
https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it
Behaviour Driven Development
What Is BDD ( Behaviour Driven Development)?
The most important part of the project is the development phase. BDD is a technique that enables you
to make the process easier by breaking up the project into smaller tasks and then concluding solutions.
Development is a pretty challenging and complicated phase of a project, and resultantly many teams
tend to miss the key elements. This vital element of the development process is to fulfill the specific
requirements of a business. To overcome these problems, top software development companies start
their development project with a defined approach. The main goals and power of the software
development cycle are based on a progressive and defined approach.
https://www.clustox.com/what-is-bdd-the-role-scope-and-benefits-of-bdd-in-software-development/
#:~:text=Principles%20of%20BDD%3A&text=We%20must%20not%20do%20less,or%20ability%20to
%20deliver%20outcomes.
Microservices
What are microservices?
Microservices - also known as the microservice architecture - is an architectural style that structures an
application as a collection of services that are
● Highly maintainable and testable
● Loosely coupled
● Independently deployable
● Organized around business capabilities
● Owned by a small team
The microservice architecture enables the rapid, frequent and reliable delivery of large, complex
applications. It also enables an organization to evolve its technology stack.
https://microservices.io/
Monolithic Architecture
What is monolithic architecture?
A monolithic architecture is the traditional unified model for the design of a software program.
Monolithic, in this context, means "composed all in one piece." According to the Cambridge dictionary,
the adjective monolithic also means both "too large" and "unable to be changed."
Monolithic architecture for software explained
Monolithic software is designed to be self-contained, wherein the program's components or functions
are tightly coupled rather than loosely coupled, like in modular software programs. In a monolithic
architecture, each component and its associated components must all be present for code to be executed
or compiled and for the software to run.
monolithic-architecture
Microservices vs Monolithic Architecture
Microservices vs. monolithic architecture
In 2009 Netflix faced growing pains. Its infrastructure couldn’t keep up with the demand for its rapidly
growing video streaming services. The company decided to migrate its IT infrastructure from its private
data centers to a public cloud and replace its monolithic architecture with a microservices architecture.
The only problem was, the term “microservices” didn’t exist and the structure wasn’t well-known.
Microservices-vs-Monolithic Architecture
Behaviour Driven Development
What Is BDD ( Behaviour Driven Development)?
The most important part of the project is the development phase. BDD is a technique that enables you
to make the process easier by breaking up the project into smaller tasks and then concluding solutions.
Development is a pretty challenging and complicated phase of a project, and resultantly many teams
tend to miss the key elements. This vital element of the development process is to fulfill the specific
requirements of a business. To overcome these problems, top software development companies start
their development project with a defined approach. The main goals and power of the software
development cycle are based on a progressive and defined approach.
https://www.clustox.com/what-is-bdd-the-role-scope-and-benefits-of-bdd-in-software-development/
#:~:text=Principles%20of%20BDD%3A&text=We%20must%20not%20do%20less,or%20ability%20to
%20deliver%20outcomes.