Programming Tips πŸ’‘
54.5K subscribers
65 photos
8 videos
30 files
338 links
Programming:
Tips πŸ’‘
Articles πŸ“•
Resources πŸ‘Ύ
Design Patterns πŸ’Ž
Software Principles βœ…

πŸ‡³πŸ‡± Contact & Ads: @MoienTajik
Download Telegram
Using Random on the production may put you in a trouble❗️


What is a random number❓

Well, even if you have never read any definition, you can still answer that question pretty easy. πŸ€·πŸ»β€β™‚οΈ

It’s the unpredictable result of some action like throwing a dice. 🎲

We just can’t predict what the next number will be. ❌

In a real world, randomness is kind of natural thing, but it starts to be more complicated when it comes to machines. πŸ’»

Why❓Simply because of their deterministic characteristic which makes it really hard to generate random numbers (but it’s still possible). βœ…

That’s why in most of the time we use the pseudorandom numbers – they look like a random but they are the result of some mathematical algorithms.⚑️

Are they used in generator offered in C#❓
Let’s find out. πŸ€“


https://t.me/pgimg/166

[ Article ] : kutt.it/rnd

γ€°γ€°γ€°γ€°γ€°γ€°
#CSharp #Random
@ProgrammingTip
Span πŸŒ€

C#
gives us great flexibility when it comes to using different kinds of memory. πŸ’Ž

But the majority of the developers use only the managed one. πŸ€·πŸ»β€β™‚οΈ

Use Span to work with ANY kind of memory in a safe and very efficient way. Simplify your APIs and use the full power of unmanaged memory❗️


https://t.me/pgimg/170

[ Article ] : adamsitnik.com/Span

γ€°γ€°γ€°γ€°γ€°γ€°
#CSharp #DotNet
@ProgrammingTip
Pose πŸ‘₯

Replace any .NET method (including static and non-virtual) with a delegate. πŸ’Ž

It is similar to Microsoft Fakes but unlike it Pose is implemented entirely in managed code (Reflection Emit API).✨

Everything occurs at runtime and in-memory, no unmanaged Profiling APIs and no file system pollution with re-written assemblies.⚑️


Example Usage πŸ”₯:

Shim static property getter
⏱:

Shim dateTimeShim = Shim.Replace(() => DateTime.Now).With(() => new DateTime(2004, 4, 4));


Usage πŸ‘Ύ:

// This block executes immediately
PoseContext.Isolate(() =>
{
// All code that executes within this block
// is isolated and shimmed methods are replaced

// Outputs "4/4/04 12:00:00 AM"
Console.WriteLine(DateTime.Now);
}, dateTimeShim);


https://t.me/pgimg/179

[ Github ] : github.com/tonerdo/pose

γ€°γ€°γ€°γ€°γ€°γ€°
#CSharp #DotNet #Fake
@ProgrammingTip
Reinforced.Typings ⚑️

Converts C# classes to TypeScript interfaces (and many more) within project build. πŸ’Ž

Examples ✨ :

C#
β™₯️ :

[TsInterface]
public class Order
{
public string ItemName { get; set; }
public int Quantity { get; set; }
public double Subtotal { get; set; }
public bool IsPaid { get; set; }
public string ClientName { get; set; }
public string Address { get; set; }
}

[TsClass]
public class User
{
public string FirstName { get; set; }
public string Email { get; set; }
public UserType Type { get; set; }
}

[TsEnum]
public enum UserType { One, Two }


Result => TypeScript πŸ’™ :

export interface IOrder
{
ItemName: string;
Quantity: number;
Subtotal: number;
IsPaid: boolean;
ClientName: string;
Address: string;
}

export class User
{
public FirstName: string;
public Email: string;
public Type: MyApp.UserType;
}

export enum UserType {
One = 0,
Two = 1,
}


https://t.me/pgimg/188


[ Github ] : kutt.it/csts

〰️〰️〰️〰️〰️〰️
#CSharp #TypeScript
@ProgrammingTip
Mapster πŸ”₯

A fast, fun and stimulating object to object .NET Mapper. ⚑️

Don't let other libraries slow you down, raw Mapster performance is at least 2.5 times faster❗️


https://t.me/pgimg/192

[ Github ] : kutt.it/mapster

[ Performance Benchmark ] : kutt.it/mapbnch

〰️〰️〰️〰️〰️〰️
#Mapper #Mapster #CSharp
@ProgrammingTip
Blazor, web framework for browser-based .NET apps πŸ”₯

Today, nearly all browser-based apps are written in JavaScript (or similar languages that transpile to it). πŸ‘πŸ»

That’s fine, but there’s no good reason to limit our industry to basically one language when so many powerful and mature alternate languages and programming platforms exist. ⚑️

Starting now, WebAssembly opens the floodgates to new choices, and one of the first realistic options may be .NET. πŸ’Ž

Blazor is a new experimental web UI framework from the ASP.NET team that aims to brings .NET applications into all browsers (including mobile) via WebAssembly. ✨

It allows you to build true full-stack .NET applications, sharing code across server and client, with no need for transpilation or plugins. ✌🏻

In this talk I’ll demonstrate what you can do with Blazor today and how it works on the underlying WebAssembly runtime behind the scenes. πŸŒ€

You’ll see its modern, component-based architecture (inspired by modern SPA frameworks) at work as we use it to build a responsive client-side UI. 🌈

I’ll cover both basic and advanced scenarios using Blazor’s components, router, DI system, JavaScript interop, and more. πŸ’™


Don't miss this talk, that's awesome ! ⭐️

[ Video ] : kutt.it/blz

〰️〰️〰️〰️〰️〰️
#Blazor #WebAssembly #CSharp
@ProgrammingTip
C# 8 Interfaces: Dangerous Assumptions in Default Implementation ⚠️

One of the features that is being promoted about C# 8 interfaces is that we can add members to an interface without breaking existing implementers. βœ…

But we can cause a lot of pain if we aren't careful. πŸ€·πŸ»β€β™‚οΈ

Let's look at some code that makes bad assumptions so that we can understand the importance of avoiding these problems. ⛔️


[ Article ] : kutt.it/csdif

〰️〰️〰️〰️〰️〰️
#CSharp #Interfaces
@ProgrammingTip
Using the ReferenceAssemblies NuGet package to build .NET Framework libraries on Linux, without installing Mono πŸ’Ž

In this post I show how you can build .NET projects that target .NET Framework versions on Linux, without using Mono! πŸ€·πŸ»β€β™‚οΈ

By using the new Microsoft.NETFramework.ReferenceAssemblies NuGet packages from Microsoft you don't need to install anything more than the .NET Core SDK! πŸ”₯


[ Article ] : kutt.it/coremono

〰️〰️〰️〰️〰️〰️
#CSharp #DotNet #AspCore #NetCore
@ProgrammingTip
EasyCompressor πŸ“¦

EasyCompressor is an open-source compression abstraction library that supports and implements many compression algorithms such as Zstd, LZMA, LZ4, Snappy, Brotli, GZip and Deflate. πŸ—‚

It is very useful for using along with Distributed Caching or storing files in database. βœ…

[ GitHub ] : github.com/mjebrahimi/EasyCompressor

〰️〰️〰️〰️〰️〰️
#Compression #CSharp #DotNet
@ProgrammingTip