6 Simple tips on how to write better readable code āœ…

Le thread šŸ§µšŸ‘‡šŸ¼
āœ… Use meaningful function and variable names

Avoid long phrases when naming.

Booleans should start with a verb (eg isActive, isOpen, isMoved...)

Names should be short easily understood
āœ… Don't Repeat Yourself (DRY)

A function is supposed to do just one thing!

Group tasks into functions and only call them when needed. This makes your code cleaner

Don't repeat code!
āœ… Avoid deep nesting

Don't:
if(..
if(...
if(...

Do:
if(...) {... return}
if(...) {...return}
āœ… Write defensive code

Identify undefined/null outcomes and defend yourself

let response = apiCall()
if(!response) {...}
continueExecution()

This way, the program will effectively handle null/undefined values first, then continue to execute if none returned.
āœ… Indent & Space-out your code

Consistent spacing out and indenting makes your code more readable and cleaner
Thanks for reading my thread šŸ’›

āœ… Follow me for more:

- Web3
- Blockchain
- Javascript HTML CSS
- Software development

... content

ā€¢ ā€¢ ā€¢

Missing some Tweet in this thread? You can try to force a refresh
怀

Keep Current with langford.devāš”

langford.devāš” Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @langford_dev

5 Jan
Learning Web3 is free! šŸ”„

My Top 10 YouTube Channels to learn Web3 development

Le Thread šŸ§µšŸ‘‡šŸ¼
Read 12 tweets
3 Jan
šŸ’› Web3 101 - Smart Contracts šŸ’›

Let's talk about smart contracts

- What are they?
- How do they work?

Le ThreadšŸ§µšŸ‘‡šŸ½
A smart contract is:

- like an agreement between two people in the form of code.

- Cannot be changed after its written (immutable)

- only executes when predetermined conditions are met

- can be executed on its own without any third parties

- runs on the blockchain
Let's assume Jef wants to buy Vik's car

A smart contract represents the agreement between Jef & Vik on the blockchain

The contract will be like this:

AFTER Jef pays Vik 10 eth, THEN Jef becomes the new owner of the car

The contract only executes if Jef pays Vik 10 eth
Read 6 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(