Using a Lambda Expression Over a List in C#

This article exemplifies methods for performing several tasks and queries over a set of records in a List.

Sometimes if you have a set of records in a List, it becomes quite easy to query on a list using a Lambda Expression. This article exemplifies methods for performing several tasks and queries over a list. Create a new console project and go to Program.cs See sample code below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LamdaExpressionsOnList
{
    class Program
    {
        static void Main(string[] args)
        {
          //Your Code
        }
    }
}

Suppose we have a “Person” class that has the following members:

class Person  
{  
    public string SSN;  
    public string Name;  
    public string Address;  
    public int Age;  
    public Person(string ssn, string name, string addr, int age)  
    {  
        SSN = ssn;  
        Name = name;  
        Address = addr;  
        Age = age;  
    }  
}  

Now we create a list of the Person objects in which we have to perform several operations like finding a person on certain conditions, removing a person’s record etc. These types of operations can be easily performed using a “Lambda Expression”. We create the list and populate them in the following way:

List<Person> listPersonsInCity = new List<Person>();  

listPersonsInCity.Add(new Person("203456876", "John", "12 Main Street, Newyork, NY", 15));  

listPersonsInCity.Add(new Person("203456877", "SAM", "13 Main Ct, Newyork, NY", 25));  

listPersonsInCity.Add(new Person("203456878", "Elan", "14 Main Street, Newyork, NY", 35));  

listPersonsInCity.Add(new Person("203456879", "Smith", "12 Main Street, Newyork, NY", 45));  

listPersonsInCity.Add(new Person("203456880", "SAM", "345 Main Ave, Dayton, OH", 55));  

listPersonsInCity.Add(new Person("203456881", "Sue", "32 Cranbrook Rd, Newyork, NY", 65));  

listPersonsInCity.Add(new Person("203456882", "Winston", "1208 Alex St, Newyork, NY", 65));  

listPersonsInCity.Add(new Person("203456883", "Mac", "126 Province Ave, Baltimore, NY", 85));  

listPersonsInCity.Add(new Person("203456884", "SAM", "126 Province Ave, Baltimore, NY", 95)); 

Now we see how we can do various complex operations on the list using a one-line simple Lambda expression. 

1. The following code retrieves the first two persons from the list who are older than 60 years:

Console.WriteLine("\n-----------------------------------------------------------------------------");  
Console.WriteLine("Retrieving Top 2 aged persons from the list who are older than 60 years\n");  
foreach (Person person in listPersonsInCity.FindAll(e => (e.Age >= 60)).Take(2).ToList())  
{  
    Console.WriteLine("Name : " + person.Name + " \t\tAge: " + person.Age);  
}
Console Output

2. The following code checks any person’s age that is between 13 and 19 years:

Console.WriteLine("\nChecking whether any person is teen-ager or not...");  
if (listPersonsInCity.Any(e => (e.Age >= 13 && e.Age <= 19)))  
{  
    Console.WriteLine("Yes, we have some teen-agers in the list");  
}
Console Output

3. The following code checks whether all the people’s ages are greater than Ten years or not:

Console.WriteLine("\nCheking whether all the persons are older than 10 years or not...");  
if ( listPersonsInCity.All(e => (e.Age > 10)))  
{  
    Console.WriteLine("Yes, all the persons older than 10 years");  
}
Console Output

4. The following code gets the average of all the people’s ages:

Console.WriteLine("\nGetting Average of all the person's age...");  
double avgAge = listPersonsInCity.Average(e => e.Age);  
Console.WriteLine("The average of all the person's age is: "+ avgAge);

5. The following code checks whether a person having the name ‘SAM’ exists or not:

Console.WriteLine("\nChecking whether a person having name 'SAM' exists or not...");  
if (listPersonsInCity.Exists(e => e.Name == "SAM"))  
{  
    Console.WriteLine("Yes, A person having name  'SAM' exists in our list");  
}
Console Output

6. The following code checks at what position a person having the name ‘Smith’ exists in the list:

Console.WriteLine("\nChecking the index position of a person having name 'Smith' ...");  
int indexForSmith = listPersonsInCity.FindIndex(e => e.Name == "Smith");  
Console.WriteLine("In the list, The index position of a person having name 'Smith' is : " + indexForSmith);
Console Output

7. The following code retrieves the oldest person in the list:

Console.WriteLine("\nGetting the name of the most aged person in the list ...");  
Person p = listPersonsInCity.First(m=> m.Age == (listPersonsInCity.Max(e => e.Age)));  
Console.WriteLine("The most aged person in our list is: "+ p.Name +" whose age is: "+ p.Age);
Console Output

