TGViewer
Channel Public Channel
Programming & AI Tips πŸ’‘

Programming & AI Tips πŸ’‘

@programmingtip

Programming & AI:
Tips πŸ’‘
Articles πŸ“•
AI & LLMs πŸ‘Ύ
Design, Architecture, Principles βœ…

πŸ‡³πŸ‡± Contact: @MoienTajik
Subscribers
46.3K
Photos
67
Videos
11
Links
377

Showing posts older than #138 Β· Back to latest

Older Posts 20 shown
Post #137 823
JavaScript Clean Code πŸ› 

Don't add unneeded context πŸ’‘
If your class/object name tells you something, don't repeat that in your variable name.

Bad :
const Car = {
carMake: 'Honda',
carModel: 'Accord',
carColor: 'Blue'
};

function paintCar(car) {
car.carColor = 'Red';
}


Good :
const Car = {
make: 'Honda',
model: 'Accord',
color: 'Blue'
};

function paintCar(car) {
car.color = 'Red';
}


βž–βž–βž–βž–βž–βž–
#JSTips #CleanCode
@ProgrammingTip
Post #136 842
JavaScript Clean Code πŸ› 

We will read more code than we will ever write. It's important that the code we do write is readable and searchable.πŸ’‘

Bad :
// What the heck is 86400000 for?
setTimeout(blastOff, 86400000);


Good :
// Declare them as capitalized `const` globals.
const MILLISECONDS_IN_A_DAY = 86400000;

setTimeout(blastOff, MILLISECONDS_IN_A_DAY);


βž–βž–βž–βž–βž–βž–
#JSTips #CleanCode
@ProgrammingTip
Post #133 856
JavaScript Clean Code πŸ› 

Use explanatory variables πŸ’‘

Bad :
const address = 'One Infinite Loop, Cupertino 95014';

const cityZipCodeRegex = /^[^,\\]+[,\\\s]+(.+?)\s*(\d{5})?$/;

saveCityZipCode(address.match(cityZipCodeRegex)[1], address.match(cityZipCodeRegex)[2]);


Good :
const address = 'One Infinite Loop, Cupertino 95014';

const cityZipCodeRegex = /^[^,\\]+[,\\\s]+(.+?)\s*(\d{5})?$/;

const [, city, zipCode] = address.match(cityZipCodeRegex) || [];

saveCityZipCode(city, zipCode);


βž–βž–βž–βž–βž–βž–
#JSTips #CleanCode
@ProgrammingTip
Post #131 884
JavaScript Clean Code πŸ› 

Use default arguments instead of short circuiting or conditionals πŸ’‘

Bad :
function createMicrobrewery(name) {
const breweryName = name || 'Hipster Brew Co.';
// ...
}


Good :
function createMicrobrewery(breweryName = 'Hipster Brew Co.') {
// ...
}


βž–βž–βž–βž–βž–βž–
#JSTips #CleanCode
@ProgrammingTip
Post #130 867
JavaScript Clean Code πŸ› 

Use meaningful and pronounceable variable names πŸ’‘

Bad :
const yyyymmdstr = moment().format('YYYY/MM/DD');


Good :
const currentDate = moment().format('YYYY/MM/DD');


#JSTips #CleanCode
@ProgrammingTip
Post #126 1.03K
Android Asset Studio πŸ› 

A web-based set of tools for generating graphics and other assets that would eventually be in an Android application's res/ directory.

βž–Launcher icons
βž–Action bar icons
βž–Notification icons
βž–Generic square icons
βž–Simple nine-patches

https://jgilfelt.github.io/AndroidAssetStudio/

#Android #Tools
@ProgrammingTip
Post #125 1.02K
#Fun NPM Delivery
Post #124 1.06K
Measuring Time πŸ•°

Many applications require a very precise time measurement. For this purpose, Java provides static methods in System class. πŸ”†

1️⃣ - currentTimeMillis(): Returns current time in MilliSeconds since Epoch Time, in Long.
view sourceprint?

long startTime = System.currentTimeMillis();
long estimatedTime = System.currentTimeMillis() - startTime;


2️⃣ - nanoTime(): Returns the current value of the most precise available system timer, in NanoSeconds, in long.

nanoTime() is meant for measuring relative time interval instead of providing absolute timing.

long startTime = System.nanoTime();
long estimatedTime = System.nanoTime() - startTime;


#java #time
@ProgrammingTip
Post #120 1.15K
JSF*ck πŸ€¦πŸ»β€β™‚οΈ

It's a programming style based on the atomic parts of JavaScript.

It uses only 6 different characters to write and execute code.

Try it one time 🀣

http://www.jsfuck.com/

#Fun #JavaScript
@ProgrammingTip
Jsfuck JSFuck - Write any JavaScript with 6 Characters: []()!+ JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to execute code.
Post #115 1.2K
Creating a Responsive website using Boostrap Studio Tutorial ⚜️
Older posts β†’
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook β†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 β†’