Click here to Skip to main content
15,886,830 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Thanks for the trip down memory lane Pin
raddevus15-Feb-21 2:58
mvaraddevus15-Feb-21 2:58 
GeneralRe: Thanks for the trip down memory lane Pin
Dr.Walt Fair, PE18-Mar-21 7:11
professionalDr.Walt Fair, PE18-Mar-21 7:11 
GeneralRe: Thanks for the trip down memory lane Pin
englebart2-Sep-22 3:51
professionalenglebart2-Sep-22 3:51 
GeneralRe: Thanks for the trip down memory lane Pin
Kirk 1038982111-Feb-21 1:00
Kirk 1038982111-Feb-21 1:00 
GeneralRe: Thanks for the trip down memory lane Pin
Wayne Welpe11-Feb-21 2:17
Wayne Welpe11-Feb-21 2:17 
GeneralRe: Thanks for the trip down memory lane Pin
Gary R. Wheeler19-Mar-21 13:58
Gary R. Wheeler19-Mar-21 13:58 
GeneralRe: Thanks for the trip down memory lane Pin
RDM Jr1-Jan-22 5:20
RDM Jr1-Jan-22 5:20 
Generalad hoc Programming PinPopular
raddevus6-Jan-21 9:19
mvaraddevus6-Jan-21 9:19 
Last night herself was watching a show and I decided to start reading a book to learn React. Sigh | :sigh: I know, but I wanted to see what it does.

The 2nd chapter of this book (Learning React: Modern Patterns for Developing React Apps 2, Banks, Alex, Porcello, Eve, eBook - Amazon.com[^]) melted my brain!!

I discovered JavaScript Destructuring!
Quote:
Destructuring assignment allows you to locally scope fields within anobject and to declare which values will be used.


Code Sample
JavaScript
const sandwich = {  bread: "dutch crunch",  
             meat: "tuna",  cheese: "swiss",  
      toppings: ["lettuce", "tomato", "mustard"]
};
const { bread, meat } = sandwich;
console.log(bread, meat); // dutch crunch tuna


You see, the sandwich object can be all chopped up and turned into separate objects.

It's very cool AND very terrible!

Destructured Array
JavaScript
const [firstAnimal] = ["Horse", "Mouse", "Cat"];
console.log(firstAnimal); // Horse


See, now you have a variable that contains the first value.

Suppose you want a variable that contains the last value.
JavaScript
const [, , thirdAnimal] = ["Horse", "Mouse", "Cat"];
console.log(thirdAnimal); // Cat


Getting To A Point
I'm getting to the main point, here and I think it has a pay-off

Now we also know that JavaScript (and many modern languages) have the concept of a anonymous functions (C#) or arrow functions in JavaScript.

They are very convenient and helpful and can make code much more readable.
JavaScript
hello = val => console.log("Hello " + val);
hello("test this") // Hello test this


Think About the Young Impressionable Minds
Now, think about new devs who come along and learn this stuff first thing.
Suddenly this is the beautiful code. It is amazing.
You can do anything at anytime. It's ad hoc!!!

You don't have to worry about program structure or anything, cuz you can just get your values and re-organize them (destructure) and create an arrow function and you're on your way.

Think about how different that learning to program is now!?!

My mind exploded!! Now I understand why software is actually further from an engineering discipline now. Back in the day we focused on at least some beginning structure, some OOP and architecture.

It Was About Organization
It wasn't just about rigidity, it was about organization. It was hopefully better for maintenance.

Steaming Pile of Software
Now, just sit down and type and suddenly you have a steaming pile of software.

Yes, I understand how great these things can be for DTO (data transfer objects) etc. but learning this stuff first is probably very unhelpful.

Just thought it was interesting. And this is why I learn new code and read new books all the time. Programming is definitely changing.
GeneralRe: ad hoc Programming Pin
  Forogar  6-Jan-21 9:26
professional  Forogar  6-Jan-21 9:26 
GeneralRe: ad hoc Programming PinPopular
Ryan Peden6-Jan-21 10:47
professionalRyan Peden6-Jan-21 10:47 
GeneralRe: ad hoc Programming Pin
raddevus6-Jan-21 10:54
mvaraddevus6-Jan-21 10:54 
GeneralRe: ad hoc Programming PinPopular
Ryan Peden6-Jan-21 11:04
professionalRyan Peden6-Jan-21 11:04 
GeneralRe: ad hoc Programming Pin
Jon McKee6-Jan-21 11:29
professionalJon McKee6-Jan-21 11:29 
GeneralRe: ad hoc Programming Pin
honey the codewitch6-Jan-21 14:45
mvahoney the codewitch6-Jan-21 14:45 
GeneralRe: ad hoc Programming Pin
Jon McKee6-Jan-21 14:48
professionalJon McKee6-Jan-21 14:48 
GeneralRe: ad hoc Programming Pin
honey the codewitch6-Jan-21 14:49
mvahoney the codewitch6-Jan-21 14:49 
GeneralRe: ad hoc Programming Pin
Jon McKee6-Jan-21 14:58
professionalJon McKee6-Jan-21 14:58 
GeneralRe: ad hoc Programming Pin
honey the codewitch6-Jan-21 15:54
mvahoney the codewitch6-Jan-21 15:54 
GeneralRe: ad hoc Programming Pin
GuyThiebaut10-Feb-21 21:07
professionalGuyThiebaut10-Feb-21 21:07 
GeneralRe: ad hoc Programming Pin
Jon McKee11-Feb-21 0:17
professionalJon McKee11-Feb-21 0:17 
GeneralRe: ad hoc Programming Pin
Rob Grainger16-Mar-21 5:49
Rob Grainger16-Mar-21 5:49 
GeneralRe: ad hoc Programming Pin
Jon McKee16-Mar-21 10:30
professionalJon McKee16-Mar-21 10:30 
GeneralRe: ad hoc Programming Pin
Richard Deeming6-Jan-21 23:40
mveRichard Deeming6-Jan-21 23:40 
GeneralRe: ad hoc Programming Pin
Marc Clifton6-Jan-21 11:45
mvaMarc Clifton6-Jan-21 11:45 
GeneralRe: ad hoc Programming Pin
Chris Maunder5-Feb-21 14:01
cofounderChris Maunder5-Feb-21 14:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.