8. The following code gets the total of all the people’s ages:

Console.WriteLine("\nGetting Sum of all the person's age...");  
int sumOfAges = listPersonsInCity.Sum(e => e.Age);  
Console.WriteLine("The sum of all the persons's age = "+ sumOfAges);
Console Output

9. The following code skips each person whose age is less than 60:

Console.WriteLine("\nSkipping every person whose age is less than 60 years...");  
foreach (Person pers in listPersonsInCity.SkipWhile(e => e.Age < 60))  
{  
Console.WriteLine("Name : "+ pers.Name + " \t\tAge: "+ pers.Age);  
}
Console Output

10. The following code retrieves all the people until we find a person with a name beginning with any letter other than “S” :

Console.WriteLine("Displaying the persons until we find a person with name starts with other than 'S'");  
foreach (Person pers in listPersonsInCity.TakeWhile(e => e.Name.StartsWith("J")))  
{  
    Console.WriteLine("Name : " + pers.Name + " \t\tAge: " + pers.Age);  
}
Console Output

11. The following code checks whether all the people have their SSN or not:

Console.WriteLine("\nChecking all the persons have SSN or not ...");  
if(listPersonsInCity.TrueForAll(e => e.SSN != null))  
{  
    Console.WriteLine("No person is found without SSN");  
}
Console Output

12. The following code removes all the people having the name “SAM”:

Console.WriteLine("\nRemoving all the persons record from list that have "SAM" name");  
listPersonsInCity.RemoveAll(e => (e.Name == "SAM"));  
if (listPersonsInCity.TrueForAll(e => e.Name != "SAM"))  
{  
    Console.WriteLine("No person is found with 'SAM' name in current list");  
}
Console Output

13. The following code searches for the person having “203456876” as their SSN:

Console.WriteLine("\nFinding the person whose SSN = 203456876 in the list");  
Person oPerson = listPersonsInCity.Find(e => (e.SSN == "203456876"));  
Console.WriteLine("The person having SSN '203456876' is : " + oPerson.Name + " \t\tAge: " + oPerson.Age);
Console Output

Lambda Expressions are a powerful addition to C# Programming. This article attempts to describe lambda expressions in simple terms to pave the way for some powerful uses of this construct.

Top 7 Photo Editors Like Photoshop in 2019

Looking for free photo editors like Photoshop to make photos and designs more professional? Adobe Photoshop is the dream of any designer and retoucher since it offers a professional toolset for creative process.

However, the biggest difficulty everyone faces is its quite high monthly price, which often becomes a deal-breaker and leads to many people searching for Photoshop torrents to avoid paying such a huge sum for Adobe products.

Luckily, it’s possible to find a photo editor like Photoshop that is either completely free or cheaper and is capable of doing almost everything that Photoshop can, and sometimes even more.

7 Photo Editors Like Photoshop

Even though Adobe Photoshop is often viewed as the best option among graphics editors, its capabilities are frequently superfluous. Other than that, Adobe is transferring more and more users to the “Cloud” system, which isn’t to everyone’s taste.

Finally, during the last few years, people have been complaining more and more about performance drops when using Adobe software due to the heavy load it puts on the processor. It’s often enough to open a couple of projects in Photoshop even on a powerful PC and you won’t even be able to use your browser comfortably.

Currently, Photoshop remains the leading choice among professionals, but more and more users are searching for decent free photo editors like Photoshop.

Here we have compiled list of some best photoshop alternatives.

1. Affinity Photo

Affinity Photo started to create a stir in the creative community almost from the moment it was released. It’s probably the most credible photo editor similar to Photoshop that we’ve seen to this day.

The program supports Photoshop’s signature file standards and is aimed at photographers and designers while costing significantly less.

Being completely compatible with Photoshop and other file formats, it targets specifically professional photographers and designers. While Affinity Photo is much cheaper than Photoshop (without a subscription), its creators state that their software is actually better, promising superior performance and fewer errors.

Frankly speaking, the performance boost you receive will probably highly depend on what hardware you’re using (the program was developed for using the latest quadcore technology).

Pros:

  • Works with RAW and PSD files
  • RGB, CMYK, LAB and Greyscale support
  • Layer-focused image editing

Cons:

  • Doesn’t have premade lens-specific corrections
  • Users can’t customize the workspace
  • Not very beginner-friendly

2. GIMP

If you want to get a free photoshop alternative that is just as powerful and multifunctional, then GIMP is one of the best alternatives. It is free, open-source, which allows a huge number of volunteers to continuously improve it.

