Skip to main content

Posts

Showing posts with the label Ziggy Rafiq

JavaScript Conditional Statements

  JavaScript's Conditional Statements Overview  JavaScript's conditional statements provide the ability to execute different blocks of code depending on whether a certain condition evaluates to true or false. In this way, developers can create dynamic code that reacts to changing data or user input. Here are some examples of how to use conditional statements in JavaScript. If Statement The if statement is the most basic conditional statement in JavaScript. It allows you to execute a block of code only if a certain condition is true. Example One In the above example, I have given the code checks whether the age variable is greater than or equal to 18. If it is, the first block of code (inside the curly braces) will be executed and "You are old enough to vote." will be logged to the console. If the condition is false, the second block of code will be executed and "You are not old enough to vote yet." will be logged into the console. Example Two In the above ex...

JavaScript Operators (Arithmetic, Assignment, Comparison, Logical Conditional Ternary, Bitwise)

  JavaScript, operators are symbols or keywords used to perform operations on one or more values. JavaScript has several types of operators, which includes the following below. Arithmetic Operators Arithmetic Operators: These operators are used for basic arithmetic operations such as addition, subtraction, multiplication, and division. The addition operator + can also be used for string concatenation. Examples of arithmetic operators include +, -, *, /. Addition (+)   In this example above, I have used the addition operator is used to add two or more numbers or to concatenate two or more strings. Subtraction (-) In the example above, I have used the subtraction operator is used to subtract one number from another.   Multiplication (*)   In the example above, I used the multiplication operator is used to multiply two or more numbers.   Division (/)     In the example above, I have used the division operator is used to divide one number by another...

DRY Software Principle Using C#

DRY Software Principle Using C# DRY stands for "Don't Repeat Yourself," which is a software principle in C# that emphasizes the importance of avoiding code duplication. The idea is that every piece of knowledge or logic in a system should have a single, unambiguous representation within that system. In practice, this means that instead of copying and pasting code, developers should create reusable functions, classes, and modules to avoid duplicating code. By doing this, they can simplify code maintenance and reduce the risk of introducing errors when changes are made. Here are some ways to apply the DRY principle in C# development: Create reusable functions and classes: Instead of copying and pasting code, create reusable functions and classes that can be used across multiple parts of the application.   Use inheritance and polymorphism: Inheritance and polymorphism can help reduce code duplication by allowing you to create a base class with common functionality that...

Software Principles Using C#

    Software Principles Using C# There are several software principles commonly used in C# development, which are as follows. SOLID Principles : The SOLID principles are a set of five principles that guide the design of software systems. They include the Single Responsibility Principle (SRP), Open-Closed Principle (OCP), Liskov Substitution Principle (LSP), Interface Segregation Principle (ISP), and Dependency Inversion Principle (DIP). KISS Principle : The KISS (Keep It Simple, Stupid) principle states that software systems should be simple and straightforward, without unnecessary complexity. YAGNI Principle : The YAGNI (You Ain't Gonna Need It) principle states that developers should only add functionality when it is actually needed, instead of adding it in anticipation of future needs. DRY Principle : The DRY (Don't Repeat Yourself) principle states that developers should aim to write reusable code and avoid repetition. Separation of Concerns (SOC) : The Separation of C...