Big O Notations
OS
Race Condition
When two threads try to share resources and whoever gets first other gets bad data like getting balance before withdrawal
Deadlock
When two threads are waiting for the other to release the resource. now both threads are deadlocked.
thread A needs a Db connection which thread B has acquired lock on it and Thread B needs a File which A has locked. Now both be waiting for each other to release the locks.
Starvation
A thread is not able to acquire a resource that it wants to process because it is acquired by threads that have higher priority.
Mutex (mutual exclusive)
Semaphore
Live Lock
A Livelock is a situation where a request for an exclusive lock is denied repeatedly, as many overlapping shared locks keep on interfering each other. The processes keep on changing their status, which further prevents them from completing the task. This further prevents them from completing the task.
Asynchronous
When a program sends any request to the lower-level control, HTTP, file read or database, etc It doesn't wait for it to finish but the thread continues to do its work. it doesn't block anything.
Multiprocessing
Spin up multiple processes with their own memory and resources and divide tasks among them
Multithreading
Threads are part of a process that has access to the same memory
Cooperative multitasking vs Preemptive multitasking
Preemptive scheduling has to solve a hard problem -- getting all kinds of software from all kinds of places to efficiently share a CPU.
Cooperative scheduling solves a much simpler problem -- allowing CPU sharing among programs that are designed to work together.
So cooperative scheduling is cheaper and easier when you can get away with it. The key thing about small devices that allows cooperative scheduling to work is that all the software comes from one vendor and all the programs can be designed to work together.
Performance Optimization
Latency: The time to completion of a task. Measured in time units.
Throughput: The number of tasks completed in a given period. Measured in tasks/time unit, typical seconds.
SOLID PRINCIPLES
OOP
Interfaces vs Abstract classes with C# 8
- The interface is like a contract; you define to expose functionality however abstract class is an abstraction of some functionality or implementation.
- Interfaces can be multiply inherited and also structs can implement it but abstract class behaves like a class
- The conceptually derived class is a specialization of parent class but interfaces represent a common contract of the functionality. ConsoleLogger will be common functionality used, enhanced or extended version of BaseLogger but ConsoleLogger will implement ILogger defined functions.
- Interface Implementation is default implementation that means you can either use default implementation or override it but the abstract class's functionality is extendable.
- Multiple interfaces could be implemented and relation shouldn't be necessary "is a" but single base class exists and relation should be "is a" with the base class.
- avoid diamond problem, please
Design Patterns
Database
Relationships
- One to one: Either we keep column within same table or define foreign key in other table unique and not nullabke
- One to many: Foreign Key with in other table
- Many to many: A junction table with both tables ids in it.
Modeling
A non-cluster key is mapped as clustered-value in a tree. Once it finds the cluster key from the tree. now it can easily search on real data with a cluster key.
Operating Systems
.NET
Fundamentals
- .NET apps run managed code in a runtime environment known as the Common Language Runtime (CLR).
- The .NET CLR is a cross-platform runtime that includes support for Windows, macOS, and Linux. The CLR handles memory allocation and management. The CLR is also a virtual machine that not only executes apps but also generates and compiles code using a just-in-time (JIT) compiler.
- Higher-level .NET languages, such as C#, compile down to a hardware-agnostic instruction set, which is called Intermediate Language (IL). When an app runs, the JIT compiler translates IL to machine code that the processor understands. JIT compilation happens on the same machine that the code is going to run on. So, On run time .net compiles the app and optimizes it too.
- The default experience for most .NET workloads is the JIT compiler, but .NET offers two forms of ahead-of-time (AOT) compilation: iOS needs full AOT and ReadyToRun where dotnet produces ready to run if you describe ReadyToRun to True, OS and Processor too.
Working with unmanaged resources
Sometimes code needs to reference unmanaged resources. Unmanaged resources are resources that aren't automatically maintained by the .NET runtime. For example, a file handle is an unmanaged resource. A FileStream object is a managed object, but it references a file handle, which is unmanaged. When you're done using the FileStream, you need to explicitly release the file handle.
In .NET, objects that reference unmanaged resources implement the IDisposable interface. When you're done using the object, you call the object's Dispose() method, which is responsible for releasing any unmanaged resources. The .NET languages provide a convenient using statement (C#, F#, VB) that ensures the Dispose method is called.
- Source code (.cs) files are compiled into MSIL (Microsoft Intermediate Language) also known as CIL (Common Intermediate Language) or IL (Intermediate Language) along with its metadata. MSIL is machine independent.
- Metadata includes programming language, environment, version, and class libraries types, members, and references in your code.
- CLR contains JIT(Just In Time) compiler which converts MSIL to machine code to be executed on current machine.
- The MSIL code is only the managed code which CLR manages; everything else is called unmanaged code outside of scope of CLR (win32 apis, COM components) managed by OS.
- Common Type System (CTS) understands all the language types and translates it to the CLR. Reference types; allocates memory in the runtime and into the heap and Value Types; stored in the stack and memory is allocated at compile time.
- CLR helps common execution environment for more than 60 .Net Languages, memory management i.e garbage collection, sharing code and libraries across the languages,
- The Common Language Runtime in the .NET Framework is the Virtual Machine component that handles program execution for various languages such as C#, F#, Visual Basic .NET, etc. The managed execution environment is provided by giving various services such as memory management, security handling, exception handling, garbage collection, thread management, etc.
What is Heap and what is Stack?
- Both are memory locations, wherein Heap is global and Stack is local.
- The Heap is application-level while the Stack is thread-level.
- The Stack has a defined first-in-first-out stack structure, while the Heap does not have a defined data structure.
- Its size is defined at the time of its creation. For Heap, the size is defined when starting the application and for Stack, when creating a thread.
- Both can grow dynamically.
- The Stack is faster than the Heap. A stack is in “cache” and doesn’t have to synchronize with other threads like the Heap.
- The Stack stores values while the Heap stores objects.
Roslyn (Library, API): Compiles, Provide Diagnostic, Analyze Code.
Compile Time Vs Run Time
C#
Types
- Value types are sealed
- All primitive types, enums and structs are value types.
Reference types
- A type that is defined as a class, delegate, array, or interface is a reference type
- On Declaration they have value of null by default
Nullable types
? after the type. For example, int? is an int type that can also have the value null. Nullable value types are instances of the generic struct type System.Nullable<T>. Nullable value types are especially useful when you're passing data to and from databases in which numeric values might be null. For more information, see Nullable value types.Entity Framework Core
Entity Framework (EF) Core is an open source and cross-platform data-access technology that can serve as an ORM. EF Core lets you work with a database by referring to .NET objects in code. It reduces the amount of data-access code you would otherwise need to write and test. EF Core supports many database engines.
For more information, see Entity Framework Core and Database Providers.
LINQ
Language-integrated query (LINQ) lets you write declarative code for operating on data. The data can be in many forms (such as in-memory objects, a SQL database, or an XML document), but the LINQ code you write typically doesn't differ by data source.
For more information, see LINQ (Language Integrated Query) overview.
ASP.NET
WebAPI
SOAP:
soap has built-in retry logic, has WS security built-in, has WSDL file for function definition
Rest API: A Design Approach
Verbs
Best Practises
Throating
Authentication/Authorization
OAuth
Angular
Ajax
Javascript
HTTP
CSS
HTML
Microservices
Event Driven Archetecture
Cloud Archetecture
TDD
Unit Test
Integration Test
Functional Test
BDD
Cache
Queues
Version Control
CI/CD
MSBuild and the .NET CLI can be used with various continuous integration tools and environments, such as:
No comments:
Post a Comment