Coder Baba
2.42K subscribers
1.01K photos
23 videos
722 files
723 links
Everything about programming for beginners.
1 and only official telegram channel of CODERBABA India.

Content:
.NET Developer,
Programming (ASP. NET, VB. NET, C#, SQL Server),
& Projects
follow me https://linktr.ee/coderbaba
*Programming
*Coding
*Note
Download Telegram
✔️ C#: Replace if statement with Null Conditional Operator
✔️ C#: Replace if statement with Null Conditional Operator

✳️The null conditional operator, also known as the null propagation operator or the safe navigation operator, is a feature introduced in C# 6.0 that allows you to write cleaner and more concise code when dealing with potentially null reference types.

✳️The null conditional operator is represented by a question mark followed by a period (?.) and is used to access members or invoke methods on an object that may be null. If the object is null, the expression returns null instead of throwing a null reference exception.

✳️Checking for null is probably what you do quite often, for example, to prevent a null reference exception when invoking properties. Using if-statements for numerous null checking makes code cumbersome and lengthy.

✳️The null conditional operator allows checking one or more expressions for null in a call chain, which is called null propagation. Such a notation can be written in a single line whereas a number of if-else statements typically occupy many lines.


💡In the comments I attached an example in JavaScript: Replace if statement with Optional chaining.


✳️ Can you make the example cleaner ? Do you have any other suggestions?

Thank you for reading 😊
✔️ Avoid else after return
✔️ Avoid else after return

✳️ This principle is a guideline in clean code development that suggests avoiding the use of an else statement immediately after a return statement in a function or method.

✳️ When a return statement is encountered in a function, it immediately exits the function and returns control to the calling code. Any code following the return statement within the same block will not be executed. In many cases, including an else statement after a return is redundant and can be safely removed.

✳️ Following the "Avoid else after return" principle helps in writing cleaner, more maintainable code by simplifying control flow and improving code readability.

✳️ In the attached image, an example of how to apply this principle.

Bad: Violates the "Avoid else after return" principle.

✔️ Good: Refactoring the code, the else clause have been eliminated.

💡 Short: The conditional operator (? :) is used to directly return either "Pass" or "Fail" based on the condition. This eliminates the need for an if-else statement.
✔️ Function names should say what they do
✔️ Function names should say what they do

Function names should be clear and descriptive, providing a clear indication of what the function does. This makes it easier for other developers to understand the purpose of the function without having to read through the implementation details.

This is important because function names serve as a form of documentation and make it easier for other developers to understand the purpose and behavior of the code.

Following this principle helps make your code more readable, understandable, and maintainable.

Thank you for reading 😊
✔️ Use searchable names

We will read more code than we will ever write. It's important that the code we do write must be readable and searchable. By not naming variables that end up being meaningful for understanding our program, we hurt our readers. Make your names searchable.

Using searchable names means that variable, function, and class names should be clear and unambiguous so that other developers can easily understand what they do.

Thank you for reading 😊
Clean Code

Use meaningful and pronounceable variable names:

The name should reflect what it does and give context. It's essential to choose names that are clear, descriptive, and easy to understand.

Thank you 😊
Naming conventions refer to the guidelines or rules that developers follow when naming variables, functions, classes, and other elements in their code. The purpose of these conventions is to make the code more readable, maintainable, and self-documenting.

There are several commonly used naming conventions in programming languages, I will mention the three most popular:
1- Pascal Case: The first letter of every word is capitalized, with no spaces or underscores. It is commonly used in C++, C#, Visual Basic.
Examples: FirstName, LastName, NumberOfDevices.

2- Camel Case: The first letter of the first word is lowercase, and the first letter of subsequent words is uppercase, with no spaces or underscores. It is commonly used in Java and JavaScript.
Examples: firstName, lastName, numberOfDevices.

3- Snake Case: Words are separated by underscores, and all letters are lowercase. It is commonly used in Python and Ruby.
Examples: first_name, last_name, number_of_devices.

Thank you for reading 😊
C# is the Programming Language of 2023 🏆

As per the TIOBE Index, C# has been announced as the Programming Language of 2023. This is mainly because of the uptick in popularity, which is about +1.43%.

What sets C# & .NET aside:
1/ The Ecosystem & Community.
2/ Low Barrier to Entry.
3/ Very Active Feature Additions to the Language.
4/ The Rich CLI.
5/ Visual Studio and JetBrains IDE.
6/ Entity Framework Core is the GEM that no other Languages / Frameworks can come close to!
7/ .NET 8 introduced a lot of performance boosts to the Language.
🌐 Our latest YouTube video is live! 🎥 Dive into the world of software testing with our "Software Testing Tutorial" for beginners and beyond! 🛠 Whether you're new to testing or looking to sharpen your skills, this tutorial is your go-to guide.

🔗 Watch Now: Software Testing Tutorial https://youtu.be/zxWmz7qGDRg

🧑‍💻 Topics covered include manual testing, automation, STLC, SDLC models, and much more! 🌟 Don't miss out on this educational journey. Click the link above to watch and enhance your software testing expertise. 💡🔍

Like, comment, and subscribe for more insightful tech content! 🚀 #SoftwareTesting #TestingTutorial #TechEducation #YouTubeTutorial #LearnProgramming #QualityAssurance #CodingJourney 🌐
🖥 Web Development Mastery: From Basics to Advanced 🖥

Start with the fundamentals:
- HTML
- CSS
- JavaScript
- Responsive Design
- Basic DOM Manipulation
- Git and Version Control

You can grasp these essentials in just a week.

Once you're comfortable, dive into intermediate topics:
- AJAX
- APIs
- Frameworks like React, Angular, or Vue
- Front-end Build Tools (Webpack, Babel)
- Back-end basics with Node.js, Express, or Django

Take another week to solidify these skills.

Ready for the advanced level? Explore:
- Authentication and Authorization
- RESTful APIs
- GraphQL
- WebSockets
- Docker and Containerization
- Testing (Unit, Integration, E2E)

These advanced concepts can be mastered in a couple of weeks.

Remember, mastery comes with practice:
- Create a simple web project
- Tackle an intermediate-level project
- Challenge yourself with an advanced project involving complex features

Consistent practice is the key to becoming a web development pro.
👍2
Type Casting in Java:

In Java, type casting is a method or process that converts a data type into another data type in both ways manually and automatically. The automatic conversion is done by the compiler and manual conversion performed by the programmer.
#coderbaba #java #coding #programming #javafullstackdeveloper #TypeCasting
import java.util.Scanner;
public class retainStore {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
System.out.println("Enter the Customer ID for the Purchase is");
int customerid=sc.nextInt();
System.out.println("Enter the Bill id for the Purchase is");
int billid=sc.nextInt();

int discount=0;
System.out.println("Enter the Bill Amount for the Purchase is");
double billAmount=sc.nextDouble();

//199.99 2% | 210.00 5%
if(billAmount>0 && billAmount>=199.99 && billAmount<=210.00)
{
discount=2;
}
else if(billAmount>0 && billAmount>=210.00)
{
discount=5;
}
else
{
discount=0;
}

double discountedBillAmount= billAmount-billAmount *((double)discount/100);
System.out.println("Customer ID="+customerid);
System.out.println("Bill ID="+billid);
System.out.println("Discount="+discount);
System.out.println("Bill Amount="+billAmount);
System.out.println("Discounted BillAmount="+discountedBillAmount);

}
}
MERN Stack Developer Roadmap 2024:

