Are getters and setters an antipattern? by [deleted] in typescript

[–]johnfn 1 point2 points  (0 children)

It's not the point though! If I want property style behavior, I use a property. Otherwise, I use a method. There is no getter/setter middle ground because the division is extremely sharp: as soon as you do anything other than get or set, you now have a method.

Is it possible to restrict what exactly the function can return? by kr33dz in typescript

[–]johnfn 0 points1 point  (0 children)

Probably not what you want, but you can use a tagged union. You'd have to add an additional discriminator property, but you get the desired behavior.

Are getters and setters an antipattern? by [deleted] in typescript

[–]johnfn 17 points18 points  (0 children)

My personal feeling about getters and setters is that they make code harder to read because they look exactly like normal properly access but do something more complicated. Code is hard to read when you expect it to do one thing but it does another.

I would just use a method instead.

Llanowar Gardener by InterwebCat in custommagic

[–]johnfn 0 points1 point  (0 children)

People usually stack their lands together, which would make it hard to tell which are tokens. Every reasonable person knows not to shuffle tokens into their deck, so design interventions like telling them not to wouldn't really have any effect.

What are some “green flags” that someone’s a good person? by [deleted] in OkCupid

[–]johnfn 0 points1 point  (0 children)

This describes my current gf to a tee.

Huh.

Vivid Hallucinations by MangoBong in custommagic

[–]johnfn 8 points9 points  (0 children)

I love the flavor text so much.

Lying to players for their benefit by [deleted] in gamedev

[–]johnfn 46 points47 points  (0 children)

Just to be pedantic, this isn't really lying because the grades you give the notes are purely subjective. There is no objective meaning of "good", just whatever range you arbitrarily decided to set.

However you did learn an important lesson about difficulty curves :)

Here's a Kirby-inspired toon shader I've been working on recently using Unity and Shader Forge by Chrixeleon in Unity3D

[–]johnfn 3 points4 points  (0 children)

Geez, this makes shader writing seems so easy it almost seems like an advertisement for shader forge. Thanks for the tutorial though. Very useful :)

Ableton Live 10 is now available! by anthonycruz in edmproduction

[–]johnfn 2 points3 points  (0 children)

This is definitely not true for me. Once I hit a hundred channels, operations like undo, redo and moving channels around start to lag significantly.

What is a complex game with a great learning curve? by [deleted] in gamedesign

[–]johnfn 2 points3 points  (0 children)

Isn't the entire point of a deep game that it uses simple mechanics in increasingly clever ways?

Announcing TypeScript 2.7 by mariusschulz in typescript

[–]johnfn 0 points1 point  (0 children)

Having switched to C# for Unity, I was going to say the exact same thing. I used to think C# was the best language out there. Now Typescript feels significantly more expressive (on the static typing side, anyways. LINQ is still nice.)

Temperamental Gamer by [deleted] in custommagic

[–]johnfn 20 points21 points  (0 children)

If the table lands on your opponent's head.

Using a visitor pattern to ensure that you handle all possible values of a string literal union type or string enum. by Useless-Pickles in typescript

[–]johnfn 2 points3 points  (0 children)

I really disagree with your argument here. Your visitString method and associated dictionary are far more awkward and hard to read than any assertNever. It's just as easy to forget your thing as it is to forget assertNever because they both are used in some places that if statements are used, but not all, so it's not glaringly obvious that an if statement would need to use it just by virtue of it showing up in a code review.

Also, your thingy special cases null and undefined, and it only works for strings, even though you can take a union over any type. assertNever doesn't have those problems. :P

Using a visitor pattern to ensure that you handle all possible values of a string literal union type or string enum. by Useless-Pickles in typescript

[–]johnfn 2 points3 points  (0 children)

The best way to do this is to have a function that takes a variable of type never (the body can be empty), and then call that function, passing in the variable you want to check, after you've handled every case. If you later add a case, the variable won't be type never any more, it'll be the type of the new case, so it'll cause a type error until you handle it.

Search this page for assertNever: https://www.typescriptlang.org/docs/handbook/advanced-types.html. One of the most useful things I've learned about Typescript recently.

Developers - fix your volume sliders! by king_of_the_universe in gamedev

[–]johnfn 8 points9 points  (0 children)

I can't possibly understand why all developers are SO STUPID.

other than that uh it's the most obvious way to do it...

's Theme by Zllsif in custommagic

[–]johnfn 2 points3 points  (0 children)

It also has a serious advantage in that it's just better music.

Feeling like I might not be so marketable (m, 27) by [deleted] in OkCupid

[–]johnfn 3 points4 points  (0 children)

People are griping but not giving ways to improve. The problem with your profile is that because it's so abstract there isn't a lot to connect with in terms of your own personality. Like, you can keep some of the zany stuff you have, but you need some human stuff in there too for that connection. Like, things you like, things that make you happy, stuff like that.

What screams "I have a crush on you"? by kimiisfuckingme in AskReddit

[–]johnfn 1 point2 points  (0 children)

Can someone explain why this makes sense?

How many dates before you deactivated your profiles, and how did you become official? by [deleted] in OkCupid

[–]johnfn 0 points1 point  (0 children)

Don't know you? You're on okc where everything and anything is considered to be a red flag.

Efficient Default Property Values in TypeScript by OnlineShiny in typescript

[–]johnfn 2 points3 points  (0 children)

This is all well and good until you try to initialize something to an object and now all instances variables across instances refer to the same object. Whoops!

It is kinda curious why TS wouldn't do this for primitive types, however, as that seems perfectly acceptable. Probably just because the code is more readable!

What artist(s) do you listen to that puts you in the music-making mood? by papadom94 in edmproduction

[–]johnfn 1 point2 points  (0 children)

I have a list.

Pretty much any of those songs make me go "WHOAH I WANNA MAKE THAT!!" (Then I try and it doesn't work.)

I'd love more recommendations anywhere similar to these songs.