Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "constructor"
-
Next time I see a constructor with 22 parameters. I'm gonna report whoever wrote that to the police40
-
IOS SUCKS!! SWIFT SUCKS !! OBJECTIVE-C SUCKS!! SUCK MY DICK APPLE YOU PIECE OF SHIT !! Why did you have to make the language sooo counter intuitive, and so different from the popular languages you pain in the ass piece of shit, Why can't I throw exceptions from a constructor of a class?? Why do I have to use a fucking struct to just throw exceptions?? Can't class constructions fail you peice of shit?? huh? GOD DAMN IOS MAGGOT DEVELOPERS IF I EVER RUN INTO THOSE FUCKERS IM GONNA FUCKING RAPE EM BURN THEM ALIVE AND HAVE THEM FOR DINNER68
-
Yes, that's an 18 arguments constructor.. there's 21 other classes and I'm afraid of looking into them.49
-
Researching to making a small 2D game using constructor classes and while building out classes, was working on my Tree method using fractal geometry and made a wallpaper out of the tree 🌳12
-
Update on this: https://devrant.com/rants/1641198/...
I was a little tired but made updated and currently getting a more natural looking tree.26 -
Me: I have an input stream!
Library: I want a file.
Me: I can see your code, you will convert it to an input stream! Don't any of your constructors take an input stream?
Library: No. I want a file. Okay, you can also include an encoding.
Me: I don't care about encoding.
Library: Fine, just give me the file then.
Me: You mean I have to somehow convert my input stream into an actual file so I can give it to you?
Library: You're gradually catching on, yes.
Me: Can I add a new constructor myself that takes an input stream?
Library: Sure! Good luck in getting it approved by the maintainers and the new jar distributed everywhere, including Maven Central before your deadline.
Me: Fine, I'll just rearchitect everything so I can give you an actual file.
Library: And then everything will be fine.
Me:3 -
I wrote a database migration to add a column to a table and populated that column upon record creation.
But the code is so freaking convoluted that it took me four days of clawing my eyes out to manage this.
BUT IT'S FINALLY DONE.
FREAKING YAY.
Why so long, you ask? Just how convoluted could this possibly be? Follow my lead ~
There's an API to create a gift. (Possibly more; I have no bloody clue.)
I needed the mobile dev contractor to tell me which APIs he uses because there are lots of unused ones, and no reasoning to their naming, nor comments telling me what they do.
This API takes the supplied gift params, cherry-picks a few bits of useful data out (by passing both hashes by reference to several methods), replaces a couple of them with lookups / class instances (more pass-by-reference nonsense). After all of this, it logs the resulting (and very different) mess, and happily declares it the original supplied params. Utterly useless for basically everything, and so very wrong.
It then uses this data to call GiftSale#create, which returns an instance of GiftSale (that's actually a Gift; more on that soon).
GiftSale inherits from Gift, and redefines three of its methods.
GiftSale#create performs a lot of validations / data massaging, some by reference, some not. It uses `super` to call Gift#create which actually maps to the constructor Gift#initialize.
Gift#initialize calls Gift#pre_init (passing the data by reference again), which does nothing and returns null. But remember: GiftSale inherits from Gift, meaning GiftSale#pre_init supersedes Gift#pre_init, so that one is called instead. GiftSale#pre_init returns a Stripe charge object upon success, or a Gift (and a log entry containing '500 Internal') upon failure. But this is irrelevant because the return value is never actually used. Pass by reference, remember? I didn't.
We're now back at Gift#initialize, Rails finally creates a Gift object using the args modified [mostly] in-place by all of the above.
Another step back and we're at GiftSale#create again. This method returns either the shiny new Gift object or an error string (???), and the API logic branches on its type. For further confusion: not all of the method's returns are explicit, and those implicit return values are nested three levels deep. (In Ruby, a method will return the last executed line's return value automatically, allowing e.g. `def add(a,b); a+b; end`)
So, to summarize: GiftSale#create jumps back and forth between Gift five times before finally creating a Gift instance, and each jump further modifies the supplied params in-place.
Also. There are no rescue/catch blocks, meaning any issue with any of the above results in a 500. (A real 500, not a fake 500 like last time. A real 500, with tragic consequences.)
If you're having trouble following the above... yep! That's why it took FOUR FREAKING DAYS! I had no tests, no documentation, no already-built way of testing the API, and no idea what data to send it. especially considering it requires data from Stripe. It also requires an active session token + user data, and I likewise had no login API tests, documentation, logging, no idea how to create a user ... fucking hell, it's a mess.)
Also, and quite confusingly:
There's a class for GiftSale, but there's no table for it.
Gift and GiftSale are completely interchangeable except for their #create methods.
So, why does GiftSale exist?
I have no bloody idea.
All it seems to do is make everything far more complicated than it needs to be.
Anyway. My total commit?
Six lines.
IN FOUR FUCKING DAYS!
AHSKJGHALSKHGLKAHDSGJKASGH.7 -
Took me longer than I'd like to admit before I realized why my function always returned zero.
Too quick with the constructor it seemed.6 -
I'm freelancing and there was a guy who needed help with JavaFX. He gave me code only to his view class so I don't steal the rest... It was around 5k lines and it was full of compilation errors because of missing classes. While checking the code I realised something is really wrong with his model classes. So I asked maybe he could send me this one model class that was suspicious. So he did and it was around 10k lines long and had around 200 fields... ALL OF THEM FUCKING STRINGS except 3. You know what the rest of 3 were? 2 Lists of strings and a boolean... It was his "main" model class, he was using it for everything. It had setters for all fields and empty default constructor, so he would just instantiate the object and would set the fields that he wanted to use. Need new functionality? Just add 5more String fields and set them!2
-
Sometimes I feel really bad becouse i am incapable of coding faster.
I saw someone coding a prototype of pong in 5 minutes.
It took me 30 minutes just to make the constructor function of the paddles8 -
Hey op, I have to change the new SingletonPojo() constructor. it's private and I can't access it.
Me:"wha...do whatever you need, I'm busy."
*Some day after, seeing how he's using my Singleton*
...
New SingletonPojo ().getInstance();
...
Good Lord have mercy of us.1 -
Hoozay! I'm now starting to become an adult! (or atleast, that's what they expect of me)
myAge:
.long 19
main:
push rbp
mov rbp, rsp
mov eax, DWORD PTR myAge[rip]
add eax, 1
mov DWORD PTR myAge[rip], eax
mov eax, DWORD PTR myAge[rip]
mov esi, eax
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
mov eax, 0
pop rbp
ret
__static_initialization_and_destruction_0(int, int):
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], edi
mov DWORD PTR [rbp-8], esi
cmp DWORD PTR [rbp-4], 1
jne .L5
cmp DWORD PTR [rbp-8], 65535
jne .L5
mov edi, OFFSET FLAT:_ZStL8__ioinit
call std::ios_base::Init::Init() [complete object constructor]
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:_ZStL8__ioinit
mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev
call __cxa_atexit
.L5:
nop
leave
ret
_GLOBAL__sub_I_myAge:
push rbp
mov rbp, rsp
mov esi, 65535
mov edi, 1
call __static_initialization_and_destruction_0(int, int)
pop rbp
ret12 -
I started programming 7 years ago, but I downloaded my first tutorials on programming in C++ already back in 2000. I had read maybe 4 pieces of literature, didn't understand anything, because it taught things in this order 1, "So, say you want to create a cat?", no I don't. I want to make a useful program.
2, "then you have make a constructor and a destructor", makes sense since that perfectly replicates nature, not,
3, "then you can define a method in the class that enables your cat to meow", eeeh no it doesn't make a sound, what it does however is print a series of characters even less useful than "Hello World" to stdout.
Then I found assembler and it all made sense! 😀 -
Working on a project with 2 other students. One of them makes a C# "super class" with 50 fields, and manually creates getters and setters for each and every one. Then he proceeds to write a constructor that accepts 50 parameters, because why not.
I comment on the git commit, telling him that he can just write " get; set; " in C# and that he should model the problem in smaller, more manageable classes ( this class had 270 lines and did everything from displaying data to calculating stuff). Tried to explain to him that OOP works kind of differently from how he did it.
....
His answer: "Yeah, I don't really care. If it works once, it's okay for me".
This after the most beautiful code review I have ever done...
Fml8 -
While working on my one of the first project in java i ended up using deprecated Calendar API for the date. Since deadline was near i thought it would be a good idea to use the JCalendar API for as date picker (which is a third party API).BAD IDEA. It was the night before the submission round about 11pm when i realized that there is no way to convert JCal object into Calendar and it turned out it is not working as expected you have to subtract a particular number from the year to get date right.
To convert JCal into Calendar i used the toString function to get the date in string sliced it using substring into year,month,day then had to assign date to Calendar object via constructor.
Had to write 70 lines of code just to convert JCal into Calendar...
And then there were other complications related to this problem. Had tu pull an all nighter just to solve date related problems
LESSONS LEARNED :
NEVER USE A DEPRECATED API
NEVER USE THIRD PARTY APIs WITHOUT RESEARCH7 -
Refactored an authentication library a while back and teams are now getting around to updating their nuget packages.
It is a breaking change, but a simple one. The constructor takes a connection string, application name, and user name.
A dev messages me yesterday saying ...
Tom: "I made the required changes, but I'm getting a null reference exception when I try to use the authorization manager"
Odd because the changes have been in production for months in other apps, so I asked him to send me a screen shot of how he was using the class (see attached image below).
Me: "Send me a screenshot of how you are using the class"
<I look at what he sent>
Me: "Do you really not see the problem why it is not working?"
<about 10 minutes later>
Tom: "Do I need to pass a real connection string? The parameter hint didn't say exactly what I should pass."
<not true, but I wasn't going to embarrass him any more>
<5 minutes later>
Tom: "The authorization still isn't working"
Me: "Do you still have 'UserName' instead of the actual user name?"
<few minutes later>
Tom: "Authorization is working perfect, thanks!"
A little while later my manager messages me..
B:"I'm getting reports from managers that developers are having a lot of problems with the changes to the authorization nuget package. Were these changes tested? Can you work with the teams to get these issues resolved as soon as possible? I want this to be your top priority today."
Me: "It was Tom"
B: "Never mind."11 -
PHP arrays.
The built-in array is also an hashmap. Actually, it's always a hashmap, but you can append to it without specifying indexes and PHP will use consecutive integers. Its performance characteristics? Who knows. Oh, and only strings, ints and null are valid keys.
What's the iteration order for arrays if you use them as hashmaps (string keys)? Well, they have their internal order. So it's actually an ordered hashmap that's being called an array. And you can produce an array which has only integer keys starting with 0, but with non-sequential internal (iteration) order.
This array weirdness has some non-trivial implications. `json_encode` (serializes argument to JSON) assumes an array corresponds to a JSON array if its keys are consecutive integers in increasing order starting with 0, otherwise the array becomes a JSON object. `array_filter` (filters arrays/hashmaps using callback predicate) preserves keys, so it will punch holes in the int key sequence if non-last items are removed, thus turning arrays into hashmaps and changing your JSON structure if you forget to discard keys before serialization.
You may wonder how JSON deserialization works, then? There's a special class for deserialized JSON objects, `stdClass`. It's basically a hashmap too, but it's an object, not an array, and all functions that would normally accept arrays won't work with it. So basically its only use is JSON (de)serialization. You can even cast arrays to objects, producing `stdClass`.
Bonus PHP trivia:
Many functions return nonsensical values. `preg_match`, the regex matching function, returns 1 for success, 0 for no matches and false for malformed regular expression. PHP supports exceptions, so it could just throw one on errors. It would even make more sense to return true, false and null for these three cases. But no, 1, 0 and false. And actual matches are returned by output arg.
`array_walk_recursive`, a function supposed to recursively apply callback to each element of an array. That's what docs say. It actually applies it to leafs only. It will also silently accept object instead of array and "walk" it, but without recursing into deeper objects.
Runtime type enforcing is supported for function arguments and returned values. You can use scalar types, classes, array, null and a few special keywords. There's also a `mixed` keyword, which is used in docs and means "anything". It's syntactically valid, the parser will accept it, but it matches no values in runtime. Calling such function will always cause a runtime error.
Strings can be indexed with negative integers. Arrays can't.
ReflectionClass::newInstanceWithoutConstructor: "Creates a new class instance without invoking the constructor". This one needs no commentary.
`array_map` is pretty self-explanatory if you call it with a callback and an array. Or if you provide more arrays of equal length via varargs, callback will be called with more arguments, one from each array. Makes sense so far. Now, you can also call `array_map` with null instead of callback. In that case it treats provided arrays as rows of a matrix and returns that matrix, transposed.5 -
I feel the whole universe is a programmed game and someone is playing us. Like when we're playing GTA.
Few of us are the main characters and the rest of us are just random objects to populate the earth, we don't have any rule in the story. :(
Birth is the Constructor()
Death is the Finalizer()4 -
I get angry every fucking time when I see such method signature:
method(int, int, int, string, string, string, string)
Sounds scary, doesn't it?
Nah. That's the reason our IDEs are so complex. So, I change this and put proper data value/struct class instead, just to make this much readable and understandable for everyone.
And, every time there is a fella that asks this utterly stupid question:
What about performance impact?
Aaaaaaaaaaaaaa fuckyutitititiigig
And. I. Have. To. Run. Performance. Tests.
Because noone understands performance and computers so I have to prove there is nothing to worry about.
I know when I will go somewhere else I will have to again prove some fuckwit that web applications are so complex already, so adding a new data structure doesn't impact its performance.12 -
One of my favourite things in JS is the absolutely cursed shit that it lets me do.
Did you know that you can return anonymous classes from functions?17 -
Well after years of programming, I've hit my first runtime error that provides no info , the code fails prior to being able to generate an error so this is fucking fine :-)
And of course, the one time I need stack overflow, it tells you to initialise the class with data... Yet the class doesn't contain a fucking constructor... Smiley face7 -
Other dev: fuck you, your code can't handle null as input
Me: yeah, because it's kotlin. It's like I added @NotNull, so?...
Other dev: fuck kotlin
Me: fuck you and your nullpointers. Don't pass my precious constructor that crap!2 -
Today I tried to find out why the constructor of my class wasn't called. After 2 hours I found out, that it was named "__constructor" and not "__construct"... I feel so dumb right now. FML2
-
Living in student accomondation :
Me doing whatever on my Laptop (coding, YouTube ...) minding my own business enjoying silence or music or whatever...
EVERY FUCKING TIME I GET TO GET COMFY, MY STUPID FUCKING ROOMMATE DECIDES TO COME IN, LAUGH LIKE A DUMB FUCKING IDIOT AND EITHER STAYS FOR X MINUTES WATCHING OVER MY SHOULDER AND IS EITHER CRITICIZING MY CODING OR STARTS WATCHING THE VIDEO SITTING NEXT TO ME LAUGHING LIKE A DUMB FUCK.
He does that at least 3 times a day, while he should be studying himself(He almost failed all of His CS classes and does not even know how to create a fucking constructor in Java).
MOTHERFUCKER, GO AND LEAVE ME THE FUCK ALONE.
MIND YOUR OWN FUCKING BUSINESS
Had to get that off my Christ :)
PS : told him multiple Times to fuck off. If i go and sit somewhere else (like library or somewhere) dumbfuck just follows me.
FUCK HIS LAUGH, SOMEBODY CUT HIS TOE OFF PLEASE.
Cant even change Apartment as accomondation ist completely full :)3 -
Looks like I'm @dfox evil twin.
class nerd-san extends dfox {
constructor() {
evil = true;
sunglasses = true;
}
}2 -
As I was refactoring a class in a TypeScript project, I changed calls from `this.config` to `this.getConfig()`.
Suddenly, the tests were failing as somehow the live credentials were used from within the test.
Digging deeper I discovered this.
interface Base {
public config;
public getConfig();
}
So far so good. Wondering why config needs to be public, though nothing too shabby, let's look further:
class MyImpl implements Base {
constructor() {
this.config = this.getConfig()
}
getConfig = () => someGlobalVar;
}
┻━┻︵ \(°□°)/ ︵ ┻━┻
Why would you do this? This breaks dependency injection completely.
In the tests, we were of course doing:
testMe = new MyImpl();
testMe.config = testConfig;
So even though you have a getter, you cannot call it safely as the global var would take precedence. It's rather used as a setter within the constructor. WTF.
Sad part is that this pattern is kept throughout the entire codebase. So yeah for consistency!?
(And yes, I found a quick workaround by doing
getConfig = () => this.config || someGlobalVar;
though still, who in their right mind would do something like this?)1 -
To the developer who was kind enough to complicate matters by using Java 8 Time and Joda Time in the same constructor. Please reconsider your life choices
-
delete this;
(in the constructor)
Actual line of code I wrote in my code because of sleep need... Coffe isnt always good, kids... Rather sleep polyphasically2 -
I used to think that I had matured. That I should stop letting my emotions get the better of me. Turns out there's only so much one can bottle up before it snaps.
Allow me to introduce you folks to this wonderful piece of software: PaddleOCR (https://github.com/PaddlePaddle/...). At this time I'll gladly take any free OCR library that isn't Tesseract. I saw the thing, thought: "Heh. 3 lines quick start. Cool.", and the accuracy is decent. I thought it was a treasure trove that I could shill to other people. That was before I found out how shit of a package it is.
First test, I found out that logging is enabled by default. Sure, logging is good. But I was already rocking my own logger, and I wanted it to shut the fuck up about its log because it was noise to the stuffs I actually wanted to log. Could not intercept its logging events, and somehow just importing it set the global logging level from INFO to DEBUG. Maybe it's Python's quirk, who knows. Check the source code, ah, the constructors gaves `show_log` arg to control logging. The fuck? Why? Why not let the user opt into your logs? Why is the logging on by default?
But sure, it's just logging. Surely, no big deal. SURELY, it's got decent documentation that is easily searchable. Oh, oh sweet summer child, there ain't. Docs are just some loosely bundled together Markdowns chucked into /doc. Hey, docs at least. Surely, surely there's something somewhere about all the args to the OCRer constructor somewhere. NOPE! Turns out, all the args, you gotta reference its `--help` switch on the command line. And like all "good" software from academia, unless you're part of academia, it's obtuse as fuck. Fine, fuck it, back to /doc, and it took me 10 minutes of rummaging to find the correct Markdown file that describes the params. And good-fucking-luck to you trying to translate all them command line args into Python constructor params.
"But PTH, you're overreacting!". No, fuck you, I'm not. Guess whose code broke today because of a 4th number version bump. Yes, you are reading correctly: My code broke, because of a 4th number version bump, from 2.6.0.1, to 2.6.0.2, introducing a breaking change. Why? Because apparently, upstream decided to nest the OCR result in another layer. Fuck knows why. They did change the doc. Guess what they didn't do. PROVIDING, A DAMN, RELEASE NOTE. Checked their repo, checked their tags, nothing marking any releases from the 3rd number. All releases goes straight to PyPI, quietly, silently, like a moron. And bless you if you tell me "Well you should have reviewed the docs". If you do that for your project, for all of your dependencies, my condolences.
Could I just fix it? Yes. Without ranting? Yes. But for fuck sake if you're writing software for a wide audience you're kinda expected to be even more sane in your software's structure and release conventions. Not this. And note: The people writing this, aren't random people without coding expertise. But man they feel like they are.5 -
Finally after wondering for hours why the constructor of a class does not get called...i notice that constructor don't fucking accept a return value data type (void)...😡😒8
-
In what fucking programming language a constructor can return a nullable value???
Swift of course. :|
Fuck apple :-)5 -
As someone who didn´t work with dependency injection in almost all projects before:
I legitimately sat here for half an hour and asked myself how to fucking access a new database context...
Me:
You can´t just add that to the constructor.
Dependency Inection:
Yes you can!2 -
Hiii devRanters, I have a TypeScript question for you...
How do I dynamically import classes?
I have a class like this:
export default class Foo implements Bar {
...
....public getName(): string {
........return this.name;
....}
}
and then I have another file with this:
import(`./class-cmd/${file}`).then((command) => {
....winston.debug(command);
....winston.debug(command.getName());
});
the first command spits out something like this:
debug: default=class Foo {
....constructor() {
........this.name = "foo";
....}
....getName() {
........return this.name;
....}
}
and I would expect that the second command will work, however it throws this:
UnhandledPromiseRejectionWarning: TypeError: command.getName is not a function
Any idea what I might be doing wrong?18 -
In PHP, constants can only be of simple data types like strings or floats.
You can't make a database connection a constant because it's not a simple data type.
That makes the only way of accessing complex "constants" within functions using the keyword global... which is not encouraged and forces you to make the database connection global (that may not be convenient in some software patterns).
The last option is passing the database connection as a parameter (either to the function or to the constructor of the instance whose methods will use the connection)... which would be good if I didn't want to go full OO. Because it's a pain to do so.
So all in all, constants are not well supported by PHP.
Come on, constants...12 -
other dev changed constructor from
public A(String val){
this.val = val;
}
to
public A(String val){
this.setVal(val);
}
this feels bad in many ways, but need some arguments to convince him that its wrong11 -
everything was going great, I was loving it,
then self happens
why should one pass self (current object refrance) to the constructor in python , why doesn't this keyword exist in python.
coming from java I always forget to add it.
just WHY?????9 -
senior: we have no reason to change/mutate this property, we don't need a setter method, just set it once in the constructor
also senior: there's no reason to change/mutate this value, but i want you to write a setter method for it3 -
JSrant
Is there no other uglier way to create a constructor in JavaScript apart from using parameters for the properties?
Some of my entity has like a dozen properties (+_+)12 -
A quick rant about dependency injection.
I see far too often in projects, a huge over-reliance on dependency injection / IOC frameworks which permeate throughout the entire codebase.
I cringe every time I see a constructor annotated with @Inject and 10 params.
The benefit of these frameworks is how easy they make it to manage many dependencies. What I dislike about them, is exactly that. I feel that they make it TOO easy to manage many dependencies.
How trivial is it to simply add another constructor param? exactly. And people then wonder why their dependency tree looks insane.
I am a strong believer in injecting dependencies the traditional way, via the constructor with no fancy framework. The reason being that it forces you to think more about the dependencies you are adding to your classes, and consider if they are really all needed.
The other problem I have with it, is it basically encourages you to inject everything because its so easy. The purpose of dependency injection is inversion of control and allowing classes to depend on abstraction rather than concrete implementation. All that goes out the window when you @Inject 6 different concrete classes.
Use dependency injection for its intended purpose, not as an excuse to be lazy and avoid thinking about dependencies.3 -
From long Using Visual Studio Code for Programming.
Why i love
supports Typescript
supports java
Lighter
plugins available like linter, git lense
Best for small web app projects.
And Favourite IDE, intellij Idea
Why ?
For writing java i use as
it can easily generate getter setters
constructor
importing
and build process.
best for java.
last but not the least
Nano
why ?
because most of the devops configuration, requires to be done via terminal only and i often use nano.
it is good for shell scripting,
editing configurations
that is all....2 -
Never have I felt more like a pirate than when I wrote a copy constructor for a class called "Args".1
-
Looking at an old Java project, running java 1.6, test folder doesn't even exist and the "old but gold" java.utils.Date class is used throughout the whole thing. How do I initialise a new date again...? I actually just googled that :D At least the constructor parameters are named nicely... wait.. what...1
-
When you see "use strict"; in a JS file, and then see "window.chart = this;" as the first line of the constructor.
-
if you want to encounter 400 lb angry virgin programmers go on r/Python and suggest they should add a static keyword to their classes.
They swarm out of the woodwork and take turns trolling you until a mod bans you for responding in suit.
Its amazing, the dumbest lack of language feature and they're like
'me no want the extra keystroke me like code that can lose peopel, me fo fucks no never, not gonna happen, you asshat, haha, now go bye now, *click*'
valid argument is python classes are lacking in decoration
this i suppose is ok overall, i mean they work. except the issue i was having the other day resulted from a variable not being DOUBLE DECLARED IN BOTH THE CLASS SCOPE AND INSIDE THE CONSTRUCTOR LIKE IT WAS A JS OBJECT BEING INTERPRETED AS A STATIC FIELD !
ADDITIONALLY IF THEY LIKE CONCISE WHY THE FUCK DO ALL THEIR CLASS METHODS REQUIRE YOU TO INCLUDE ===>SELF<== !!!!
BUT NOOOO TRY TO COMPARE SOMETHING SENSIBLE LIKE
MYINSTANCE.HI SHOULD NOT BE STATIC
MYCLASS.HI SHOULD BE STATIC AND THEY GET ALL PISSED
ONE ACTUALLY ACTED REJECTED FOR THE SAKE OF HIS LANGUAGE SAYING 'YOU WANT WHAT PYTHON HAS BUT YOU DON'T WANT PYTHON !'
...
...
...
I DIDN'T KNOW THEY MADE VIRGINS THAT BIG!40 -
F*ck JavaFX. I mean, how a GUI framework doesn't have a standart navigation procedure? It is not even possible to create a page by constructor. In many other framework when I wanted to pass a data to a page, I just had to write
"new MyPage(SomeClass someObject)"
but in javafx I have to first create a constructor, link the fxml file to it then show the page.
Actually I am not angry. It is a big mistake to wait a good GUI framework from a company that has a website something like that in 2018.1 -
Sitting here scrolling my timeline seeing my friends and family getting engaged, getting their degrees, getting new jobs, talking about #addictedtosuccess and all that. Meanwhile I'm just here like "Should I use a constructor or a static method for this?" 🤷🏽♂️3
-
!rant
Loving the the fact that constructors in Swift (initializers) can fail (returning null/nil) and be async.
In C# there is no other way than using static methods instead.8 -
It would have to be variable names for classes. I mainly use C#, but I'm sure this applies to other languages. You need a name for the instance variables, the parameters for the constructor, and properties.
-
Not a rant, just the completion of a very demanding and interesting task for this week.
Wrote a whole data scheme for this enterprise app my company is developing. Very proud of it, since it has a very restricted size, multiple layers of encryption and data verification, several user types with different requirements, and it all has to be rock solid in an offline environment.
The punchile is...I enjoyed writing the documentation for the whole package more than I should, I guess...spent the whole day being very thorough and documenting every member, function, constructor and exception.
Feelin fabulous. -
Other peoples' code... (in C++)
I am finding what some people consider good code is not as described. I found a class that provides strings. Great it gives me paths and stuff. I incorporated it in a new project.
segfaults
Hmmm, it must have an init function... It does, but not in the class. It has a friended init function:
friend init_function(). If this function is not created and called external to the class then the class will segfault...
okay...
I implement this. I use code from another project that implements this correctly. The friend class allows the private constructor to be called to create the main instance of the class. So its a fucking cryptic ass singleton. I look at this class. It uses a macro to decide what to function call in the class. The class already has function names for each call it needs to make. The class is literally a string lookup table. I vow to redo this shitty code, someday...
I start to wonder what other fragile code I will find. Not long later I keep getting errors on malloc. Like any malloc that is called results in a segfault. The malloc is not at fault though. I run valgrind and find a websocket library is returning an object a different size than the header file describes.
WTF...
Somebody has left an old ass highly modified definition of the websocket header in a location in that I include headers (partly my fault). I eliminate that from my include path. All is well, everything behaves. I will be making sure this fucking header is not used and it is going to die. Wasted a bunch of time.
Lessons learned: some code is just fucked and don't leave old ass shit you tried laying around.5 -
- The golden rule of CoffeeScript is: "It's just JavaScript".
- Nice!
- And provides a basic class structure that allows you to name your class, set the superclass, assign prototypal properties, and define the constructor, in a single assignable expression.
- No nO NO NO! -
Today my boss sent me something that smelled fishy to me. While he was trying to simulate Excel's rounding he faced what was to him unexpected behaviour and he claimed that one constructor of the BigDecimal class was "wrong".
It took me a moment why this was happening to him and I identified two issues in his code.
I found one fo the issues funny and I would like to present you a challenge. Can you find a number that disproves his claim?
It's Java if anyone was wondering.
double d = 102.15250;
BigDecimal db = new BigDecimal(d)
.setScale(3, BigDecimal.ROUND_HALF_EVEN);
BigDecimal db2 = new BigDecimal(String.format("%f",d))
.setScale(3, BigDecimal.ROUND_HALF_EVEN);
BigDecimal db3 = BigDecimal.valueOf(d)
.setScale(3, BigDecimal.ROUND_HALF_EVEN);
System.out.println(db); // WRONG! 102.153
System.out.println(db2); // RIGHT! 102.152
System.out.println(db3); // RIGHT! 102.152
P.s. of course the code itself is just a simple check, it's not how he usually writes code.
P.p.s. it's all about the numerical representation types.8 -
Hi people first as you know my English is not very poor im sorry for that.
I try to make an automat a sprinkle water and a auto light on a interior garden in aquarium.
For that in python i use main thread, a class Water.py extends Threading and Light.py extends Threading
In the __init__.py file i put my main function that get argv for execution. One of my arguments is -v (--verbose)
I want to pass that args to my class instances.
-I don't want to make one parameter in my constructors because I think we don't passe verbose mode in parameter of constructor.
-I use global not working through de import.
Do you have some magic for me :/ ?6 -
Omg I loath path separators. Been working on windows most of the time (bought a surface pro for some reason) and my colleagues work on Linux. We just do standard web dev stuff nothing special but. I started having issues with my windows build getting weird function.prototype.bind.apply is not a constructor issue. Which is valid because apparently my colleagues started using the fat arrow function everywhere and on places where not needed.......
But on Linux they never had an issue because babel fixed it to the old function during the transpileee. So why the fuck am I getting this problem. After some tedious debugging and asking my colleagues. (colleagues only responded with just use Linux) I found the the issue to lie in the webpack loader for the Javascript in which the path regex used a single / :(. So I changed that to a group to be / or // and bam the whole bloody project works on windows now.
....... My colleagues still don't understand that they over use the fat arrow in the wrong places unfortunately3 -
TL;DR - I came up with an ingenious version of a solution to a problem and still got 0 marks.
In my bachelor's degree we learned about abstraction, as usual for CS degree students.
In a later exam, a coding question asked us to swap two variables values without using a third variable and print the before and after on the screen.
You can read the question above again, because wait for it....
So this is what I wrote basically (JS equivalent solution),
class Solution {
constructor(obj) {
this.var1 = obj.var1;
this.var2 = obj.var2;
}
swap() {
return {"var1": this.var2, "var2": this.var1};
}
}
let input = {"var1":5, "var2": 7}
let object = new Solution(input);
console.log('Before');
console.log(input);
let solution = object.swap();
console.log('After');
console.log(solution);
Now look, before your boomer asses jump in and say "aCkChUaLlY tHiS iS iNcORrEcT"
I did include all kinds of comments that this is abstracted. The swap function is hidden away and the object variable doesn't need to know what it's doing.
In the context of this question, this is absolutely acceptable as a solution since the end-goal is to print the results on the screen and the user wouldn't see the source code.
I still got 0 on that question and I still get pissed about it sometimes, when I remember it, like just now.16 -
My colleagues want to forbid the usage of the shorthand constructor in TypeScript.
I feel strongly about this.
At least they find it annoying that I call the more verbose one "PHP-style constructor" :D -
Teacher: Constructor will be automatically invoked when the object of the class is created.
Rayver : hahaha Its like calling my GF to cantine and her bestie getting an automatic invitationn4 -
Just discovered another reason to hate React. If you are want a form field and you want to read it's value, and you actually want to be able to edit it, then you have to setup onChange, onSubmit, and you have to bind them in the constructor...just to do this one simple fucking thing. If this were Vue.js or Angular.js...binding is super stupid fucking easy. But React turns it into a 5 step process.
-
Once wrote a function that set the controller vibration to 5% of its max in a constructor in the middle of nowhere. It was enough to notice if you were paying attention and feeling for it, but not enough to think that the controller was vibrating. Still there as of last week
-
Perfect use of DI in .NET Core project.
> Passed logger object in UI project's controller class constructor.
> Then pass it to internal class.
> Then pass it to business project.
> Then pass it to another class and finally used logger in a method to log exceptions in try-catch1 -
OOP is so ass, classes that extend classes that need objects, of classes that extend classes , passend to their constructor which constructs an object to be given to a constructor of a class that extends a class that implements three interfaces. And in the end it all could have been done with a single function and all of these classes get used a single time.19
-
What's the fuckin point when a language makes you call the constructor of a parent class in the child class before you can use the inherited items?
Why do I need to call `super()` every time in my constructors? Why can't this be automatic?7 -
I wanted to create my own Minecraft Beta 1.4 Mod and failed, this constructor stuff was to complicated for me.
So I went to the University to learn Java and ended up by learning it myself, with a lot of help form other students who are way smarter than I am. -
I once had to implement a program to process CSV files. One line would be one order, so I wrote a class with a static factory method (Java) instead of an ordinary constructor, because I needed to throw exceptions if something with the line was wrong (which now and then was the case: invalid product IDs, missing fields and the like). After I committed my changes (CVS was still common in those days), a coworker (let's call him Max) asked me what the hell I was doing there. He expected me to replace the code (perfectly working, by the way) with either an ordinary constructor or by implementing "the factory pattern properly". His rationale: "We don't have those kinds of things in our code base!" So I let him argue a bit, not finding any well substantiated reason for me to "fix" the code. So Max wanted to team up with another developer in our office (let's call him Rick), explained the "issue" to him. I just sat there and enjoyed, knowing that Rick would not really care. But as soon as Rick understood what I did, he walked over to the book shelf, picked "Effective Java" from it, opened the book at chapter 1 and said to Max: "Look, Josh Bloch suggests doing it exactly that way for the problem at hand!" Max kept on arguing for a while, because his "rationale" (see above) was not affected by the fact that the code was actually good. It just didn't appear in our code base before.
-
Once I helped one of my friends writing a coding project for an interview for him.
We worked out a solution in C++. I showed him all the class hierarchies, how the flow worked and so on.
The day after he told me he re-wrote it in C# as he was more confident with it. Fair enough.
He changed most of the names using camel + underscore notation, sometimes starting with a capital letter, sometimes not!
But the best (or, rather, worst) was to convert the class hierarchy in a big class with all stuff in it, called "CMother". That got me. This class had a couple of static methods that took a lot (if not all) inputs that somehow coincided with the member variables of another class and did some work with them (like a constructor of that class would do).
Needless to say, he didn't got the job -
God DAMN IT!!!!
I swear, every single time I get close to a Spring project I'm elbows deep in shit.
Like this case... I have to explicitly specify @DependsOn for my @Component, so Spring could autowire constructor parameters. If I don't, sometimes the app starts fine (if I start it through IDE) and sometimes it fails, saying bean could not be created (apparently, there's some functionality gap causing PostProcessors not to be called if the bean is first touched by a constructor autowirer)
when they say frameworks are good and fast, I say "LOOK AT MY LIFETIME SPENT WORKAROUNDING THEIR ERRORS!!!" -
So I know this sounds crazy, but I'm writing a GUI in Python to automatically generate HTML for me. I may add support for CSS, but I'm not sure yet. Anyways, I was trying to replace an object's dictionary with a dictionary I was building in the GUI class. I was trying to replace the dictionary or reference it some way, when I have a place in the element's constructor to handle this exact situation.... I just had to put the temporary dictionary into the constructor.2
-
I asked a new coworker to implement an interface that included an event.
He proceeded to write the implementation and subscribe to the event in the constructor...
When asked why.. he responded with we should know when the event fires.2 -
Prototyping is making me feel more and more like an idiot. Thing ain't drawing correctly? It's because a month ago I had a copy paste error and I was doing am unnecessary conversion. Thing is crashing because of file access errors? The 3rd party shared file reader I was trying to use but didn't need opens streams in the constructor and didn't close them in a destructor/finalizer.
-
Programmer: Type type(2);
C++ Compiler: // Okay, I'll use the constructor that takes 1 argument
Programmer: Type type();
C++ Compiler: // I see there is a constructor that takes no arguments, but surely you don't want that. Everybody loves functions, a function shall be declared!
Who, in their right mind, thought this syntax is a good idea?! Syntax inconsistencies drive me crazy...11 -
C# styling question: in a constructor do you prefer:
public MyClass(int MyVariable) {
this.MyVariable = MyVariable;
}
or
public MyClass(int _MyVariable) {
MyVariable = _MyVariable;
}
?22 -
At my first job as a dev, after about 2-3 weeks in, my team got a new member. Him and I were the only devs in that team. Supposedly he had 1 year professional experience of C++. After about a week I started noticing he was slow, he also wrote down basically everything I said, if I said I needed a bathroom break he almost wrote that down too.
During a break he asked me; what's a constructor?
Needless to say I was doing both his and my job for 6-7 months before someone else realized he was useless and removed him. Since I was new I didn't know how to react, do I tell anyone? :-/
On the bright side, I learned a lot and we still delivered well before the deadline.1 -
Here's a story about why putting util functionality in a generic parent class is baaaad. So we run into a bug where an online shop module we develop causes a third party module to break the entire site until the session expires.
We track the bug down to the fact that the third party module has added some functionality to the part of the shop that deals with the cart and that functionality expects that one of the module's libraries is initialized. But as it turns out another of that module's libraries that is loaded earlier is fetching the cart and thus triggers our module which adds gifts to it.
Now, since we need a deeper integration with the cart to make gifts depend on the cart contents we call the part of it that now depends on the third party module's unloaded library.. So we think changing the order the third party libraries are loaded will fix the issue, only to discover the unloaded one is a child class of the first and the cart is fetched in the parent constructor. The parent of course then turns out to be a generic util class, inherited by all the module's libraries, so whatever order we load them in, the constructor is always called, so we had no other choice but to dynamically disable our module during the initialization of those libraries and then patch the updated cart contents into them after they've all been initialized.
At this point we get curious what that module's doing with the cart contents only to discover.. nothing. It's just that the parent class is full of utils and data fetching that the vendor reuses in all their modules.. -
Fucking Fluent NHibernate with it's stupid fucking explicit empty constructors. WHY? JUST FUCKING USE THE DEFAULT CONSTRUCTOR YOU MONG LIBRARY!!! And also, why the holy fuck do my field setters need to be PROTECTED INSTEAD OF PRIVATE??? WHY THE FUCK?
-
Currently being a TA for the software development course in my college, spent an hour on a stupid student for explaining what is a constructor.
-
Background: We switched from just simple old PHP and JS using notepad++ to PHPStorm and its infinite configurables, Symfony 4, Twig, Composer, Doctrine, Yarn, NPM, Bootstrap, ( thank the stars we didn't try to add Docker in with all this ), any other junk I'm missing here? Then upgraded to Symfony 5.
Symfony's autowiring: madness behind the curtains. I get frustrated about when and where I can just magically inject these dependencies or use config variables, you know, like the ones you define in service.yaml. Hmmm, "service".yaml. In a controller you can say getParameter() but in a service you have to inject the parameter, FROM THE "SERVICE".yaml!!! Autowiring drives me nuts. Ok, so we can supply dependencies using the constructor, that's great! Within a controller you never have to instantiate the object you're passing to the constructor (autowiring handles that). That's cool, weird when we you try to trace it for the first few times, but nice I guess. Feels like half-assin' it. What bugs me here is that it only works in controllers... I guess out of the box.. i'm not even sure. To get that feature to work for services you have to make some yaml edits. Right?Maybe? Some of the Symfony tutorials have you code up some junk then trash it. Change config then wipe that out and do X instead... so I have no idea what "out of the box" for Symfony really is.
Found this cool article that describes my frustrations in better terms and seems like a good resource to learn about autowiring. I need to continue my yaml wizardry classes. https://alanstorm.com/symfony-autow...
.....And on to YAMLs, or CSS, or JS or any other friggin' change you make to a file anywhere... Make a change, reload page, nothing... nope you have to do some hidden cheat combo of yarn dostuff -> cache:clear -> cache:warmup -> cache:cache:the:cache ... I really really hate this crap. Maybe I'm too old school for all this junk. It was simple with pure PHP. Edit code, push file, reload page, and oh look it changed! Done. So happy! Ok, Ok. Occasionally the js or css might get cached by the browser and you have to ctrl/f5 or Shift/f5 .. one of those. With this framework there's just so much more that you have to remember to do get some new feature of your site loaded.
Now, I totally get wanting to use some type of entity framework, but I feel like my entire world turned backwards. Designing tables using something like MySQL Workbench made sense. I can see all the columns and datatypes right there as i'm building them. From what I've experienced now with Symfony/Doctrine is you have to make and entity, get a shit-ton of question lobbed at you and if it's a relation field you have to really have a clear idea of the cardinality up front. Then we migrate that to the database. Carefully read through the SQL if you really really just want to use migrations:migrate in Prod. That alter table could cost you some some downtime if your table is large.
Some days man.... -
When the team you inherit the project off of can't even be bothered to add a parameter to their constructor. Instead they expect you to pass it in as part of a title string :')2
-
I have become very fond of React, but the pushback I've experienced when suggesting typescript is crazy.
I think this is the reason why so many enterprise apps are written in Angular. Type safety isn’t a crutch, it's a tool. Plus, interfaces are a dev time construct, and will not bloat the codebase since it doesn’t transpile into js.
But Ts also gives us a lot of other goodies that allow for cleaner design patterns and a better adoption of oop principals.
Also, generics/constructor types, whatever you wanna call it, are your friends. An Array<SomeEntity> or SomeEntity[] will give you peace of mind I’m so many scenarios.
Anyway, I have bitched enough.
Rant over.
Have a wonderful Christmas, everyone.
Ps. This isn’t aimed at anyone in particular, but a the react community as a collective. :)3 -
I love you as strong as the ide loves the code
I feel you are part of me ... like a method is part of the class... without you i will be just an interface... i feel comfortable passing my private variables into you ...
You are my implementation and constructor
The link between us is like the link between
The bug and the exception
You had me when you hit run -
*Python:*
```
d = json.loads(str)
d['foo'] = bar
json.dumps(d)
```
*Scala:*
```
Caused by: TimerException{org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `scala.collection.immutable.Map` (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [Source: UNKNOWN; line: 1, column: 1]}
... 15 more
```2 -
Todays website fail:
Notice: The called constructor method for WP_Widget in FollowMeWidget is deprecated since version 4.3.0! Use
__construct()
instead. in /home/vapingst/public_html/wp-includes/functions.php on line 3893
Notice: The called constructor method for WP_Widget in FooterContactUsWidget is deprecated since version 4.3.0! Use
__construct()
instead. in /home/vapingst/public_html/wp-includes/functions.php on line 3893 -
Today I found a faulty design choice in java, that seriously makes me hate java. Basically java prohibits abstract static methods. This -combined with the poor design choices for constructors - means that Subclasses cannot have a common constructor or static method calling the constructor.
Basically meaning that you can't just map a collection to objects without handling EVERY FUCKING CASE, WRITING THE WHOLE MAPPING AGAIN AND AGAIN, ADDING A FORCED PORTION OF SPAGHETTI WITH EVERY CLASS WHERE THIS WAS NEEDED.
https://stackoverflow.com/questions...
There seem to be other OOP languages with this faulty design. Can't say if I now hate OOP ingeneral or not, because maybe some languages may have provided a substitute for this6 -
Either I am dumb or the usage of p5.js functions makes it either hard or impossible to test with jest. Constructor properties are thrown away (which I need) and all methods are mocked, if I automock, or I've got the pleasure to mock everything inside the class. Otherwise of course jest complains that p5's color() isn't defined. And mocking everything manually is not safe in case of class changes.
Of course p5's tdd tutorial isn't helping, as it seems to mock everything.
I need like a pro/mentor or smth for this... -
I been teaching someone python for a few day with 2-3 hour each day. It has been very pleasant to teach him programming since he have a goal in mind. He already know what kind of program we wanted to build.
He is a novice and not familiar with programming. It have been a good chance to see how the novice look at the python. I been given a chance to ask the answer like
"Why do we throw exception?" ,
"Why do we put define function at the top of the file and not at __main__?"
"Why do I need to use constructor?" ,
"Why should I call parent constructor in the child constructor?"
Here is the main question.
I have been wondering "should I teach him multi inheritance and the diamond problem?" I haven't been using multi inheritance for a while other than the exercise I done when I started programming and cannot think of the situation to use multi inheritance. I know in other language we use multi inheritance (kind of) regularly by extending multiple interface. I wanted to ask if multi inheritance is common in python.
Another question I have is how should I introduce him to gui programming in a simple manner? I am thinking of introduction him to the gui framework which haved WYSIWYG editor like "Remi"10 -
So here the function that does same thing as new operator in javascript:
// we define our function Person that assigns properties to THIS that points to some object
const Person = function(name, lastName) {
this.name = name;
this.lastName = lastName;
}
// in Person prototype property we define our functions
Person.prototype.getName = function() {
return this.name;
}
Person.prototype.getLastName = function() {
return this.lastName;
}
// function that simulates new operator
// first argument is a function that would act as constructor
// second argument is an arguments that would be passed to constructor
function New(func, ...args) {
// with Object.create() we create a new object and assign [[__proto__]] from "func" prototype property
let object = Object.create(func.prototype);
// here we're calling "func" with THIS pointing to object
func.apply(object, args);
// then we return it
return object;
}
let person = New(Person, "Name", "LastName");
console.dir(person);
// so this is how prototype OOP works in javascript6 -
We have this C# class which is like the core of our entire business logic. If you are in another class and it doesn't contain an argument in the constructor and/or property of that core class you're gonna have a bad time.
That core class has lots of useful business logic bools, "IsSomething", "HasSomething" etc. However that core class has a parameterless constructor which is sprinkled dangerously throughout our app, meaning the object is often not initialised properly and it's a 2 day mindfuck to make sure your "IsSomething" bool is actually false and not just false because the other business logic that bool relies on wasn't initialised and the bool has never had a chance to be true.
It's difficult to trust even a simple "if' statement. And if you're somewhere were you've had a list of that core class passed in, you need to trace how the list was initialised to make sure all your bools have been set 😴4 -
When you work on a project for months, the newly appointed tech lead says "we all (him, the boss and other colleagues not involved in this project) looked at your code and decided that it should be dropped and we are starting from scratch again....now I'm not against code review (which we never did) so I welcome the input but allow me to vent my frustrations about how this is being done. Also to have a review & verdict without me being present?
So I ask what was so wrong:
* You changed the database structure. Valid, I tried to make your db an actual db with relationships, so I added some foreign keys, delete fields that were never used, all because they told me to use an ORM.
* You used to much logic in setters, validation etc, valid again but this would be something we could look at and fix imho.
* You are passing classes in your constructor, valid I wanted to use DI to make unit testing possible. Ohh but I don't like unit testing so I don't see the point and it makes it to complicated was the response.
So not only was the project cancelled, the new iteration is being developed without me, I'm shunned from all meetings. Ohh and from what I see they are now using 5 tables instead of 25 and completely started the db model from scratch...5 -
Some of the rants that I’ve read recently have inspired me to write this one:
You know how some OOP based APIs require you to call the base implementation of an overridden method?
If you think about it, its pretty shit. None of the languages have mechanisms to enforce it, so all you can do is to rely on the caller to read the docs for that method that he is overwriting and then do the right thing.
And then you can also have the requirement that the base implementation should be called at the start or at the end of that method.
I really think that this is an OOP problem because if I would have to design it, I’d make a function that takes a closure as a parameter and then call that closure at the start or at the end of that "base" code. This is implicitly documented (by naming the closure appropriately so that the caller knows if it is called at start or end). And it is impossible to miss it because you need to pass something to that parameter. (Alternatively, you could also pass the closure to the constructor).7 -
So I'm new to NestJS, Node, etc. and I just noticed that the guy working on the API made every request call a different service class, instead of using a single service class. For example.
get() {
return await this.getObj.run()
}
post(myDto){
return await this.storeObj.run()
}
update(myDtoUpdate){
return await this.updateObj.run()
}
And I'm not sure why. He's also injecting the request into those classes, instead of passing the DTO to the method call. I mean, it's still injecting the data into it I guess, but it seems so roundabout. Something like this:
public constructor(
@Inject(REQUEST) private request: Request,
){}
I'm scared, but I'm not sure if it's just my own ignorance or a sixth sense telling me that this is gonna be a mess.
Have you seen APIs implemented this way? I can see the benefit of dividing the code into smaller classes, but it just seems overkill to me, specially when there's a big chance that code will be repeated (getting an entity by ID when updating it, for example).
I'm still in time to kill this with fire before a new monster is born though, so that's something.1 -
I've recently had an exam, a C++ exam that was about sorting, pointers, etc... The usual. The exam was about Huffman's
optimization algorithm along with some pointer problems. He asked for a function to find something in a stack, what I did was write down a class that has a constructor, deconstructor, SetSize(), Add(), Remove(), Lenght(), etc.. He didn't give me any points for that, why? Because I didn't write down everything like in his book... I had classmates that literally had phones open with his book, he just watched how they copied code and gave them 10/10 points. But nothing to the guy that wrote down 20 pages of code. YES!! On paper, an IT university that asks you to program on a fucking paper. Good thing that at the very least I passed.
TL;DR
Teacher has book, I refuse to remember code from it/copy from it, I get lower grades than people that literally copied word for word.
Life is really fair. -
Learning Flutter since I've seen it suggested somewhere on here, and therefore I'm having to learn Dart. It just bugs me how it doesn't complain when I leave an extra comma at the end of the constructor parameters3
-
My new favourite RUNTIME c# error, evidently thrown by the standard library because the string is not present in the project:
"no parameterless constructor defined for this object"6 -
Hi, so currently I am developing a program in Java that requires a few enums (I'm new to them and so far they are pretty awesome) and currently I want to create an enum that requires a single field, an instance of another enum. So in the first enum's constructor, I'm setting all the parameters into a new instance of the second enum, however, I'm getting "Enum1 has private access in Enum2!".
I'm off for the day but rq I just wanted to ask if anyone could help me with this. I'll be back in a few hours!1 -
i always get sucked into this "cute code" hell whenever i am working with a b2c codebase, and especially with kotlin code.
here's a scenario:
task : build a debounce logic for an input view where each user input is currently triggerring an api call.
my steps
1. read what debouncing is.
2. see if any code is available on the internet
=> found a code piece on the internet with some level of abstraction ( basically a simple final class that implements the input event callback and encapsulates the debounce logic)
3) copy it, run it , it wokrs
------
for any sane coder, these steps are hardly 10-30 mins and they can move on with life. but its your truly that made this task into a 6hour research only to come up at similar solution. my curiosity led me to stupid places
1) why this class is final? what if someone else wanna use it but with a different behaviour? lets try open(non final class) .
2) why even use a class? it extends an interface, lets try to wrap the logic in interface itself (kotlin supports interfaces that don't require implementation)
3) umm , the interface works but it looks ugly, with all its global overridden variables. what about we make it extension?
4) yeah the extension approach is also not very good, lets go back to open class.
5) but extend is super nice to look! lets keep the extension and open class too
6) can we optimise the implementation? why it uses an additional handler? what if we provided everything in constructor? how about builder pattern?
FUCK MY BRAIN! there are so much fucking options that i forgot that i spent 4 hours on this small thing
the simplest approach would have been tk just shove all the listeners and everything in activity and forget about it :/
senior devs on this platform, how do you stop yourself from adding every concept that you know into the smallest possible task?6 -
I have a readonly object property foo on a typescript class. When I create an instance bar by calling the constructor, bar.foo doesn't compare equal to this.foo as seen from within bar several async calls later. What could I have possibly fucked up?4
-
There is a new Java library very useful for building frameworks and in this library there is a particular classpath scan engine that deserves attention as it is original and powerful.
The peculiarity of this engine is the possibility to search classes over a path or the runtime classpath by concatenable and nestable criteria by exploiting the power of the lambda expressions on the native Java reflection elements such Class, Field, Method, Constructor, Module, Package, Annotation, etc ... thus giving the possibility therefore to carry out searches without limits and for any criterion that can be immaginated: this library is called Burningwave Core, it is open source and on the official wiki on github there are a lot of examples.5 -
I want to run a simulation like rolling a dice N times and find out what's the distribution/probability of getting certain SUMs after the rolls.
However the dice is more likely to land on a lower number, and/or depends on what the number it landed on previously.
Stats wise I think ideally I want to be able to just input the avg, standard deviation, and skewness into a Random class constructor, and then ask it for N "random" numbers.6