Wednesday, August 9, 2023

 

Code2Know


Boxing and Unboxing

Conversion of the value type to the reference type is known as boxing - implicit

V > O 
int v = 1; object o = v;

Converting the reference type back to the value type is known as unboxing - explicit

O > V
object o = 5; int v = (int) o;

CLR boxes a value type, it wraps the value inside a System.Object instance and stores it on the managed heap. 

HTTP Requests

 

HTTP methods,

It's good to know at least 9/39 of these methods:


GET Method: Gets data from a server.

POST Method: Sends data to a server to create something new.

PUT Method: Changes something that's already on a server.

PATCH Method: Changes part of something on a server.

DELETE Method: Removes something from a server.

HEAD Method: Gets information about something on a server.

OPTIONS Method: Tells you how you can interact with something on a server.

TRACE Method: This shows the path of communication between you and the server.

CONNECT Method: This makes a special kind of connection to a server.



Reference  




Thursday, May 23, 2019

Monolith Architecture

  • Monolith architecture is a traditional software development approach where an entire application is built as a single, indivisible unit.

  • All the components of the application, such as the user interface, business logic, and database access, are tightly coupled and packaged together.

  • Monolith architecture is often used for smaller applications or those with limited complexity.
  • Because all the components are contained within a single codebase, it's easier to develop, test, and deploy the application.

  • Monolith architecture can be faster to develop, particularly for simpler applications.

  • It's easier to debug errors in monolithic applications as they can be quickly traced back to the affected component.

  • Making changes to one part of the application can affect other parts, making it difficult to maintain and update as the application grows in complexity.

  • Monolithic applications can be difficult to scale, as all the components are tightly coupled and must be scaled together.

  • Monolith architecture is often contrasted with microservices architecture, where an application is broken down into smaller, independent services that communicate with each other over a network.

  • The choice between monolith and microservices architecture will depend on the specific needs and requirements of the application, as both approaches have their own advantages and limitations.

Monday, February 27, 2017

Dependency Injection usage in practically.....

DI is the concept where in framework comes in and injects the object rather than you creating it. (loosely coupled, decoupled with unnecessary work)

It helps to create classes that are loosely coupled and separate the logic dependency.

Applying dependency injection we can achieve re-usability, maintainability and write testable code

  • a
    • b




References:

http://codes2know.com/c-dependency-injection/

B' happiiiiiii always..............!

Thursday, July 7, 2016

Optimize code using Threading


Threading is quite helpful to optimize the performance of programming  

Parallel code execution
Processor given sometimes to execute one function and then other function parallel
  • Thread.Sleep 
    • synchronous
    • when want to block the current thread 
    • this help to run as individual thread

  • Task.Delay
    • asynchronous
    • when want only to delay the current thread without blocking
    • this help to run multiple thread at once


Sample code:




  • Foreground thread
    • thread will keep on running even though the main application is quit 
  • Background thread
    •  all the thread die if the main application quit

//Reference
using System.Threading;
using System.Threading.Task;

//Create thread
Thread obj1 = new Thread(Function1);
Thread obj2 = new Thread(Function2);

//Specially for background thread 
obj1.IsBackground = true;

//Invoke thread
obj1.Start();

static void Function1()
{
//do something 
//Wait 4 seconds
Thread.Sleep(4000);

}


References:

B' happiiiiiii always..............!

Wednesday, March 23, 2016

C#6 comes with new features..


Final version of C# 6 having been released, with couple of new features


  • Static Using Syntax
static qualifiers can be use as a namespace reference





  • Auto-Property Initializers

ability property inline initialization rather that and initialized through constructor




  • Dictionary Initializers & String Interpolation

cleaner way to  initialize the Dictionary and Concatenate strings together


  • NameOf Expression

handling exception with less codes



  • Expression Bodied Function & Property

functions and properties in lambda expressions save you from defining function and property statement block


  • Exception Filters

define specific catch block rather than specify a condition for a catch block



  • Await in a Catch and Finally Block

useful in log tracking without blocking, asynchronous code inside in a catch/finally block



  • Null Conditional Operator

released from NullReferenceException errors handeling


References:

B' happiiiiiii always..............!

Tuesday, August 11, 2015

how to work with SignalR

In real-time the server is aware of the data updates, event occurrences, etc.This is commonly achieved through methods like continuous polling, but this is incur a lot of traffic and load to the server.

So as an alternative SignalR is popup. SignalR is an Asp.Net library, which is designed to use the existing transport technologies underneath based on the client nature and the support it offers. 

This is capable of pushing the data to a wide variety of clients. So because of this new trend developers no need to worry about which server push transport but to use and deciding on the fallback in case of unsupported scenarios.

SignalR uses transports that are required to do real-time work between client and server. Each and every transports have its own requirement. So if these requirements are not met, SignalR will attempt to use other transports (one at a time) to make its connections.
  • WebSocket 
  • Server Sent Events
  • Forever Frame
  • Ajax long polling