Thanks to that fact, GIMP has loads of plugins and scripts written for it and it can also work with plugins for Adobe Photoshop. Another benefit of GIMP is that it appeared all the way back in the mid-90s so you can find a huge number of free courses and guides on the web.

GIMP offers a wide selection of tools and it’s a fantastic option if you’re looking for a free photo editor similar to Photoshop. The UI is slightly different from Photoshop’s but you can modify it to your liking.

If you find a “monstrous” program with huge system requirements and a scary price tag unappealing – GIMP is the option for you.

Pros:

  • Constant maintenance and updates that solve relevant issues and add new functions
  • Smooth performance on all platforms
  • Extremely versatile and easily customizable with plugins and scripts

Cons:

  • I didn’t experience any problems but heard some people suffer from a couple of bugs
  • Doesn’t support 16bit color channels
  • Some functions are in development for way too long

3. Photo Pos Pro

Photo Pos Pro is another decent photo editor like Photoshop that strives to be as user-friendly as possible. It has separate modes for beginners and advanced users. In beginner-mode, you can apply filters in a single click and perform basic photo corrections.

The professional mode has a UI similar to Photoshop. Most find its interface to be more intuitive and comprehensible than GIMP.

Alas, this free photo editor like Photoshop has a very serious flaw. The maximum size of saved files is limited to 1024×2014 pixels.

If you need to work with larger files, the photo editor will offer you to purchase the paid version for $20. That’s a bit unpleasant, but still several times cheaper than Photoshop.

Pros:

  • Capability to work with layers
  • All kinds of brushes, templates, textures and gradients
  • Tools for batch, manual and automatic color correction

Cons:

  • No way to create your own brushes
  • Rather poor printing preparation functionality

4. Pixlr Editor

Pixlr Editor is a rather unusual photo editor similar to Photoshop. It’s available in several versions, including PC, mobile and as an online editor. The web version is the sole reasonable Photoshop replacement since it’s the only one with layer support.

Sadly, the web version of this program can’t be set to full-screen since there will still be unused space on the right. However, that’s the only serious drawback of Pixlr Editor.

All tools found in Ps are available and work great. Overall, this is the perfect photo editor app like Photoshop for situations when you need to edit an image but you don’t have the right to install a downloadable editor.

Pros:

  • Available for free
  • Has its own smartphone app
  • Plenty of tools to work with

Cons:

  • Can be slightly overwhelming for beginners
  • Requires Internet connection

5. Pixelmator

Pixelmator is a universal graphics editor build on the principles of simplicity and accessibility for everyone. The program is available only on iOS and MacOS, which explains such an approach.

Pixelmator positions itself as a photo editor like Photoshop that is simpler and more intuitive.

Instead of a single workspace, here we have the main window and movable panels that you can open in the View menu or by using shortcuts. The number of picture editing tools isn’t large but won’t leave you complaining either.

I also want to mention the smart selection function that was added with the latest update. My subjective experience suggests that this option works better than in Photoshop and is slightly better visible.

There’s no need to impose this editor on professionals, but it’s a perfect fit for regular users. One of the most “magical” capabilities of Pixelmator is object removal. You pick the diameter of the selection, add a couple of brush strokes, and the photo will be cleared of any excess objects.

Pros:

  • Clean user-friendly UI
  • Large choice of effects other than photo adjustments
  • Drawing tools are efficient and error-free

Cons:

  • Doesn’t offer non-destructive editing or a history panel
  • No CMYK and RAW support

6. PaintNet

Paintnet represents a Windows-based free photo editor like Photoshop supplied by Microsoft. However, don’t let that fact scare you: despite being a default program, it’s a surprisingly multifunctional and useful tool.

This option focuses on ease of use and is better suited for photo editing than artistic creations. Nonetheless, it includes a variety of special effects that allow you to easily create an artificial perspective, mix and move pixels on the canvas, select and copy areas, etc.

A solid selection toolset, layer support and such settings as curves and brightness/contrast mean that PaintNet is a wonderful free photo editor similar to Photoshop, especially if you don’t need the latest additions to Ps’ toolset.

Pros:

  • Allows working with image layers
  • Updates come out almost every month
  • Contains a satisfying number of effects

Cons:

  • Lack of functions for professional graphics design

7. Adobe Photoshop Express

Adobe Photoshop Express can be considered a lighter, more limited version of Photoshop. This editor can be found online or as an app for Windows, iOS and Android. This is the simplest solution described in the article.

It doesn’t have layer support, plugins or brushes and works only with JPEG, JPG and JPE images below 16MB. You can’t even crop photos.

The only things you can find in this photo editor app like Photoshop are some basic settings and a collection of beautiful filters that you can use to enhance a photo before posting it on social media.

