There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

devfuuu , in new preference war just dropped

Yes.

alexdeathway , (edited ) in new preference war just dropped
@alexdeathway@programming.dev avatar

First one are method name, second one are status name.


<span style="color:#323232;">
</span><span style="color:#323232;">def open_file_dialog(self):
</span><span style="color:#323232;">       self.dialog_file_open = True
</span><span style="color:#323232;">       pass
</span><span style="color:#323232;">
</span>

Yoda level preference war.

Croquette ,

I tend to add is to booleans toreally differentiate between a method name and a status.


<span style="color:#323232;">def open_file_dialog(self):
</span><span style="color:#323232;">    self.dialog_file_is_open = True
</span><span style="color:#323232;">    pass
</span>

That way, it’s easier for my dumb brain to spot which is which at a glance.

fourwd ,
@fourwd@programming.dev avatar

In Elixir, we mark statuses by using a question mark at the end of the variable name. Something like this:


<span style="color:#323232;">authorized? = user |> get_something() |> ensure_authorized?()
</span>

I like this better than the is_ prefix

alexdeathway , (edited )
@alexdeathway@programming.dev avatar

does ‘?’ have type definition in elixir or this is generally agreed design pattern?

Faresh ,

If it’s like Lisp, then ? is just part of the symbol and doesn’t have any special syntatic meaning. In different Lisps it’s also convention to end predicate names with a ? or with P (p for predicate)

cytokine0724 ,

jealously weeps in ruby

FMT99 ,

We do this in Ruby all the time, we just prefer methods over variables, usually.


<span style="color:#323232;">def authorized?
</span><span style="color:#323232;">  current_user&.authorized?
</span><span style="color:#323232;">end
</span>
cytokine0724 ,

I’m a principal backend engineer routinely writing Ruby for my day job, so I’m familiar, lol. But you can’t do it for local variables and that just sucks. Definitely a +1 for Elixir.

db0 ,
@db0@lemmy.dbzer0.com avatar

is_dialog_file_open

fite me

TheSlad ,

No fiting. IS always goes at the start of names for booleans you are correct

sus ,

that works for 2 word names eg is_open or is_file, but in this case is_dialog_file_open is structured like a question, while dialog_file_is_open is structured like a statement

red ,

It still works. is_this_thing_some_thingy. Is is just a prefix for if the suffix returns true/false.

Rinox ,

Doesn’t matter, the point is that, if it starts with “is” then you automatically know it’s a boolean.

Yondoza ,

This is the way.

Command statement = an action

Question statement = a status

crispy_kilt ,

Lol mutable state

souperk , in Hot Potato License
@souperk@reddthat.com avatar

So that’s the legal equivalent of the guy committing 10k changes the day before leaving the company…

Wimopy , in Hot Potato License

Ok, I might be misunderstanding here, but since committing changes is allowed for everyone, doesn’t this mean fixing bugs is something you could do? You’d just be stuck with all the other rights as well until someone else makes a change.

unexposedhazard ,

The main dev made the last commit, so they dont have the right to make another commit, until they arent the last person to make a commit anymore (until someone else has made a commit). This makes sure that there are at least 2 people making commits but hopefully much more.

In other words, making a commit revokes your right to do so until someone else makes a commit.

Cethin ,

Am I just bad at reading? It says the right to make changes is granted to everyone one Earth. That would include the last person to make a commit as well, assuming they’re a citizen of Earth. I’m sure what you’re saying is what it’s supposed to say, but it isn’t actually what it says.

mexicancartel ,

All rights reserved by…, except the right to commit to this repository.

Being a legal license it requires much more rigorous and clear statement

stankmut ,

You can’t just ignore the second part of that sentence which gives the right to make commits to all citizens of earth. That would include the person who wrote the last commit.

mexicancartel ,

Thats why I said it needs to be more rigorous. The license probably meant Everyone in the earth except the last person who commited to it

lugal ,

Are you doxing OOP right now??? How do you know they life on earth?

mexicancartel ,

All rights reserved by…, except the right to commit to this repository.

Being a legal license it requires much more rigorous and clear statement

sxan ,
@sxan@midwest.social avatar

That may be what they meant, but that’s not what it says.

zewm ,
@zewm@lemmy.world avatar

The fact that you have 38 upvotes with such an incorrect statement is mind boggling.

This is how politics works I supposed. Write something that sounds plausible but is completely incorrect, inaccurate or completely fabricated and stupid people applaud and follow.

unexposedhazard , (edited )

Its ok to be unable to read, but dont make that other peoples problem.

github.com/ErikMcClure/…/hot-potato-license

