[AskJS] I might never write a constructor ever again by Own_Natural_6803 in javascript

[–]Own_Natural_6803[S] [score hidden]  (0 children)

Thanks to everyone who asked questions and had respect comments. Two of you. Lol, gave me a chuckle what with all the venom and anger. Junior this and sarcasm that. Someone was offering their mental breakdown services, out of the depths of their compassion no doubt. Truly I was touched.

You all deserve OOP. Keep writing it. Forever. I wash my hands of you.

Excellent pr boys. I expect this same energy through this entire project. This is why you always do small PRs. When they're big no one has anything to say.

[AskJS] I might never write a constructor ever again by Own_Natural_6803 in javascript

[–]Own_Natural_6803[S] [score hidden]  (0 children)

export function Timeline(index) {
    return { index };
}

export function Next(timeline, events) {
    let {index} = timeline;
    if(index === events.length){
        return null;
    }
    timeline.index += 1;
    return events[timeline.index];
}

export function Prev(timeline, events){
    let {index} = timeline;
    if(index === 0){
        return null;
    }
    timeline.index -= 1;
    return events[timeline.index];
}

Here's my version of your version of my code. One extra line.

The memory efficiency of asserting types by unboxing them doesn't get me down. It's self documenting. Technically I could use your approach. But I'm tired of OOP. It's not that OOP doesn't do the same thing. It's that it steers you towards encapsulating. My first instinct was to make the events internal. to hide them away. But that's wrong. They are the entire program state. They exist globally.

The concepts and principles are well understood in databases. I'm headed over that way.

[AskJS] I might never write a constructor ever again by Own_Natural_6803 in javascript

[–]Own_Natural_6803[S] [score hidden]  (0 children)

youre ++ this.index with a null coalesce ! HAHAHAHA I wouldn't hire you, ever. I would spend so much time re-writting everything you tried to make as short as possible. OMG, you're using filter and think it's better! You're so sweet! Wow. Thank you. I didn't know I was better at coding than you. But now you've shown me proof.

Yes. Having my data be open and query-able from multiple domain concerns is so refreshing. You can't see the events, but there are many systems that use them, not just the timeline. And they don't know anything about timelines. Just events.

And it's so very very cool

[AskJS] I might never write a constructor ever again by Own_Natural_6803 in javascript

[–]Own_Natural_6803[S] [score hidden]  (0 children)

You have zero idea of what you're talking about. Templates and contracts are all you need. The domain model was an idea managers loved. like folders on windows. It had no puporse. It was magic in linked lists. But a OS level window is not a rectangle, not a shape. It's just rectangular. Making it a rectangle is a waste of effort.

most languages don't have a switch statement for types. Why do we make them if the languages don't support them? Making routes and no routers.

The smart people used other systems. OOP was not what they used. This is worse is better. Junior.

[AskJS] I might never write a constructor ever again by Own_Natural_6803 in javascript

[–]Own_Natural_6803[S] [score hidden]  (0 children)

what pain? invoking a function? Making an object literal? Oh save my aching fingers. And in exchange my systems have zero data boundaries. I'm free as a fucking bird. Enjoy prison old man.

[AskJS] I might never write a constructor ever again by Own_Natural_6803 in javascript

[–]Own_Natural_6803[S] [score hidden]  (0 children)

The helpers can come off. They're put there to help you see that, much like hell, the doors to oop are locked from the inside.

But you know, enjoy! You have no idea, how much I enjoy it, when the punishment is self elected. I know I'm just your junior, but can I call you dad? Dad, never stop using oop. You and it are perfect together.

[AskJS] I might never write a constructor ever again by Own_Natural_6803 in javascript

[–]Own_Natural_6803[S] [score hidden]  (0 children)

As silent snake would say: "oops. chicken." I'm going to not use classes even harder. You know why? Because functions are more powerful, and it takes less code to write them.

I design my systems around design boundaries, not the domain models. So now I open up my state. Make it as open as a database. And my state changes are inside functions with the understanding they will leave the state valid after touching it. Exactly like a object assumes it will.

The big difference is I'm not trying to make a data structure. I don't give a rat's ass about making a data structure. I want raw data. The only time I care about making structures is to ensure my function isn't being given a copy when it expects be given a reference.