As you can see, it isn’t suited for deep photo editing so you might as well go with a trustworthy professional photo editing service online instead for a couple of backs.

Pros:

  • Incredibly easy to use
  • Availability of basic tools
  • Stable performance

Cons:

  • Lack of most professional tools
  • No RAW support
  • Max file size of 16MB

Conclusion

If you ever start thinking about replacing Photoshop, I hope you’ll take note of some of the offered programs. If you need to perform complex image editing that requires using many different tools, then Affinity Photo, GIMP or Pixelmator are perfectly suited for such a task. If all you need is to make a couple of simple adjustments (size change, rotation, basic color correction), then you should take a closer look at PaintNet or Photo Pos Pro.

If you need a photo editor like Photoshop that you can use online, straight from your browser – Pixlr and Adobe Photoshop Express are there for you. Interested in other Adobe products, read more about a legal way to download Lightroom free.

I hope you will love these photoshop alternatives. If you know about any other good editor then please mention in comments, I will love to add it to the list.

C# Analog Clock Program

In this tutorial we are going to use a bit of graphics class to design a C# analog clock. We have also used a timer to continuously move our clock’s pointer.

Concept

  • We will first initialize some angle values to second, minute, hour hand.
  • Then draw the clock using the graphics class, save it as a bitmap variable and load it in the picturebox.
  • Finally Use the timer to move the second hand.

Instructions

  • Create a new windows form applicaton project in visual c#.
  • Add a picture box on the form.
  • Double click the form to switch to code view. 
  • Delete all the existing code and paste the code given below.

C# Analog Clock Program

Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace AnalogClock
{
    public partial class Form1 : Form
    {
        Timer t = new Timer();
 
        int WIDTH = 300, HEIGHT = 300, secHAND = 140, minHAND = 110, hrHAND = 80;
 
        //center
        int cx, cy;
 
        Bitmap bmp;
        Graphics g;
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            //create bitmap
            bmp = new Bitmap(WIDTH + 1, HEIGHT + 1);
 
            //center
            cx = WIDTH / 2;
            cy = HEIGHT / 2;
 
            //backcolor
            this.BackColor = Color.White;
 
            //timer
            t.Interval = 1000;      //in millisecond
            t.Tick += new EventHandler(this.t_Tick);
            t.Start();
        }
 
        private void t_Tick(object sender, EventArgs e)
        {
            //create graphics
            g = Graphics.FromImage(bmp);
 
            //get time
            int ss = DateTime.Now.Second;
            int mm = DateTime.Now.Minute;
            int hh = DateTime.Now.Hour;
 
            int[] handCoord = new int[2];
 
            //clear
            g.Clear(Color.White);
 
            //draw circle
            g.DrawEllipse(new Pen(Color.Black, 1f), 0, 0, WIDTH, HEIGHT);
 
            //draw figure
            g.DrawString("12", new Font("Arial", 12), Brushes.Black, new PointF(140, 2));
            g.DrawString("3", new Font("Arial", 12), Brushes.Black, new PointF(286, 140));
            g.DrawString("6", new Font("Arial", 12), Brushes.Black, new PointF(142, 282));
            g.DrawString("9", new Font("Arial", 12), Brushes.Black, new PointF(0, 140));
 
            //second hand
            handCoord = msCoord(ss, secHAND);
            g.DrawLine(new Pen(Color.Red, 1f), new Point(cx, cy), new Point(handCoord[0], handCoord[1]));
 
            //minute hand
            handCoord = msCoord(mm, minHAND);
            g.DrawLine(new Pen(Color.Black, 2f), new Point(cx, cy), new Point(handCoord[0], handCoord[1]));
 
            //hour hand
            handCoord = hrCoord(hh % 12, mm, hrHAND);
            g.DrawLine(new Pen(Color.Gray, 3f), new Point(cx, cy), new Point(handCoord[0], handCoord[1]));
 
            //load bmp in picturebox1
            pictureBox1.Image = bmp;
 
            //disp time
            this.Text = "Analog Clock -  " + hh + ":" + mm + ":" + ss;
 
            //dispose
            g.Dispose();
        }
 
        //coord for minute and second hand
        private int[] msCoord(int val, int hlen)
        {
            int[] coord = new int[2];
            val *= 6;   //each minute and second make 6 degree
 
            if (val >= 0 && val <= 180)
            {
                coord[0] = cx + (int)(hlen * Math.Sin(Math.PI * val / 180));
                coord[1] = cy - (int)(hlen * Math.Cos(Math.PI * val / 180));
            }
            else
            {
                coord[0] = cx - (int)(hlen * -Math.Sin(Math.PI * val / 180));
                coord[1] = cy - (int)(hlen * Math.Cos(Math.PI * val / 180));
            }
            return coord;
        }
 
        //coord for hour hand
        private int[] hrCoord(int hval, int mval, int hlen)
        {
            int[] coord = new int[2];
 
            //each hour makes 30 degree
            //each min makes 0.5 degree
            int val = (int)((hval * 30) + (mval * 0.5));
 
            if (val >= 0 && val <= 180)
            {
                coord[0] = cx + (int)(hlen * Math.Sin(Math.PI * val / 180));
                coord[1] = cy - (int)(hlen * Math.Cos(Math.PI * val / 180));
            }
            else
            {
                coord[0] = cx - (int)(hlen * -Math.Sin(Math.PI * val / 180));
                coord[1] = cy - (int)(hlen * Math.Cos(Math.PI * val / 180));
            }
            return coord;
        }
    }
}

