Posts

Different Types of Immutability

Different Types of Immutability  Here are the specific types of immutability in programming: Strict/True Immutability: The object or value cannot be changed at all after it is initialized. Examples include constants, strings, integers, and tuples in many languages. Shallow Immutability: Only the immediate fields or references of an object are immutable, but the objects they reference can still be changed. A "read-only" field might point to a mutable object. Deep/Strong Immutability: The entire object graph is immutable. All fields, and all objects referenced by those fields, are also immutable. Copy-on-Write (Persistent Data Structures): While the data structure appears immutable to the user, any change triggers the creation of a new, updated copy. The original remains unchanged. Compile-time Constants (Write-once): Fields that are assigned a value at compile-time and cannot be changed during runtime, such as const in C# or final in Java.

F# and Immutability

F# and Immutability In F#, everything is immutable except arrays.  In F#, you get immutability "for free" in most cases.

Immutability vs. ReadOnly

 Immutability vs. ReadOnly   The key difference is that readonly restricts reassignment of a reference/variable, while immutable guarantees that the contents or state of an object cannot be changed after creation.   Example (C#): A readonly List<T> cannot be set to a new List<T> instance, but you can still call methods like Add() or Remove() on the existing list.

Immutability and C#

Immutability and C# C# has System.Collections.Generic.Immutable collection that was introduced in .NET Framework 4.5 (around 2012–2013). I went back and revisited Jinaga by my friend, Michael Perry.   https://github.com/jinaga/jinaga.net I investigated the code generators for immutability types by A. Arnott and Nikolay Pianikov: https://github.com/AArnott/ImmutableObjectGraph https://github.com/DevTeam/Immutype

Immutability and Security

Immutability and Security   I have been thinking about immutability and security.  Was thinking about how immutables have better security overall (since cannot modify), but not entire security since security is also visibility.

Prevent Duplicates of Customer Data On Entry?

Prevent Duplicates of Customer Data On Entry? Do you have a way to prevent the entry of duplicate customers in the data entry screens?  So maybe you don't get duplicates like: Customer Member table: Last Name First Name Member # Phone Number Street Address City, State Wayland Jennifer 201215 2078675309 123 Maine Street Camden, Maine Wayland Jenn 201211 2078675309 123 Main Street Camden, Maine

Have Buckets or Not?

Have Buckets or Not?   So with accounting on computers, there is a question to have buckets or not when doing the database fields.  A bucket is used for accounting and financial reports such as total sales, etc.  There is usually a different bucket for each time period you need, such as January Total Sales or First Quarter Sales.  Why use buckets at all?  Answer - for speed for doing the daily, monthly, quarterly, and annual reports. Choices:     No - Reasons: 1) Just calculate it when the need arises in the future, rather than update the total field as each transaction hits.  2) Risks conflicts of trying to write the new value of the total field simultaneously when lots of concurrent transaction. 3) Calculation errors could happen by overlooking a particular transaction and accounting hates mismatches.     Yes, Live - 1) Bucket total is up-to-date and current. 2) Faster than gathering the correct transactions and summing them. ...