The Principles Of Good Programming


Programming principles have helped me over the years in becoming a better programmer, and I believe, this article will help any developer become more efficient and able to produce code which is easier to maintain. By following these coding principles, you can save development and maintenance time, and conquer lots of other bottlenecks which generally arise in later development phases.

What are Programming principles?

Programming is the process of coding, testing, troubleshooting, debugging and maintaining a system. Programming principles help you to write excellent quality of code and maintain a good coding practice.

Why should a developer follow the principles?

When I started my adventure with programming in C language, I wrote complete spaghetti code. After that, I started coding in C#. Here also, I did the same thing. It means each file had many responsibilities, no abstraction, and it was difficult to debug and fix issues. I am not only one person working on applications; my team is working on the same. Later, I started thinking how to improve quality of the code. And the answer is Coding Principles.

Actually, writing programs is often a matter of personal taste but there are certain principles or guidelines that should be followed within your own style in order to make programs easy to maintain and understand by both, you and others, and also principles guide the creation of stable, scalable, and robust code.

What are the benefits if developer followed it?

  1. Readability
    All developers were in a team able to understand the code.

  1. Extensibility
    In the software world, we should not blame the change requests; it’ll come at any time. So our code is always easy to extend without breaking existing business rules.

  1. Maintainability
    It’s easy to maintain by the development team and the production support team too because the application is loosely coupled.

  1. Modularity
    Divide a program into reusable pieces: functions, modules, libraries.

Types of Programming Principles

  1. DRY (Don’t-Repeat-Yourself )

    Duplication can lead to maintenance nightmares, poor factoring, and logical contradictions. "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system". In other words, a piece of logic should only be represented once in an application.

    • Duplication is the root of all software evils.
    • Duplication is a waste.

      DRY is also known as Duplication is Evil (DIE) or Once And Only Once.

  1. KISS (Keep It Simple, Stupid)

    Nowadays programming languages, frameworks, and APIs have powerful means to create sophisticated solutions for various kinds of problems. Sometimes developers might feel tempted to write “clever” solutions that use all these complex features.

    The KISS principle states that most systems work best if they are kept simple rather than making them complex; therefore simplicity should be a key goal in design and unnecessary complexity should be avoided.

    This principle can be applied to any scenario, including many business activities, such as planning, designing, and development.
  1. YAGNI (You Aren’t Gonna Need It)

    As developers, we'll always think a lot about the future usability of the project and try to do some extra features coding in a mind that “just in case we need them” or “we will eventually need them”. Just one word… Wrong! I’ll repeat it this way: You didn’t need it, you don’t need it, and in most of the cases… “You Aren’t Gonna Need It”.

    YAGNI states that "don’t implement something until it is necessary".

    There are two main reasons to practice YAGNI,
    • You save time because you avoid writing code that you turn out not to need.
    • Your code is better because you avoid polluting it with 'guesses' that turn out to be more or less wrong but stick around anyway.
  1. SOLID

    SOLID principle supports good object-oriented design and programming. Five of these principles are described as SOLID: Single responsibility, Open-closed, Liskov substitution, Interface segregation, and Dependency inversion. I am a fan of this SOLID principles article. Please read it. I am sure you'll love it.


You should not forget that writing a program is self-discipline. You should bear in your mind that you are not the only person who will deal with your programs. Moreover, properly written programs would be very helpful to you, as well, while debugging.

These principles will help you and others in the team to write or deliver good, clean, and high-quality code.

Similar Articles