Difference between GET and POST Method

Http protocol supports the following methods to retrieve data such as get, post, put, delete etc. In this article, I will tell you about the difference between GET and POST methods.

These methods are basically used to get and send any data. Because of these methods, the request-response between server and client exist. To send data streams we use these two methods. GET and POST are the most common HTTP methods.

Difference between GET and POST Method

GETPOST
We add parameters in URL and get data in response.Send additional data from the client or browser to the server.
Sends data as part of URI (uniform resource identifier)Sends data as HTTP content.
get return same results every time.The post method implements in that way it changes with every request.
We can send limited data in the header. We can send a large amount of data because its part of the request body.
It is not much secure because data is exposed to URL and we can easily bookmark it and send it. It  is more secure because data is passed in the request body and user not able to bookmark it
You can cache the data.You cannot cache post request data.
GET is bounded by the max. URL length continued by the browser and web server.POST doesn’t have such conditions.
GET is used to request data from a particular resource.POST is used to send info to a server to create/update a resource.
parameters passed  in URLparameters passed in body
This is not happening in get method.Use POST for destructive things such as creation, editing, and deletion.
get is used for fetching documents.post used for updating data.
in get we pass things like customer id, uId to get a response.post request sends information to server like customer info, file upload etc.

Check out the example of both requests.

GET Request:

GET https://api.github.com/users/{name}

Here you can pass name according to that you will get data.

GET https://api.github.com/users/sniper57

POST Request:

In this you will have to send content-type such as multipart/form-data, application/json,  application/x-www-form-urlencoded and object or data that you have to pass in body.

Host: foobar.example

Content-Type: application/json

Object- [{name1:value1},{name2:value2}]

In this you are posting JSON data to API.

Comment down below if you have any queries related to get vs post methods.

You can now try Microsoft’s web-based version of Visual Studio

Earlier this year, at its Build developers conference, Microsoft announced that it was working on a web-based version of its Visual Studio IDE. At the time, Visual Studio Online went into a private preview, open to a select number of developers. Now, at its Ignite conference, the company has opened the service to all developers who want to give it a spin.

With Visual Studio Online, developers will be able to quickly spin up a fully configured development environment for their repositories. From there, they can use the web-based editor to work on their code.

“Visual Studio Online brings together Visual Studio, cloud-hosted developer environments and a web-based editor that’s accessible from anywhere to help developers be more productive than ever,” Microsoft notes in its press materials. “As development becomes more collaborative and open source workflows, like pull requests, become more pervasive, developers need to be able to switch between codebases and projects quickly without losing productivity.”

In its current form, the service is deeply integrated with Microsoft’s GitHub (no surprise there), but the company notes that developers can also attach their own physical and virtual machines to their Visual Studio-based environments. Developers also can create these online environments right from Visual Studio Code, the company’s increasingly popular free code editor for Windows, Mac and Linux.

The cloud-based environments, as well as extension support for Visual Studio Code, are now in preview.

5 Tips to Become a Better Programmer

8 Best Rules for Good Programming Style

ALSO READ: 5 Tips to Become a Better Programmer

Proper programming style significantly reduces maintenance
costs and increases the lifetime and functionality of software. Most software
disasters are rooted in poor style of programming. In this article I am listing
out the 8 best rules that lead to a better programming style.

Readability

Good code is written to be easily understood by colleagues.
It is properly and consistently formatted and uses clear, meaningful names for
functions and variables. Concise and accurate comments describe a natural
decomposition of the software’s functionality into simple and specific
functions. Any tricky sections are clearly noted. It should be easy to see why
the program will work and reason that it should work in all conceivable cases.