Step 1: 🌐 Master Web Basics
Step 2: 🖥 HTML/CSS Proficiency
Step 3: Deep Dive into JavaScript
Step 4: 🗂 Version Control with Git
Step 5: 🐍 Node.js for Server-Side
Step 6: 🗃 Express.js for Routing
Step 7: 📦 NPM for Package Management
Step 8: 📚 MongoDB for Databases
Step 9: 🌟 React.js for Frontend
Step 10: 🔐 Implement Security (JWT)
Step 11: 🚀 App Deployment (Heroku, Netlify)
Step 12: 🐳 Docker Basics
Step 13: ☁️ Explore Cloud Services
Step 14: 🔄 CI/CD with GitHub Actions
Step 15: 🧪 Testing with Jest
Step 16: 📜 API Documentation
Step 17: 📢 Build a Portfolio
Step 18: 💼 Resume Crafting
Step 19: 🛑 Interview Preparation
Step 20: 🔍 Job Hunting Strategy
🚀 Exciting Announcement! 🍔🖥

Hey fam! 🌐 I'm thrilled to share my latest YouTube video! 🎥 Dive into the world of technology with my "Fast Food Restaurant Management System" built using C# .NET & SQL Server. 🚀💻

📽 Watch Now: Fast Food Restaurant Management System
https://youtu.be/sPG-WUYeBaI

In this tutorial, we explore the fascinating intersection of coding and culinary management. 🍟🍕 Ready to witness innovation? Click the link above and let the coding journey begin! 🛠🎬

🔍 Keywords:
#RestaurantTech #CSharpDotNet #SQLServer #TechInnovation #CodingProject #SoftwareDevelopment #YouTubeTutorial #FastFoodTech #CodingJourney #SubscribeNow

Your support means the world! 🌍🙌 Like, comment, and subscribe for more tech insights. Let's grow and learn together! 🚀🔐 #CoderBaba #TechCommunity #YouTubeCoding #TechLife 🖥👨‍💻