Objects and Data Structures – The Law of Demeter

How much information about one object should another object have? Should an object be able to access the inner objects of another one? The law of Demeter Simply put, the Law of Demeter says that an object shouldn’t have knowledge of the inner workings of another object. A method in an object should only have…

Continue reading

Objects and Data Structures – Data Abstraction

Object Oriented Programming (OOP) is a programming paradigm in which we use real world concepts or objects and create abstractions that will represent them in our software. Data Abstraction When we create an abstraction to represent a real world concept or object, we have to decide what that abstraction will expose and what it will hide (private…

Continue reading

Formatting – Horizontal Formatting

What is the maximum length for a line of code? A long time ago, monitors were only capable of showing only 80 characters per line so that was the limit. Currently, with widescreen monitors and small fonts you can have lines that are definitely way too long. According to the book clean code, most lines…

Continue reading

Formatting – Vertical Formatting

Continuing our series on formatting we will first address the concept of vertical formatting. File Size How many lines of code should a file have? This is a question that people can start a very “interesting” conversation. Some people prefer very short files while others have no problem with files that have more than a…

Continue reading

Formatting – Why it’s important

Think about visiting a restaurant where the food is excellent, but the kitchen is a mess. Even if you loved the meal, seeing the kitchen will make you think twice about eating there again. Another example that is closer to the computer world is data centers. Look at the following picture. Which network installation do you…

Continue reading

Comments – Bad Comments (Part 2)

In this post, we continue with the examples of bad comments. Position Markers Sometimes people put a comment marking an important place in a file, or to separate the sections (variable definitions, methods, etc.) inside the file. This is something that should only be done in special cases, since overuse can just make the comments…

Continue reading

Comments – Bad Comments (Part 1)

In our previous post, we looked at cases where  including comments in your code is a good thing. This time we will look at the cases where comments are a bad thing. The examples that we mention below, are bad, mainly because they are used as a compliment to code that can be cleaner. The…

Continue reading

Comments – Good Comments

Even though you should generally try to write your code in a way that doesn’t need comments, there are cases where they can be valid. Below are some examples. Legal Comments Sometimes your job will require you to put some legal comments at the beginning of your file. Maybe you’re using some open source code…

Continue reading