Maintainability

Code should be written so that it is straightforward for
another programmer to fix bugs or make changes to its functionality later.
Function should be general and assume as little as possible about preconditions.
All important values should be marked as constants which can be easily changed.
Code should be robust to handle any possible input and produce a reasonable
result without crashing. Clear messages should be output for input which is not
allowed.

Comments

Comments are the first step towards making computer program
human readable. Comments should explain clearly everything about a program
which is not obvious to a peer programmer. The volume of comments written is
meaningless, quality is all that counts.Block comments are written using /* comments */ style. They should go at the top of every source
file and generally include your name, the date your code was written and
overall description of the purpose of that program. Block comments should also
precede most functions with a description of the function’s purpose; these can
be omitted for very short, obvious functions only.Inline comments are written as //comments, they should go near important lines of code within
functions or with variables when they are initialized.

Naming

Names given to classes, variables, and functions should be
unambiguous and descriptive. Other guidelines for naming are:

  • Capitalization is used to separate multi-word names:
    StoneMasonKarel.
  • The first letter of a class name is always capitalized:
    GraphicsProgram
  • The first letter of a function or variable name is always in
    lowercase: setFilled().
  • The names x and y should only be used to describe
    coordinates.
  • The names i, j, and k should only be used as variables in
    for loops.
  • Other one-letter names should be avoided: area = base *
    height instead of a = b * h.
  • Names of constants are capitalized, with underscores to
    separate words: BRICK_COLOR.
  • Use abbreviations with caution. max instead of maximum is
    fine, but xprd instead of crossProduct is a problem.

Indentation

Indentation is used to clearly mark control flow in a
program. Within any bracketed block, all code is indented in one tab. This
includes the class body itself. Each additional for, while, if, or switch
structure introduces a new block which is indented, even if brackets are
omitted for one line statements. For if statements, any corresponding else
statements should line up

White Space

White space is meaningless to compilers, but should be used
consistently to improve readability. Typically three blank lines are left in
between functions. Individual blank lines are used within functions to separate
key sections. Use of spaces varies as well, but inserting one space usually
make expression more readable; next = 7 *
(prev – 1)
 is clear than next=7*(prev-1).

Function Usage

Function should be short and accomplish a clear, specific
task. As much as possible they should be considered “black boxes” which do not
depend on anything except their parameters and can be handle any possible input
gracefully. A common rule of thumb is the “Ten Line Rule”, usually function
longer than ten lines are trying to do too much and should be simplified.Another important aspect of functions is that any repeated
segments of code should be made into a separate function. This will shorten
your program and improve readability.

Output

A final, overlooked aspect of good programming style is how
our program output results and information to users. Part of writing
professional looking programs is providing clear instructions and results to
the users of our programs. This means proper English with no spelling error conditions.
One must always assume that writing programs to be used by somebody with no
understanding of computer programming whatsoever.If you liked the article then please share it!

5 Tips to Become a Better Programmer

In this article I am sharing the 5 best tips that will really help you to increase your programming skills and become a better programmer.

ALSO READ: 8 Best Rules for Good Programming Style

1. Know Basics

You should have a good understanding of basics of the programming language in which you are working or learning. If your basic concepts are strong then you can solve complex problems by breaking it into smaller problems. Your code should be neat and well structured, so that if you start working with the code after few months then you can easily know where you left off.

2. Practice a Lot

We all know the fact that “practice makes a man perfect”. For improving your skills you have to practice thousands of hours. There are plenty of ways for practicing, like you can solve problems from good programming books or find online programming contests. There are many awesome websites like codechef.comtopcoder.com, etc where you can practice.

3. Be Amenable to Change

Technology is changing very rapidly so you have to aware of such changes. You should make sure that the projects or technologies on which you are working are not outdated. For becoming a better programmer you should always engage yourself in learning new things.

4. Read a Lot

The more you read, the more you learn. Read good programming books, articles, documentations. The best way for reading and learning programming is to join various programming forums and contests.

5. Help Others

Join great forums like stackoverflow.com where you can help other programmers by answering there questions. By helping others you can find answers of your own questions. You can also ask questions in the forums and get your problems solved; this will help you to become better programmer. These were few tips that will surely help you in becoming a better programmer. If you have any other tips then please mention it in the comment section.

Image Source: https://img2.thejournal.ie/inline/4496572/original/?width=630&version=4496572

15 Most Common Bad Programming Practices

Here are some most common bad programming practices that every programmer should avoid to become a better programmer.

ALSO READ: 5 Tips to Become a Better Programmer

1. Giving up too soon

