Posts

C# Singletons

C# Singletons Dependency Injection ( .NET Core) : builder.Services.AddSingleton<ILoggerService, LoggerService>(); Lazy<T>  ( .NET 4+) : public sealed class Logger {     // 1. Lazy<T> ensures thread-safe, deferred initialization     private static readonly Lazy<Logger> _instance = new Lazy<Logger>(() => new Logger());     // 2. Public global access point     public static Logger Instance => _instance.Value;     // 3. Private constructor prevents external instantiation     private Logger() { // Initialization logic here }     public void Log(string message) { Console.WriteLine($"[LOG]: {message}"); } } Logger.Instance.Log("Application started."); Old Ways: 1) not thread safe 2) lock 3) x2 lock 4) not quite as lazy, but thread-safe without using locks 5) fully lazy instantiation 

Salesforce B2B Replacement

Salesforce B2B Replacement to Azure Piece 1: Build a B2B portal with sign-on landing page with multi-tenant. Build your portal UI screens in React to ensure sub-second page loads over complex B2B workflows like bulk ordering or custom quoting. Build a portal interface that lets your customers' admins invite, deactivate, and assign roles to their own team members without opening support tickets.  Launch the new portal initially as a fast, read-only hub for order history, invoices, and account details fed by your synced DB and a read-only dashboard with totals. Piece 2: Build a dedicated .NET API layer that sits between your new portal UI and Salesforce. The Backend-for-Frontend pattern aggregates data, handles caching, and abstracts Salesforce's proprietary API limits from the frontend.  Use Salesforce's OpenAPI 3.0 Generator requesting only the specific SObjects (e.g., Account, Contact, Custom_Order__c) and endpoints you actually use resulting in OpenAPI YAML/JSON.  ...

Security

Security Identity, Claims, and Roles • Identity: This represents who the user is, typically verified through an authentication provider and represented by a unique user ID. • Claims: These are key-value pairs embedded in a token that assert facts about the user, such as their email, tenant_id, or organization_id. • Roles: Roles group permissions together (e.g., Admin, Viewer, BillingManager) to determine what broad actions an identity is allowed to perform. JWT and OAuth 2.0 • OAuth 2.0: This framework handles delegated authorization, allowing an application to obtain limited access to user accounts without exposing credentials. • JSON Web Tokens (JWT): A JWT is a compact, cryptographically signed token used to securely transmit claims between parties. • Token Verification: Your server must validate the JWT signature, expiration (exp), issuer (iss), and audience (aud) on every incoming request before reading any claims. Server-Side Authorization • Zero Trust on Client Inputs: Never rel...

React

React 1) vanilla useEffect state tracking for "side effects" like APIs, event listeners, timers, and cleanup. Talk about the "ignore flag" cleanup pattern inside useEffect to drop stale promises when components unmount or dependencies change. Versus declarative, hook-based data-fetching library (like v4 TanStack Query   was React Query v1-3)  useMutation auto receives isPending, isError and isSuccess flags.      useEffect fires asynchronously after the browser paints the screen to keep the application responsive. useLayoutEffect fires synchronously after DOM mutations but before the browser paints. Using useLayoutEffect blocks the paint loop, causing slight performance penalties, but it prevents visual layout flickers when calculating element dimensions or positions dynamically.   2) export interface OrderRequest { ... fields ... } to keep DTO in synch. (Tools like TypeGen , NSwag , or Typewriter ). 3) Q: Problem with lots of re-renderi...

AI Advantages and Disadvantages

  AI Advantages and Disadvantages AI is good at writing code but not engineering an application. AI is better with scaffolding. AI is bad a making changes, and are good are doing it one shot. AI training is one-shot training and not iterative development on your code base. All expectations mentioned up-front.   AI fails at large-scale applications where structure, architecture, and ease of  changing fails.   Human comprehension plan graded by AI.   AI fails at OOP since Python focused.   AI fails at larger projects to maintain clean code or come up with object  pattern architecture (instead it does flat classes in a project).   AI fails at being consistent with object patterns, even though doing similar  thing.   AI good with architecture of projects in a solution.   AI is fair with naming objects, but inconsistent over different sessions.     AI creates highly coupled objects and lots of visibility from one object to anot...

SaaS Moats

SaaS Moats Supply Attacks     1) Your customer builds your app with AI. Only need to replace 3 features they use. 2) Competitor reaches parity quickly. 3) Open source gets good enough. 4) The platform/integration partner ships your feature for free. 5) Custom software at SaaS prices - generic $99, built for you $299. 6) Model absorbs your product. You just became a wrapper. Demand Attacks 1) Will your customer still exist 2) Are your seats (number of employee users) going away? 3) Does the step you manage still matter? 4) Is a human still the one using your software? 9 Reasons Customers Stayed 1) Unique features 2) Owned traffic channels 3) Clever code 4) UX familiarity 5) Integrations 6) High switching costs 7) Strong Brand - still in AI  8) Coordination between people - still in AI 9) System of record - still in AI 8 Moats 1) Buyers know and trust you. ex: Ecosystems - Quickbooks or Shopify partners. 2) System of record - daily operations are built around you. ex: ...

New Computer Language

New Computer Language  We as programmers could have a new computer language. No heap. No pointers. So deterministic. Bounded while statements. Bounded loops. Active models. Go back to record structure (or plex). Extremely high if you have that. build for GPU vs. CPU are 2 completely different ways. CPUs are optimized for path finding and just preloading data. GPU is very deterministic - allocate a piece of memory, fill it, run some functions on it.   no heap or allocation. Single Instruction, Multiple Data (SIMD)     Do not do dynamic allocations anymore Discriminated unions - Rust Borrow checker - heap - don't use Imagine with no borrow checker. Start index. Now only have offsets for all of    the fields in your record. Hard Real-Time and Embedded Languages: MISRA C / SPARK Ada. Lustre synchronous programming language and Esterel. * No Recursion: The call stack depth must be completely predictable at compile time. * Fixed-Size Collections: Arrays cann...