Thursday, September 26, 2024

Clean Code 𝗖𝗹𝗲𝗮𝗻 𝗖𝗼𝗱𝗲 𝗧𝗶𝗽s - 𝗢𝘃𝗲𝗿𝗰𝗼𝗺𝗶𝗻𝗴 𝗕𝗼𝗼𝗹𝗲𝗮𝗻 𝗕𝗹𝗶𝗻𝗱𝗻𝗲𝘀𝘀

 public void ProcessOrder(int orderId, bool applyDiscount)

{

    if(applyDiscount)

    {

            //Apply Discount to the order

    }

        // Process the order here

}

ProcessOrder(1000, applyDiscount: true);


Clean Code:

public enum DiscountOption

{

    None,

    ApplyDiscount

}


public void ProcessOrder( int orderId, DiscountOption discountOption)

{

    if(discountOption == DiscountOption.ApplyDiscount)

        {

                // Apply discount to the order

        }

// Process the order

}

ProcessOrder(1000, DiscountOption.ApplyDiscount);

Screen Record

 Windows Screen Record WindowsKey+ Alt + R Recording Starts.