This is copied from V2 but same thing:

All rights reserved by the last person to commit a change to this repository,

No explanation needed

except for the right to commit changes to this repository,

Also no explanation needed

which is hereby granted to all inhabitants of the Milky Way Galaxy for the purpose of committing changes to this repository.

This refers to the previous section meaning everyone can make commits to the repository except for the person excluded by that same section

Zeshade ,

They should’ve said “all other inhabitants” to remove the ambiguity.

brisk ,

A right not being reserved does not mean it is waived, only that it is not exclusive. The last person to commit still has the right to commit, as does everyone else.

FiniteBanjo ,

Yeah, the problem with the proposition is that you have all rights and access to the code regardless of who made the last commit, unless the last person to commit revoked the HPL.

MNByChoice ,

The last person cannot revoke the right to make commits.

I have no idea what that implies about the right to change the license.

Swedneck ,
@Swedneck@discuss.tchncs.de avatar

the fact that there are this many people having different interpretations shows that the license would need waaaaaay clearer wording to hold any sort of water.

this is why i hate licenses like WTFPL and its ilk, just saying “do whatever” cannot possibly be legally viable and thus using anything with such a license is impossible by anyone who cares about copyright law (such as say, companies).

If you want your creations to be free for all to use, just slap a fat CC0 on it.

uservoid1 , in Hot Potato License

What happen when the repository is getting forked? Goofing with the license is all haha fun till nasty lawyers get into the picture and you get all sort of liability claims

ImplyingImplications ,

Just writing words doesn’t make it legally binding. Anyone who reads this comment owes me $1,000,000 USD.

ogeist ,

Oh shit, what’s your PayPal?

Anyone who reads this comment owes me $1,000,000 USD and a kiss

oessessnex ,

I don’t have 2 mil, how do I get out of this? File for bankruptcy?

pupbiru ,

on a technicality, debts like this are not legally dischargable through bankruptcy

refurbishedrefurbisher ,

Ah, the student loan loophole

Speculater ,
@Speculater@lemmy.world avatar

What’s the opposite of a loophole? That’s what student loans are.

Swedneck ,
@Swedneck@discuss.tchncs.de avatar

a legal dick jammed up your hole

morrowind ,
@morrowind@lemmy.ml avatar

If anyone I owe money to reads this, the debt is reversed.

I’ll take the kiss though

narc0tic_bird ,

I don’t have the money, can I kiss you twice instead?

unexposedhazard ,

Ofcourse its legally binding. If you include a license text with your own code on a platform that doesnt have a clause to license your code under different terms, then that license is legally valid.

But writing the license yourself without making sure that it doesnt allow for any legal loopholes is a bad idea.

bitfucker ,

What the fuck are you talking about? Do you think the license being used is not legally binding? What constitutes as legally binding to you?

MartianSands ,

You declaring a debt isn’t meaningful because you don’t have legal authority to do so.

A licence statement is describing in what way you’re granting permission for something you do have the right to control, which makes it meaningful

nogooduser ,

If you want to fork the repo then you make a commit to the original repo giving yourself rights then you make the fork and you’re golden.

MacNCheezus ,
@MacNCheezus@lemmy.today avatar

I was gonna say, just make a commit changing the license to something else, like MIT?

Faresh ,

I think this is a sort of anti-license, so I think the sort of people who use it reject copyright law.

uservoid1 ,

Sounds like programmers with sovereign citizen approach

marcos ,

What happen when the repository is getting forked?

You get two code bases with different ownership.

That’s a very practical license, that reflects the concept as it is practiced. It’s probably the only one that doesn’t come from an ivory tower.

iAvicenna , in Unit Tests
@iAvicenna@lemmy.world avatar

what if someone tries to input a cat to this function?

Mertn33 ,

‘’'5 1 g

umbrella , in Not really sure whether S-expressions or Python indentation-based scoping get more hate...
@umbrella@lemmy.ml avatar

one of my least favorite things about python is semantic whitespace. no need to comment on yaml.

fuck it, parenthesis all the way.

Scoopta ,
@Scoopta@programming.dev avatar

This sums up how I feel nicely. No issues with parens…but whitespace…fuck that shit

jjjalljs , in Unit Tests

It’s strangely satisfying when the “this will probably never happen” test case finds a problem during development.

I had tests for deleting that were like

  • create item a
  • create item b
  • delete item a via the code under test
  • assert item a is gone
  • assert item b is still there

I thought maybe the whole bit with item b was excessive, but sure enough one day I accidentally fucked something up and deleted all the items, and the test pointed it out before the bad code left my local machine.

