Code Whisper
banner
codewhisper.bsky.social
Code Whisper
@codewhisper.bsky.social
👾 Anonymous engineer, sharing thoughts on code, tech & systems.
🚫 No face, just logic.

x.com/codewhisperdev
REST Tip – Use HATEOAS to guide the client

HATEOAS = Hypermedia as the Engine of Application State

📦 Instead of sending just data, include actions

🧠 Why?
• Makes APIs discoverable
• Reduces hard-coded logic on the client
• Enables better versioning and evolution
April 9, 2025 at 10:21 AM
Let’s talk about C# class types — a solid foundation for OOP in .NET.

You’ll find more than just “class” in C#. Let’s dive into the types you can define and use.
April 8, 2025 at 7:14 PM
HTTP Tip

Idempotent methods can be safely retried without causing side effects.
🔹 GET, PUT, DELETE, HEAD, OPTIONS → Idempotent
🔹 POST → NOT idempotent

🧠 Why?

Using the correct method:
▪️ Makes APIs predictable
▪️ Enables retries in network failures
▪️ Helps with caching, monitoring, and debugging
April 8, 2025 at 5:09 PM
SQL Tip – Avoid Scalar Functions in SELECT for Performance

🚫 Bad (Scalar function kills performance on large data)

✅ Good (Inline logic or apply in WHERE/CTE for better performance)

Example:
April 8, 2025 at 1:05 PM
.NET DI Lifetime Tips:

🔹 Singleton - one of instance for entire app
🔹 Scoped - one instance per request
🔹 Transient - new instance every time

🚨 Be careful:

- Dont inject Scoped/Transient into Singleton (causes bugs/memory leaks)
- Use Singleton only for stateless or thread-safe services.
April 8, 2025 at 12:13 PM
LINQ Tip:

Use ToList() after filtering, not before

Why?

🔹 First version loads everything into memory before filtering
🔹 Second version filters at source, better for DB or large collections
🔹 Especially important when using EF Core or APIs with IQueryable
April 8, 2025 at 10:03 AM
Efficient Async Data Streaming with IAsyncEnumerable<T>

Scenario:

You need to process a large dataset (e.g., database records, file lines, etc.), but you don’t want to load everything into memory at once. Using IAsyncEnumerable<T> lets you stream data asynchronously with minimal memory usage.
April 8, 2025 at 9:26 AM
🔹 What is Queue<T>?

Queue<T> is a First-In-First-Out (FIFO) collection in C#.
It means the first item you add is the first one to be removed.

When to use?

- Task scheduling
- Print jobs
- Message handling
- Breadth-first search (BFS) in graphs

Example:
April 7, 2025 at 7:51 PM
SQL Tip:

Always monitor and maintain your indexes.
Unused or duplicate indexes = slower writes and wasted space.

Why?
- Clean indexes = faster inserts/updates
- Less I/O, better performance

🔍 Use this to find unused indexes in SQL Server
April 7, 2025 at 7:16 PM
Csharp Tip:

Use Span for high-performance, allocation-free array slicing. Avoid ToList() when you don’t need it!

Why?
🔹 Zero allocations
🔹 Lightning-fast memory access
🔹 Perfect for performance-critical code

#csharp #dotnet
April 7, 2025 at 3:37 PM
LINQ Trip:

Use GroupJoin for efficient one-to-many relationships instead of nested loops.

Why?
🔹 Cleaner than SelectMany + Where
🔹 Ideal for creating master-detail structures in memory
April 7, 2025 at 11:41 AM
SQL Tip:

Use CROSS APPLY for row-wise calculations or to invoke table-valued functions per row.

Why?
🔹Powerful for row-by-row subqueries
🔹Cleaner & faster than correlated subqueries in many cases
April 7, 2025 at 8:18 AM
Csharp Tip:

Use async Task for methods so exceptions can be awaited and handled properly.

Pro tip: Use async void only for UI event handlers.
April 6, 2025 at 10:34 PM
Pass by Value vs Pass by Reference
🔹 Pass by Value: A copy of the value is passed to the function. Changes inside the function don’t affect the original variable.

🔹 Pass by Reference: The memory address (reference) is passed. Changes inside the function do affect the original variable.
April 6, 2025 at 8:23 PM
SQL Tip:

Use EXISTS instead of COUNT(*) > 0 for better performance when checking if rows exist.

✅ EXISTS stops at the first match.
❌ COUNT(*) scans the whole table.

Faster checks = faster queries ⚡
April 6, 2025 at 12:48 PM
EF Core Tip – Bulk Update:

Need to update thousands of rows? Avoid looping with .SaveChanges() in EF Core — it's slow.
Use a bulk update library like EFCore.BulkExtensions for massive performance gains.

Bonus: Works for Insert, Delete, Merge too.
April 6, 2025 at 12:33 PM
Csharp Tip:

Extract magic values into constants to improve readability and maintainability.

Cleaner code = easier maintenance!
April 6, 2025 at 10:04 AM
C# Trick:
Use Dictionary for fast lookups instead of looping!

Instead of searching a list repeatedly, store key-value pairs in a dictionary for O(1) access.
April 5, 2025 at 10:44 PM
SQL Trick:

Use COALESCE() to return the first non-null value from a list of columns or expressions.

Why it’s awesome:
• Handles null values seamlessly
• You can chain multiple options: COALESCE(col1, col2, 'default')

Cleaner queries, fewer CASE statements!
April 5, 2025 at 7:04 PM
Csharp Trick:

Use null-coalescing assignment ??= to simplify default value logic in C# 8.0+.

What it does:
If myList is null, assign it a new list.

Shorter, smarter and safer code!
April 5, 2025 at 3:56 PM
RESTful Tip – Filtering like a pro:
Support flexible filtering via query parameters, not custom endpoints.

Why?
🔹 Keeps your endpoints clean (/products stays consistent)
🔹 Easy to combine filters (e.g. by brand, price, rating)
🔹 Plays well with sorting & pagination
April 5, 2025 at 7:55 AM
LINQ Trick:

Use Any() instead of Count() > 0 for better performance when just checking for existance.

Any() stops at the first match, Count() goes through the whole collection. Speed matters!
April 5, 2025 at 5:38 AM
One more feature that definitely needs to be added to the this application is bookmarks.
April 4, 2025 at 10:31 PM
I’ve always wondered whether a new social media app could make its way among established and popular platforms like Instagram, X, or TikTok. Right now, I think Bluesky has the potential to do that.
April 4, 2025 at 8:44 PM
Let’s integrate into the app first.

One major issue: translations aren’t native; they rely on Google Translate. This needs to be properly implemented.
April 4, 2025 at 7:29 PM