Skip to main content

Posts

Showing posts from 2019

ASP NET CORE Facts

 It has an internal web server called Kestral that runs in coordination(collaboration) with the external webserver (assume IIS). The IIS invokes the .net runtime which looks for the main method in the application and executes it. This starts Kestral.  https://app.pluralsight.com/player?course=understanding-aspdotnet-core-2x&author=roland-guijt&name=1e5802e8-d4b6-4784-a8f6-93d1739c88ba&clip=9&mode=live Most versions of classic ASP. NET relied on an assembly in a. NET Framework called System. Web, which was tied to IIS. It is not suitable anymore for today's standards. It is around since classic ASP. NET version 1, and as ASP. NET progressed, stuffed with code to support all kinds of new features. Processing a request using System. Web isn't very efficient anymore for that reason in terms of memory usage and performance. Using the pipeline, youonly plug in what you need, and everything you plug in is in separate assemblies exposed in NuGet. System...

LINQ queries

string[] arr= new string[]{"Anish","Jeeba","Jiya"}; IEnumerable<string> obj= (from item in arr select $"{item} is my name").ToList(); using let  var result = from a in arr let name = a . StartsWith ( 'a' ) where name select a ; let acts as a temporary storage. List < List < SampleList >> sam = new List < List < SampleList >>{ new List < SampleList > { new List<SampleList> { new SampleList{Name="Anish", number=31, Gender="M"}, new SampleList{Name="Anish", number=61, Gender="M"} }, new List<SampleList> { new SampleList{Name="Jeeba", number=12, Gender="F"}, new SampleList{Name="Jiya", number=44, Gender="F"} }, new List<SampleList> ...

MongoDB

Download MongoDB from  https://www.mongodb.com/what-is-mongodb   Install MongoDb nuget package: MongoDB.Driver (Author: rstam.craigwilson) Service  ______________________________________________________________________ public interface IMongoService     {          Employee CreateEmployee(Employee employee);         void Delete(string id);         Employee GetEmployeeById(string id);         List<Employee> GetEmployees();         Employee Update(Employee employee);     } public class MongoService : IMongoService     {         IMongoCollection<Employee> _mongoCollection;         public MongoService(IOptions<EmpDatabaseSettings> options)         {             Options = options;          ...

Events and Delegates

Class with 2 events  public class Worker     {         // Created 2 events         public event EventHandler OnCompleted;         public event EventHandler<WorkerArgs> InBetween;         public void DoWork(int age, string address)         {             for (int i = 0; i < age - 1; i++)             {                 Thread.Sleep(1000);                  // Either this way                 //var del= InBetween as EventHandler<WorkerArgs>;                 //if (del != null) del(this,new WorkerArgs(i,address));                 // Or Directly             ...

Open Closed -

Open Closed SOLID was written during the early 90's when changing the code and republishing took a lot of time. Now it just takes minutes to redeploy the code. Also nowadays with the agile way of developing software changes are bound to happen. We often have this tendency to try to gold-plate things or say, well, we have this specific problem, but if we just set a specific flag here or add an input argument to this function here , we could make this specific thing that we're trying to do into some sort of general purpose solution, and the problem with that is that it tends to lead to coupling and complexity.  Reused Abstractions Principle. So this is not a principle that's a part of the five SOLID principles, but it's very much related to the five SOLID principles, and basically it says, if you have abstractions, in this case, if you have interfaces or abstract-based classes, and those abstractions are not being reused by being implemented by various different c...

Single responsibility

Single responsibility THINGS THAT BELONG TOGETHER SHOULD STAY TOGETHER What we're really aiming for when we're talking about SOLID code is supple code, code that's pliable, code that you can shape into different forms and where you can change the shape if it turns out that the original shape that you had in mind doesn't really correctly address the problem at hand. And this is very important, because you almost never have all the requirements up front. Even if you think you have all the requirements up front for a piece of software that you're programming, requirements change as you go along, and the point of writing SOLID code is to make the code so supple, so pliable, that when requirements change, you can also change the code to fit the new requirements. The purpose of SOLID is to make you more productive by making the code more maintainable. If the design is rigid, it signifies that does not accept change. We define a responsibility as a reason to change. ...

Extension Method To Compare 2 Objects

Extension Method To Compare 2 Objects https://stackoverflow.com/questions/10454519/best-way-to-compare-two-complex-objects  or use this public static class ObjectComparer {     public static bool CompareObj(this object source, object destination)     {         if (!source.GetType().Equals(destination.GetType()))             return false;         var properties = source.GetType().GetProperties();         foreach (var item in properties)             if (!item.GetValue(source, null).Equals(item.GetValue(destination)))                 return false;         return true;     } } Usage Create 2 classes. class Program     {         static void Main(string[] args)         {       ...