BakedGoods , in Unit Tests

Third arm: Every fucking human

Sick and tired of autism gang ™ laying claim to totally normal human behavior just because they have a mental developmental disfigurement.

match ,
@match@pawb.social avatar

too bad, being sick and tired belongs to us now, go feel something else allist 😎

Thcdenton , (edited ) in Unit Tests

<span style="color:#323232;">Z – Zero
</span><span style="color:#323232;">
</span><span style="color:#323232;">O – One
</span><span style="color:#323232;">
</span><span style="color:#323232;">M – Many (or More complex)
</span><span style="color:#323232;">
</span><span style="color:#323232;">B – Boundary Behaviors
</span><span style="color:#323232;">
</span><span style="color:#323232;">I – Interface definition
</span><span style="color:#323232;">
</span><span style="color:#323232;">E – Exercise Exceptional behavior
</span><span style="color:#323232;">
</span><span style="color:#323232;">S – Simple Scenarios, Simple Solutions
</span>
mexicancartel ,

Use triple backticks instead of one if you are trying to get monospace syntax

Thcdenton ,

Bless. Also please dont peel my face off for that mistake :p

mexicancartel ,

Nah just informed you lol

ProgrammingSocks ,

Sorry, the face scalpers are already on their way. Nothing we can do

Thcdenton ,
ornery_chemist , in Not really sure whether S-expressions or Python indentation-based scoping get more hate...

This post made me go try something in clojure again and man I forgot just how fucking good the language is. Everything fits together so nicely.

sajran , in Not really sure whether S-expressions or Python indentation-based scoping get more hate...

So I’m going to say what I always say when people complain about semantic whitespace: Your code should be properly indented anyway. If it’s not, it’s a bad code.

I’m not saying semantic whitespace is superior to brackets or parentheses. It’s clearly not. But it’s not terrible either.

As someone who codes in Python pretty much everyday for years, I NEVER see indentation errors. I didn’t see them back when I started either. Code without indentation is impossible to read for me anyway so it makes zero difference whether the whitespace has semantic meaning or not. It will be there either way.

technom ,

Python decided to use a single convention (semantic whitespace) instead of two separate ones for machine decodeable scoping and manual/visual scoping. That’s part of Python’s design principle. The program should behave exactly like what people expect it to (without strenuous reasoning exercises).

But some people treat it as the original sin. Not surprised though. I’ve seen developers and engineers nurture weird irrational hatred towards all sorts of conventions. It’s like a phobia.

Similar views about yaml. It may not be the most elegant - it had to be the superset of JSON, after all. But Yaml is a semi-configuration language while JSON is a pure serialization language. Try writing a kubernetes manifest or a compose file in pure JSON without whitespace alignment or comments (which pure JSON doesn’t support anyway). Let’s see how pleasant you find it.

Crisps ,

This leads to weird bugs when you change indentation and miss a line or reorder lines. The logic changes. Not too bad when you’re on your own, as Python seems to be intended for. Add multiple developers and git merges and it is a recipe for disaster. With end tags at least you just end up with poorly formatted working code.

sajran ,

It’s probably more prone to mistakes like that, true. But in practice I really never witnessed this actually being a problem. Especially with tests and review.

eluvatar ,

The number of times I move code around and can just press a hotkey to fix indentation though. Not possible with Python.

sajran ,

Yeah, that’s definitely a good point. But it’s a minor thing. Adjusting indentation takes 2 keystrokes in vim, I barely notice it.

coloredgrayscale ,

Most IDEs support automatic code formatting, and doing so on save. Or have it as a github hook.

sajran ,

Of course, but when indentation has a syntactic meaning the formatter often won’t be able to fix it.

lunachocken , in Unit Tests

the autistic overthinking the unit tests

overthinked squared

bitfucker ,

“What if the test fail?”

*Write a test for the test

lunachocken ,

What if the test of the test fails?

Write a test of a test!

loudWaterEnjoyer , in Not really sure whether S-expressions or Python indentation-based scoping get more hate...
@loudWaterEnjoyer@lemmy.dbzer0.com avatar

Everyone that prefers whitespaces over parentheses is an animal.

LeroyJenkins ,

moo

sparkle ,

People who prefer significant white space over bracket & brace blocks and semicolons are animals

nickwitha_k ,

People are animals.

runeko ,
@runeko@programming.dev avatar

Meow.

lengau ,

Yep! Most of us are even homo sapiens!

Thcdenton , in Not really sure whether S-expressions or Python indentation-based scoping get more hate...

I like them both. But I only use lisp for fun.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines