Code Design

Manik Jindal
code-design
Published in
3 min readOct 16, 2016

It has been long since I wanted to do a series where I could discuss my understanding of the words Code Design and what follows with it, with a wider audience and hear their perspective on it.

I wish to do this series because my philosophy really resonates with with what Einstein said, “If you can’t explain it simply, you don’t understand it well enough.” Like him, I too believe that one has truly started to master the subject, only when they can transfer their understanding of how-things-are to someone else.

This belief would serve as my underlying ideology for the series. Wherever I can, I’d aim to explain things in a more Explain-Like-I’m-5 fashion.

Categorization of Code Design Topics

If I were to broadly categorize the various topics in code design, they would be:

  • Concepts — Concepts or fundamentals are what really form the basis of most other topics in code design. Things such as Invariants, Contracts (Interfaces), Immutability, etcetera, all belong to this category. Although the methodology of learning depends from person to person, some just read and get it, others require a more elaborate study, but, the end goal is one — To understand it from the level of the being. To grok it.
  • Principles — With respect to their definition, principles do really well to hold their ground across domains. They are simply somethings that you have to follow before you can really appreciate the benefits they bring.
  • Patterns — Patterns are nothing but consolidated learnings of the application of good code-design. The design problems that have been seen again and again over the years, have been met with various answers. Some answers were good, others not so much.
    Patterns are really just a well documented form of these problems and their solutions. So that one who faces any common design problem can simply lookup its solution and use it; a solution whose kinks have been ironed out over due course of time.
  • Language Idioms — Language idioms represent a meeting point of the above three categories with the concreteness of a programming language. They are simple the best identified way to solve a well known problem in the given language.

First Step

Having talked about all the mundane stuff, I wish to bring you to three questions, questions whose answer we will learn as the series progresses.

  1. What is Code Design?
  2. Why is it important?
  3. What differentiates a well designed code from one that is not?

So every time you finish reading a post here, see if your understanding of these question becomes clearer — at least this, is my end goal.

Goals of Code Design

Code design really has only a few goals, the foremost of which is making the code more maintainable. Maintainability encompasses both — introducing fewer bugs and writing inherently extensible code for future feature additions.

Apart from that the other goal of code design could be to make the code more reusable so that one could pick out modules from a codebase or project and use them in another — saving both time and effort.

One Last Thing

The only impediment to learning good code design is considering code design as optional, secondary or merely good-to-have. You may not know the answers to your design questions yet, but you’d learn only if you keep asking those questions.

-Manik Jindal

--

--