Programming Tips πŸ’‘
51.7K subscribers
67 photos
10 videos
30 files
354 links
Programming & AI:
Tips πŸ’‘
Articles πŸ“•
Resources πŸ‘Ύ
Design Patterns πŸ’Ž
Software Principles βœ…

πŸ‡³πŸ‡± Contact: @MoienTajik

🎯 Buy ads: https://telega.io/c/ProgrammingTip
Download Telegram
πŸ’‘ Consider the following three laws before writing Unit Test :

1- You may not write production code until you have written a failing unit test.

2- You may not write more of a unit test than is sufficient to fail, and not com-piling is failing.

3- You may not write more production code than is sufficient to pass the currently failing test.

#CleanCode #UnitTest #TDD
#Fun Unit Tests Fails πŸ˜…πŸ€¦πŸ»β€β™‚οΈ
β€œ Any fool can write code that a computer can understand, Good programmers write code that humans can understand .” πŸ‘ŒπŸ»

βž–Martin Fowler
Test code is just as important as production code❗️

It is not a second-class citizen .

It requires thought, design, and care .

It must be kept as clean as production code .

#CleanCode #UnitTest
What makes a clean test❓

Three things : Readability, readability, and readability.

Read-ability is perhaps even more important in unit tests than it is in production code .

What makes tests readable ❔

The same thing that makes all code readable :
clarity, simplicity & density of expression .

#CleanCode #UnitTest
#Fun Fails again πŸ˜‚πŸ€¦πŸ»β€β™‚οΈ
Class definition πŸ“

The name of a class should describe what responsibilities it does .

In fact, naming is probably the first way of helping determine class size.

If we cannot derive a concise name for a class, then it’s likely too large.

The more ambiguous the class name, the more likely it has too many responsibilities.

#CleanCode #Class
Classes Should Be Small ❗️

The first rule of classes is that they should be small .

The second rule of classes is that they should be smaller than that .

Our immediate question is always β€œHow small❓ ”

With functions we measured size by counting physical lines .

With classes we use a different measure .

We count responsibilities .

#Cleancode #Class
Getting software to work and making software clean are two very different activities .πŸ’‘

Most of us have limited room in our heads, so we focus on getting our code to work more than organization and cleanliness.

The problem is that too many of us think that we are done once the program works. ❌

We fail to switch to the other concern of organization and cleanliness.

#Cleancode
#Fun The Last TODO πŸ€¦πŸ»β€β™‚οΈ
Consistent Name Scheme πŸ“

Usually, Languages have their own naming conventions; For example, java uses camelCase.

Naming needs to stay consistent, otherwise, it will very difficult to find things inside the document .

There are two main ways to name things :

1.camelCase : which means that every word of the file name is capitalized except for the first one, for example: nameFilesConsistently

2.Underscores : in this case you write underscores between each word, for example:
name_files_consistently

#NamingConventions
When you can solve the same number of problems as your competitor, it is now down to coding skill and ... typing speed.

Try this typing test at https://10fastfingers.com and follow the instructions there on how to improve your typing skill.

You need to familiarize your fingers with the position of frequently used programming language characters, e.g :
braces {} or () or <>, semicolon β€˜;’, single quote for β€˜char’ and double quotes for β€œstring”, ... .

#competitive_programming
#Fun Coders Loves Their Code πŸ˜„β™₯️
Avoid Writing Long Code Lines ❌

Writing long lines of code makes it very difficult to read, moving back and forth horizontally, losing any sense of what it’s actually written.

Style and indentation will help with this .πŸ’‘

Keep also in mind,
the terminal window limits characters to 80 per line, so if the code is longer, it will be just cut, making it incomprehensible.

#CleanCode
@ProgrammingTip
In an ideal system, we incorporate new features by extending the system, not by making modifications to existing code ❗️

#Cleancode #OCP
If a system is decoupled enough to be tested, it will also be more flexible and promote more reuse. πŸ”„

The lack of coupling means that the elements of our system are better isolated from each other and from change.

This isolation makes it easier to understand each element of the system.πŸ’‘

#Cleancode #Decoupling
β€œComplexity kills. It sucks the life out of developers, it makes products difficult to plan, build, and test .”

βž–Ray Ozzie, CTO, Microsoft
#Fun Comments πŸ€¦πŸ»β€β™‚οΈ
" To write Clean Code, you must first write dirty Code and then Clean it.❗️"
βž–Bob C.Martin

You should code & code & code to become a master ... πŸ™‚πŸ”
Comments should say things that the code cannot say for itself ❗️

#Cleancode #Comments
@ProgrammingTip