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 - "polymorphism"
-
Boys use the word FRIENDSHIP to strart the relationship...
Girl use the word FRIENDSHIP to end the relationship...
Real example of Polymorphism...😜😜😜2 -
I guess my best AHHA moment was back when I learned that good code is simple code.
When I started out I wanted to prove myself by showing of how good of a programmer I was(and which I retrospectively wasn't) , which basically meant to use every high level concept I was aware of whenever possible. Multi threading where linear execution would have been totally okay, polymorphism with x meta classes where a switch would have been enough, all that shit.
It wasn't until I had to guide the first person through that mess of useless ego stroking that I found out how much time and money I wasted by not going with the easiest approach that solves the problem.
Took me some time to fully lay off that attitude but it surely was one of the most influential moments of my career.6 -
Once crafted a beautifully executed use of Polymorphism with intuitive interfaces and classes with a concise and loose code just to watch my boss get rid of the interface , because it had no code in it, and fill the fucking code with an ugly switch statement to choose which class to instantiate.5
-
Looks like I'm destined to be fucked in the ass every time I'm on vacation...
This boss : https://devrant.com/rants/1330624/...
Told me he is gonna implement the new backend of a web app we have while I'm on vacation...
He was trying stuff with python for it and I tried to explain him the benefits of polymorphism and the ideas behind it and he was looking clueless, as always...
I'm screwed... Last time I went on vacation they started using react ( no complains ) and firebase ( fuck this shit ) ...
Now we are moving this web app away from firebase but I can see it is gonna be shit and a lot of rants will follow from his "back end" that this motherfucker here is gonna have to help implement after 2 weeks of fucked up code...5 -
As a self taught C programmer starting comp sci in University, WTF is all this object oriented-ness. Constructors, parents, children, inheritance, polymorphism... I feel like more like an anthropologist than a programmer.
(But really, I get why it's better. Just so hard to learn)14 -
I was having dinner with two girls, one a project manager and the other some finance reviewer or something like that. We were discussing our line of work and I was talking about how bad quality code affects everybody and the finance reviewer girl goes like (and I quote) "In our company we use polymorphism, inheritance and encapsulation so it's not a big problem. So our database has a parent class and we only use the parent class". I was at a loss for words. I mean, if only more programmers just did that, right?14
-
Been really busy with things haven’t got around to posting a book in like a week or so..
But I’ll post one today..
This book...
This book, available for free online or you can buy it, written in 1994. But so under appreciated by people for some reason most people never have seen it or know about it. But this is the ONLY book I know of that actually covers this topic.. the only book in existence that specifically goes thru how OOP can be done with C.
NOW hold up before you say just use C++ stop and think for a second.. bear with me.
First off this book is purely for informational purposes and educational use to deepen your understanding of what OOP is actually doing behind the scenes in languages like C++ where keywords exist for these things and you just blindly use them without thinking about under the hood.
This book contains a lot of code and builds you up a complexly library from scratch to make OOP in C... now I don’t take this book literally and this but I have implemented some concepts from this book in projects in the past, and it helps a lot.
Also in my honest opinion If you finish this book, you will be a better C programmer AND c++ programmer, C programming because it teaches you a lot about complex things that you never thought about doing with the language. It proves you can do polymorphism can do inheritance and encapsulation. And it’s not really bloated either.
This books is an awesome book, if you don’t understand C pointers you definitely will after this book.. if you don’t understand OOP in C++ what’s really going on.. you will after this book. After all C++ began as just a preprocessor of C.
Great book for writing reusable, extendable large scale embedded c systems.
Anyway.. rare book of which should not be rare considering it’s free.3 -
Polymorphism (Object Oriented) explained better :
1) Father : Son, go and get Red Label.
Son : Full or Half? ..
2) Mother : Son, go and get Red Label.
Son : 100g or 250g? ..5 -
When reading through someone else's code, what about it made you think "Damn this is well written" or similar?
Any language - I have a bias towards PHP, C++ and C though.9 -
Did your motivation ever suffered for company enforced tooling/stack?
I'm striving to be as adaptable as possible to not bitch if I have to use Angular insted of React or Java instead of Go but the stack which I was forced to use for the last two years is killing the joy I find in programming.
I'm talking about Spring WebFlux a stack which in theory is very promising (IO performances of NodeJS but in Java) but in practice is a pain to use: it makes polymorphism very hard forcing to rewrite tons of code, it significantly reduces your library choice, even after studying a damn book about it debugging remains a huge headache, unit testing often requires hacks and workarounds to be done...
Programming with it always feels like trying to fit a square peg in a round hole and I'm catching myself in procrastinating more and more, initially I feared I was burning out or losing my passion for the field but I noticed which the rare times I get to use a more canonical stack like .NET my motivation instantly returns but sadly I can use it only for few hours and then I return to WebFlux and my passion flees again.
I'm considering to look for another job but sadly lately I neglected my GitHub so I might have hard times in finding it.2 -
"What are the four pillars of OOP?"
Me:(I'm not an OOP guy, but focused on design patterns)
1. Encapsulation
2. Abstraction
3. Polymorphism
4. ??(was it inheritance or composition).
Fuck, Because of the phrase "composition over inheritance". I've been mixing both composition and inheritance at the same time.9 -
Why has web development become so complicated?
I'm learning React with JSX . Why is JSX even necessary? HTML works fine. Its simple and gets the job done.
I can't stand the node_modules directory either. Opening it up reveals what seems like hundreds it not thousands of dependencies that all have their own recursive node_modules folder and the dependencies continue.
Why are we creating more unnecessary abstractions on top of more unnecessary abstractions? What happened to K.I.S.S?
What was wrong with vanilla Javascript and becoming great at that and using just that?28 -
So far in my (albeit short) career, I struggle to find people who know what polymorphism is, and how to use it. SOLID is a big unknown too.
It's always
if(this instanceof A) {}
else if(this instanceof B) {} -
So I am interning at this company, and I am Coding in Go.
Now I don't have much exp with go so I'm learning it, and all of my team is cool cause they also had to learn Go. Anyways I am just petty intern-dev so everyone and everything is cool.
Migrating from python to go is quite hard.
Unlearn, You must.
What I have imagined Go, to be is:
While python has this top down approach to inheritance and polymorphism, Go has bottom up approach.
In Python child classes are derived from parent class but In Go child classes create a parent class. (this might be totally wrong, but that's how I've imagined golang)
Go is static wrt dynamic python.
I have coded in C for 1.5 years then I switched to python, so I feel that am familiar with static typing. The path that lies ahead of me shouldn't be too hard.
I would like to take a step further and say that Golang is C, but with modern syntax/semantics. It derives many of its features from newer langs like js, Python, etc while being a compiled language which translated directly to machine code.
That's all 😊
My team members are really great and supportive, I am about 10 years younger than them but we still connect and sync.
Everything is Great, Life is Good ❤️2 -
TIL: PHP if statements don't have block scope.
I didn't know this, was surprised and thought "well, huh".9 -
me, first job interview:
interviewer: so how about your knowledge of java
me: yeah, done some projects, should be ok
interviewer: what about polymorphism in java, can you tell me sth about it?
me (thinking i'm totally right): hehe, you can't do polymorphism in java!
guess what, didnt get the job :D6 -
I really hate people that don't document well their 'inventions'.
Let's take for example kotlinx.serialization library. It's a self-obvious fact that there are at least two things that will make anyone suffer: generics and polymorphism. So, they must be on the front page. Solved. With a recipe. Ready to use.
And what do we have? One mention somewhere in docs and an amazing test that 'explains' 'everything':
https://github.com/Kotlin/...
'What we got here is a failure to communicate.' (c)8 -
Polymorphism (Object Oriented) explained:
Father: Son, go and get Red Label.
Son: Full or Half?
2) Mother: Son, go and get Red Label.
Son: 100g or 250g? -
>Be me, humble physicist turned quantitative developer
>Big physics nerd, but code for the cash
>Working on some quantitative finance software, all about risk measures
>Girl comes over one day, cute as a quark
>Think to myself, "This is it, time to make a move"
>Instead, brain decides it's time to explain my work
>Start rambling about refactoring, polymorphism, and data encapsulation
>She's looking at me like I've started speaking in binary
>She tries to steer the conversation back to normal stuff, but I'm stuck in a recursion loop
>Keep going on about my project, can't seem to stop myself
>She tries to stay longer, even tries to show interest in my work
>But the more I talk about algorithms and time complexity, the more her eyes glaze over
>Eventually, she gives up, says she has to leave
>She leaves, probably thinks I'm more interested in my code than her
>mfw I realize I've chosen code over companionship
>Why am I like this?10 -
Yesterday I had a questionable pleasure of interviewing a young software engineer who (while answering one of earlier questions) used a principle of polymorphism but made a mistake. So I asked her to explain what polymorphism is.
She couldn't. When she said "let me start from the beginning" for the 3rd time I jestfully noted that if she's more used to virtual communication she can text me the answer, and she not only thought I was being serious but also thought it's a good idea, then texted me a duck emoji, a dog emoji... And got stuck again.
Obviously when we were discussing potential salary she had an answer for every question. Ridiculous answer but no communication issues whatsoever.13 -
Tomorrow I'll have my Java exam. Teacher sent us a code example and I analyzed it, it works correctly but it's full of mistakes about polymorphism. I'm fucking afraid5
-
That moment where you see code of someone who riddles their code with nested if-else and if-elseif statements.
I don't remember writing an else statement for years. It almost always can be avoided (and the rare cases where it makes sense I prefer the switch statement).
Yet I never grasp why people do:
```
if(someCondition) {
// huge nested code block
} else {
throw new Error();
}
```
Instead of
```
if (!someCondition) {
throw new Error();
}
// continue in the normal scope
```
And then we have experts that like doing:
```
if(someCondition) {
if (bar) {
$foo = 'narf';
} else {
$foo = 'poit';
}
// huge code block
if($foo == 'narf') {
if(yetAntherCondition) {
// huge code block
} else {
throw new Error();
}
// huge code block
} else {
throw new Error();
}
} else {
throw new Error();
}
```
Help!
If ever was to design a programming language, I'd forbid the `else` and `elseif` keywords. I have yet to find an instance where I could not replace some `else` by either a guard or an early return or introducing some polymorphism.1 -
When you spend ages making a really nice for loop for handling multiple classes similar functionality, only to have it all messed up by one overloaded method1
-
It just hit me that despite being possibly the most object-heavy language out there, JavaScript actually wasn't even properly object oriented for the longest time. No language-level support for Encapsulation, Inheritance, and without a strict class system, it can never really have polymorphism or abstraction.
Since literally everything is an object, it's impossible to make it object oriented 🤯4 -
Just realized that it’s been a long time since I had to deal with collections that contain values of different types and that ugly type checks that come with it when you need to do something with the values.
Sum types are really a blessing. -
Css positioning is harder to understand than the full OOP concept.
So i wanted to create a very simple page with a single css file. I spent 2 hours to position the buttons in the fixed header and center some things.
I got the whole OOP concept with abstraction, polymorphism and inheritance in an hour and could use it right after without problems.
Holy shtcake i never want to do frontend.8 -
1. When you ask the rationale behind simpler programming concepts. Some are writing they are Java expert(5 star in some interface) and when you ask questions deeper than what is polymorphism.
2. When you ask them to show their work on one of online repositories. I aint taking your word on your msterious projects.5 -
I want to make my own Android app. I have completed Java basics. In Java basics I have completed encapsulation, abstraction, inheritance, polymorphism etc. I have basic knowledge of these all. I cannot switch myself to Android studio because I am not having a good laptop but after one month I will buy a good laptop. So in this one month of time what should I learn which will help me in my Android app development.3
-
Had a lecturer that taught a module on OOP where the entire module was spent teaching how to code on Java while the concept of OOP was just skimmed through at the end of the module. Okay, fine, it's just supposed to introduce OOP, maybe the continuation will go into detail.
The next semester we had the continuation module titled OOP with Java. Entire module was about Javafx. So two semesters later and everyone in the class barely understood things such as polymorphism or abstraction. -
!rant
had to give a short presentation on the origin of OOP at work. It turned into a neat little discussion on what OOP means to you based on your experience and what you've been taught. I had always thought it just meant working in terms of objects and polymorphism, inheritance, etc. were good practices.
Found it interesting that when I started reading into Simula, Smalltalk and Alan Kay's work, early 'uses' of OOP were different from each other and today. To me it seems it have originated obviously, from the desire to work with real world objects but branching off to being more closely related to the actor model and the idea of message passing.
Was wondering if anyone else has looked into this topic or has their own opinions based on experience.1 -
Started out reading "Standard C++ Bible" (~800 pages), who does that anyway? Throughly studied the language and at 14 years of age tried hard even grasping what the word polymorphism meant, realising 10 years later how much it gave me. Immensely grateful that C++ choose to rip my brain apart at that young age.
-
My two main grudges against Typescript:
1) Union types can't be passed as arguments if there is a variant for every element of the union
2) No tuple polymorphism, i.e. [T, U] isn't assignable to [T]. This is not a mistake because the length of the arrays differs and therefore they may be interpreted in a different way, but IMO there should be a tuple type which is actually an array but length is unavailable and it supports polymorphism. This sounds stupid, but since function parameter lists work well with tuples it would actually enable a lot of functional tricks that are currently inaccessible.7 -
Best: The absolute feeling of glee when I finally twigged what polymorphism is!
Worst: spending a fully night working out what polymorphism is....