Most of the programmers give up when they are very close to solution. So never lose hope and keep trying, you will definitely find a solution.

2. Acting defensively when someone critiques your code

Be calm when someone criticizes your code. Just listen carefully to them; maybe it will help you to improve your code quality.

3. Refusing to ask for help

Don’t be ashamed of asking help from other programmers. Don’t feel that others will think you even don’t know such a small thing. Just go ahead and ask for help. There are several programming forums like stackoverflow where many experienced programmers are active who would definitely help you.

4. Passing blame to others

A good developer is one who takes ownership and responsibility for the code he/she write.

5. Ignoring the opinions of other developers

Pair programming with other experienced developer is one of the best ways to learn and grow as a developer. You can take help of other programmers and senior developers to learn efficient ways of solving a problem that you have solved yourself.

6. Not knowing how to optimize code

Finding solution of a problem should not be your only concern. You should optimize your code in terms of time and space complexity.

7. Acting like a boss, not a leader

If you are a senior developer then you should know how to manage developers in your team. You should act like a leader who can properly lead his/her team.

8. Using the wrong tool for the job

You should be aware of which tool is best for the job. Stop making decisions based on “it’s what I know”. You need to be open to using different technologies, languages, and frameworks.

9. Refusing to research coding questions

Internet is one of the most powerful tools for programmers. You should be really smart to search solution for a problem on sites like google, stackoverflow, etc.

10. Refusing to learn from mistakes

We are humans, we make mistakes. Making mistake is not a bad thing, but refusing to learn from them is bad thing. Find the ultimate cause for the mistake and keep it in mind so that you will not repeat it in future.

11. Separating yourself from the developer community

You should be really active in developers and programmers community. This will help you to have knowledge about latest technologies and trends in the market.

12. Not giving back to the community

You should be always ready for helping other programmers. You can help others by various platforms like stackoverflow, quora, etc. or by writing articles on others or your own blog.

🙂

See how I am helping other programmers by this blog. 

13. Struggling for hours to solve something, solving it, and not documenting it

You may get some strange problem whose solution is not there on internet. You spent several hours and found the solution. Now it’s your duty to share the solution on internet so that others will not struggle that much.

14. Bad naming conventions

Use meaningful name for variables, functions, classes, etc. For example, using characters like x, y, z, etc for the variable name instead of something like length, userInput.

15. Writing too many or not enough comments in code

Comments are essential notes to developers. It increases the readability of code. You should properly write comments so that it will help you as well as other programmers to understand the code in future.

If you know some other bad programming habits then please mention in comment. I will love to add them in this article.

Source: https://www.quora.com/What-are-some-bad-programming-practices-every-programmer-needs-to-be-aware-of-in-order-to-avoid-them

5 Facile Yet Incredibly Valuable Ways to Enhance ASP.NET Developer’s Efficiency

The ASP.Net Development has arguably redefined and restructured the ambit of web application development. The new age capabilities of the platform created by Microsoft has features abound of developers to let them think out of the box and create something that paves way for innovation. Creating exclusive application become a prospect rather too realistic and as more number of developers and development companies lean towards ASP.NET, we are sure to witness better and faster web apps.

The framework is also continuously changing and it is being made sure that there are regular upgrades. For an enterprise providing the ASP.NET development services to a client – locally or offshore – it is imperative to keep glued to those changes and let them not surprise them and the clients. To upgrade themselves to the changes, developers need to rise up to the occasion and raise their skill levels and optimize the way they work. There are ways to do so, and those ways are met with certain challenges as well. But they also produce favorable results for businesses. So, here is how you can proceed to hone your results as a developer:

Also Read: http://blogs.magistechnologiesinc.com/5-things-you-must-consider-before-using-asp-net-development/(opens in a new tab)

Make Handling the Requests an Asynchronous Exercise

The customary practice in ASP.Net Development is managing the incoming request synchronously. While this kind of process has its set of benefits, you cannot set priorities with this practice, which leads to mismanagement of time. As the requests are placed in a queue, there is a method to how they are handled. So far, so good, but the lack of prioritization only works the other way for you – the wrong way that is. By using asynchronous pages, you can reduce the total request handling time and let more important applications to run first. 

Use the Browser’s Tools and Extensions

The browsers like Google Chrome and Mozilla Firefox comes with their own set of tools to help developers spend less time in writing darn-out codes and plug their applications with incredible features. The oversight leaded to ignoring these tools will only lead to increased time in developing apps and probably lesser efficiency as well. Look for the tools that are relevant to the app and leverage them in the best way you can. 

Pool the connections to Free up Some Resources

