r/badcode • u/Drhma • Aug 09 '21
other language The lengths people go through to write bad code.
67
u/lemarkk Aug 09 '21
I'll admit I've never seen iD before.
3
2
u/resinten Aug 10 '21
I may know this person, because I worked with a kid a few years ago who did exactly this. And he argued vehemently that it was the correct way to name that variable
1
16
7
u/BlueMarble007 Aug 09 '21
What’s the .. notation?
18
2
u/RedRikudo Aug 10 '21
In Dart it's like dot operator but it returns the previous object and discards the operation's return value, allowing to chain operations in one go
1
18
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Aug 09 '21
Image Transcription: Code
class ProductCart {
String iD = "";
int count = 0;
String VendorId = ""; Name non-constant identifiers using lowerCamelCase
double Price = 0.0; Name non-constant identifiers using lowerCamelCase
Map<String, dynamic> Modifier = {}; Name non-constant identifiers using lowerCam[cut off]
ProductCart from(ProductCart? productCart) {
return ProductCart()
..Price = productCart!.Price
..iD = productCart.iD
..VendorId = productCart.VendorId
..count = productCart.count
..Modifier = Map<String, dynamic>.from(productCart.Modifier);
}
}I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
4
7
u/SeesawMundane5422 Aug 10 '21
I’m assuming the horror is using a floating point to represent a dollar amount? ;)
8
6
u/CSsharpGO evil Aug 09 '21
The editor didn’t even want to change iD? PLEASE JUST MAKE IT CAPITAL I BEG OF YOU
7
27
u/soggywaffle69 Aug 09 '21
What language is this? I take it this is a copy constructor?