Programming Tips 💡
54.3K subscribers
66 photos
8 videos
30 files
339 links
Programming:
Tips 💡
Articles 📕
Resources 👾
Design Patterns 💎
Software Principles

🇳🇱 Contact & Ads: @MoienTajik
Download Telegram
Eval 👾

if you know about the dot notation, but are ignorant of the subscript notation, you might write:

eval("myValue = myObject." + myKey + ";"); 


instead of :

myvalue = myObject[myKey]; 


The eval form is much harder to read.
This form will be significantly slower because it needs to run the compiler just to execute a trivial assignment statement ❗️

#Tips #JavaScript
@ProgrammingTip
Properties of a good unit test

A unit test should have the following properties :

1️⃣ It should be automated and repeatable.

2️⃣ It should be easy to implement.

3️⃣ It should be relevant tomorrow.

4️⃣ Anyone should be able to run it at the push of a button.

5️⃣ It should run quickly.

6️⃣ It should be consistent in its results.

7️⃣ It should have full control of the unit under test.

8️⃣ It should be fully isolated (runs independently of other tests).

9️⃣ When it fails, it should be easy to detect what was expected and determine how to pinpoint the problem.

#UnitTest #Tips
@ProgrammingTip
Airbnb JavaScript Style Guide 🚀

Table of Contents 📜 :
• Types
• References
• Objects
• Arrays
• Strings
• Functions
• ...

[ https://github.com/airbnb/javascript ]

#JavaScript #Guide #Tips
@ProgrammingTip
You don’t have to memorize everything when it comes to Programming 🙅🏻‍♂️

Good programmers do not waste their time memorizing everything, every documentation, every piece of information.

But they are good at knowing the concepts and reading the documentation, googling and solving problems.

[ Website ] : http://bit.do/DontWasteTime


#Tips
@ProgrammingTip
Rubber Duck Debugging 🐤

In software engineering, rubber duck debugging or rubber ducking is a method of debugging code. 🐞

The name is a reference to a story in the book The Pragmatic Programmer in which a programmer would carry around a rubber duck and debug their code by forcing themselves to explain it, line-by-line, to the duck. 🗣

Many other terms exist for this technique, often involving different inanimate objects.

Many programmers have had the experience of explaining a programming problem to someone else, possibly even to someone who knows nothing about programming, and then hitting upon the solution in the process of explaining the problem. 👥

In describing what the code is supposed to do and observing what it actually does, any incongruity between these two becomes apparent. ↔️

More generally, teaching a subject forces its evaluation from different perspectives and can provide a deeper understanding. 👨🏻‍🏫

By using an inanimate object, the programmer can try to accomplish this without having to interrupt anyone else. 🙅🏻‍♂️


#Debugging #Tips
@ProgrammingTip
The art of asking "coding" questions 🎨

… is not working❗️🤦🏻‍♂️

Examples :
“npm install is not working”
“interpolation is not working”


“It’s not working” is not helpful ❗️

It doesn’t tell others about the problem you’re facing.

[ Website ] : http://bit.do/quea


#Tips #QA
@ProgrammingTip
What is currentColor in CSS

currentColor — As name says , it pick the current color reference in an class and when you assign currentColor as one of the value of the property it will show the refer color.

[ Article ] : http://bit.do/curro


#CSS #Tips
@ProgrammingTip
Yagni : You Arent Gonna Need It 👾

Never Add Functionality Early 💡

"Always implement things when you actually need them, never when you just foresee that you need them."


Even if you're totally, totally, totally sure that you'll need a feature later on, don't implement it now.

Usually, what you actually need is quite different from what you foresaw needing earlier. 🙅🏻‍♂️

This doesn't mean you should avoid building flexibility into your code.

It means you shouldn't overengineer something based on what you think you might need later on.

🔹🔸🔹🔸🔹🔸

There are two main reasons to practise YagNi :

1️⃣ You save time, because you avoid writing code that you turn out not to need.

2️⃣ Your code is better, because you avoid polluting it with 'guesses' that turn out to be more or less wrong but stick around anyway.

This also follows the KISS theorem:
Keep it simple, stupid!


https://t.me/pgimg/13

#CleanCode #Principles #Tips
@ProgrammingTip
A Pattern is a solution to a problem in a context.

We're going to step throught each of these parts, context, problem and solution :

The context is the situation in which the pattern applies. This should be a recurring situation. 👨🏻‍🔧

The problem refers to the goal you are trying acheive in this context, but it also refers to any constraints that occur in the context. 🏆

The solution is what you're after : a general design that anyone can apply which resolves the goal and set of constraints. 🏅

Example
Problem: How do I get to work on time

Context: I've locked my keys in the car. 🗝

Solution: Break the window, get in the car, start the engine and drive to work. 🚗


"If you find yourself in a context with a problem that has a goal that is affected by a set of constraints, then you can apply a design that resolves the goal and constraints and leads to a solution."



#DesignPatterns #Tips
@ProgrammingTip
If you don't need it now, don't do it now❗️

Design Patterns are powerful, and it's easy to see all kinds of ways they can be used in your current designs.⚡️

Developers naturally love to create beautiful architectures that are ready to take on change from any direction.💙

If you have a practical need to support change in a design today, go ahead and employ a pattern it handle that change.

However, if the reason is only hypothetical, don't add the pattern, it is only going to add complexity to your system, and you might never need it.


#DesignPatterns #Tips
@ProgrammingTip
Never commit code that’s been commented out 🚫

I’ve never understood the reasoning behind committing code that’s been commented out. 🤔

I assume it’s to keep old versions of the code around just in case the new code doesn’t work, but that’s just bizarre. ⚠️

Keeping track of old versions is the reason we use a version control system in the first place❗️

Why was the code commented out
Does it work
Should it work
Has it ever worked
Is it something we should strive towards or run away from

Code that’s been commented out is worse than useless, because every time it’s read, it raises questions like these without providing any answers.

It only serves to confuse and distract from the code in use. 🤯


https://t.me/pgimg/134


#Tips #Git
@ProgrammingTip