The way applications are connected to the database eats up a lot of resources, which can otherwise be saved by the more optimized practice of connecting pooling. It also helps the TCP connections, though keeping an eye towards
discrepancies like connection leaks becomes more imperative. 

Do not Keep Debuggers Running at All Times

While ASP.NET works in a great way to make sure the errors do not creep in and go unnoticed through the use of various debuggers and tracers to let you know, they also have an impact over the application development speed metrics. If you keep them on, the debuggers will render the whole process slow and bring a marked difference in the way applications are being executed. This further impacts the performance – a not too desirable prospect by any stretch. As and when you need it, you can switch on the debuggers to locate and correct the errors to make sure they don’t surface at run-time. 

Make the Most of Cache Class

Developers, both beginners and experts, often undermine the importance of the cache class. In fact, they ignore the benefits that the overall caching mechanism can provide them with. This mechanism is highly important for making a backup of resources while classifying their validity. The cache class makes this process be carried out with ease. As and when an object is not allowed to cache, the callbacks are summoned. With a nod to the growing evolvement of ASP.NET, developers feel the heat to stay abreast to the latest and most resourceful practices. And if they happen to be a part of a large scale ASP.NET development company, there is an escalated urgency.

5 Things You Must Consider Before Using ASP.NET Development

Today’s contemporary web needs expect you to opt for a programming framework that comes loaded with remarkable benefits. Before choosing a particular framework, you must gauge it in terms of ease-of-use and scalability. Amongst the wide range of programming frameworks available in the web market, ASP.NET has been successful in making it to the list of leading web development frameworks used by web developers across the globe. If you too are about to leverage ASP.NET features for building remarkable web solutions then this is a post you can’t afford to miss. Here, I’ve covered five vital things that you must consider before using ASP.NET as your web development tool.

1. High-grade scalability

For being able to make the most of a web development framework, you must ensure that the same is equipped with high-end scalability options. The more scalable the framework is, the better it would be for you (as a developer) to manage the events and sessions across multiple servers used during web development.

If your web programming framework comes with top-level scalability, you can stop worrying about scaling your web application in accordance to forthcoming advancements in the field of technology. ASP.NET features such as pipeline optimization and process configuration aid you in addressing the varying requirements as your project scales from one stage to another.  

2. An efficient web server

The prime reason behind the increased use of ASP.NET is its excellent web server efficiency. Backed by a brilliant web server, ASP.NET enables you to deal with different web development scenarios in addition to offering you the flexibility of monitoring web pages, modules and specific components. To sum it up, with ASP.NET, you need not stress about the speed of the web server because the framework handles the dedicated memory which is required for building web applications and further protecting the application from a wide array of irregularities and security infringements that might occur during the development process. 

3. Commendable speed

Speed is something that can render more power and authority to the web developers. If you are going with ASP.NET, you can expect quick and prompt arrangement of controls and facilities. Equipped with tables, easy-to-handle grids and wizards, ASP.NET offer you a suite of navigation, allowing you to execute web development projects smoothly. Eliminating the need for configuring a web server, ASP.NET permits you to get started with the app coding process rightaway.

Since ASP.NET runs on its own web server, you need not worry about configuring a new server on your system. The framework automatically spins a web server for your use. This is indeed a feature unavailable in a variety of other web app programming frameworks.

4. Lesser coding

Unlike a wide collection of web app development frameworks, ASP.NET comes with brilliant functional capabilities, thereby eliminating the need for any lengthy and complex coding. Features such as:WYSIWYG editing, drag-and-drop server controls and multi-lingual support make ASP.NET a framework worth working with. These features make ASP.NET a viable option for both professionals as well as the beginners who’ve just started using the framework for developing out-of-the-box web applications.

5. Trustworthy and consistent

With authentication and data validation serving as two strong assets of ASP.NET, it won’t be wrong to call it as one of the most reliable web development systems. Rich in streamlined components, ASP.NET allows a web program to automatically detect and recover from bugs, followed by acting in the right way. Issues such as crash protection, dead locks and memory leaks are being addressed well by ASP.NET.

As a web developer, you’ll no longer have to worry about system exceptions and all the scrubbing incoming data during web app development. ASP.NET is already designed to handle all this and much more for you. All you need to do is delve into some easy coding and you’re done with building a perfect web solution.

Wrapping it all up

The aforementioned pointers are just the tip of an iceberg. There’s a lot more to explore with the ASP.NET programming framework. If you’re looking forward to develop rich and expensive web applications then ASP.NET is the platform you can choose without giving a second thought. Looking at the ever-growing demands of today’s clients, ASP.NET is the tool that will help you meeting every type of web app development requirement.