Top 10 Programming tips

One Liner If…Else Statements

You can easily convert if...else statements to one-liners using a ternary operator (also known as a conditional operator). As an example, you can replace this expression:

int age = 9;    if(age < 18) {    printf("A Child");} else {    printf("An Adult");}

With a lot neater shorthand, like this:

age < 18 ? printf("A Child") : printf("An Adult");

The general syntax for a ternary operator is:

condition ? true_expression : false_expression

The ternary operator is common in other programming languages too, so it is definitely not only a “C++ thing.” Tip: Overusing ternary operators can make code less readable. It is beneficial to use it only when the if...else statement is clear enough as a one-liner.

Never Get Tired of Practicing

The adage “practice makes perfect” holds true no matter what profession you are in. In the case of coding or programming, it becomes even more critical, since your first exposure is through books or other theoretical methods whereas the real work has to be done hands-on. You must, therefore, spend as much time on a computer as you can to get the hang of it in the initial stages. Take any model project and start doing it. Some experts suggest personal projects as an effective starting point. Think up a project and start writing the codes. You may feel like you’re getting nowhere, but slowly, the solution will emerge. The more you practice your coding during your learning days, the sooner you will end up feeling confident to take on any coding assignment. That kind of confidence will help you perform quite admirably in a technical evaluation by your prospective employers. If you are lucky, you might start off with a tough assignment that could even fast-track your career.

Keep Your Cool

Coding can be exciting, yet exhausting. People are known to spend many hours at a stretch trying to find a solution or debug the errors. Your complete schedule of meals and sleep could be affected. That’s not a very healthy situation to be in, particularly when you are young. You need to balance this by keeping yourself physically and mentally alert. Our brains need to cool off from time to time. It helps to moderate your levels of stress, which ultimately helps you be more focused on learning and excel in your performance. One way is to remain calm through the rough days. There may be situations in a full-time programming assignment when your boss might blow their top because a project is not getting completed on time. You must prepare right from your learning days to remain calm even in the midst of adversity. This will help you not just with your programming career, but also in your personal life. There are many ways you can achieve this calm state of mind. Some would suggest mindfulness exercises such as meditation or yoga. Others say to take your mind off it for a while. Just moving out to the balcony to take in some fresh, cool air and watch the traffic moving on the road below could bring a sense of calm. Maybe you are fond of gaming on your phone. If that’s the case, play for a few minutes to refresh your mental faculty.

Learn to use the debugger

A debugger is to programmers what Grammarly is to content writers. In programming, making a lot of mistakes is very common, and it is completely acceptable. A debugger will tell you the errors that you made while coding. Check your errors and run some code, check again, find more errors, and run some more code. Eventually, you will become more efficient and make fewer mistakes. This is one of the most common ways to learn coding faster.

Write Unit Test for Non-Public Methods

Many developers do not write unit test methods for non-public assemblies. This is because they are invisible to the test project. C# enables one to enhance visibility between the assembly internals and other assemblies. The trick is to include //Make the internals visible to the test assembly [assembly: InternalsVisibleTo("MyTestAssembly")] in the AssemblyInfo.cs file.

Python program to swap two numbers

This is one of the basic programs every newbie programmers will learn. The most common way of swapping two variables by using a third variable. In fact, there are a couple of other ways to swap two numbers.

  1. Using a third variable
a = 5
b = 6
c = a
a = b
b = c
  1. The Pythonic way
a, b = 5, 6
a, b = b, a

Reverse of a string

x = "Hello World"


dlroW olleH


Many developers build a POCO class in order to return multiple values from a method. Tuples are initiated in .NET Framework 4.0. They can be used effectively as follows

public Tuple < int, string, string > GetEmployee()

int employeeId = 1001;

string firstName = "Rudy";

string lastName = "Koertson";

//Create a tuple and return

return Tuple.Create(employeeId, firstName, lastName);
  • Do not bother with Temporary Collections, Use Yield instead A temporary list that holds salvaged and returned items may be created when developers want to pick items from a collection. When using a temporary list, use this C# code.
public List < int > GetValuesGreaterThan100(List < int > masterCollection)

List < int > tempResult = new List < int > ();

foreach(var value in masterCollection)

if (value > 100)

 temp result.Add(value);

return temp result;

In order to prevent the temporary collection from being used, developers can use yield. Yield gives out results according to the result set enumeration. When using yield, use this code

public IEnumerable<int> GetValuesGreaterThan100(List<int> masterCollection)

           foreach (var value in masterCollection)

               if (value > 100)

                   yield return value;

Developers also have the option of using LINQ.

iOS 13 & Swift 5 – The Complete iOS App Development Bootcamp

For those of you seeking to master programming for mobile, this next option is a great choice that can offer a variety of benefits. This course will meet the needs of both beginners and those who are already working in programming. At this moment, the price for this Bootcamp is only $12,99, which is a great price given the large number of programming secrets the instructor will reveal to you in the framework of this course. So, in case you are interested in creating software for mobile, this is a course you should try.