Why OOP is so confusing?[Solved] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Why OOP is so confusing?[Solved]

I have seen OOP in many major languages like python and Java but it seems vary confusing to me . Can any one help me with that? Thanks in advance

27th Sep 2020, 4:57 AM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
44 Answers
+ 9
Try a bunch of OOP courses on DataCamp, Coursera or right here. Multiple tutorials are on the Play Store as well.
27th Sep 2020, 6:13 PM
Bohdan
Bohdan - avatar
+ 9
You do not have to use classes - just go functional programming and do your best as, perchance, OOP is not for you. Try to get on with Machine Learning and Data Science then.
28th Sep 2020, 4:21 AM
Bohdan
Bohdan - avatar
+ 9
Ore Nice run through of the high level talking points for class based and prototypal based inheritance / OOP. \•/ It's always nice to meet a fellow veteran programmer here who has also been working with Java since it was released - or shortly thereafter. 👌 jack I completely agree that, in C#, pretty much everything is an object. Even the equivalent of Java primitive types are actually value types in C#, which inherit from System.Object like everything else in the CLR. C# also supports delegates, which is basically the class equivalent for defining function types. Kotlin is the closest to C# of the statically typed languages in these regards. For those who want to really bend your minds with some cool C# Voodoo black magic, check out this code I created for another question where I demonstrate the ability to create class properties at runtime on demand. This code also uses explicitly typed properties inherited from an abstract class and other classes. https://code.sololearn.com/c0KhE05NCS76/?ref=app
29th Sep 2020, 8:13 AM
David Carroll
David Carroll - avatar
+ 7
There is way more to oop than i mentioned above. If you're really interested in learning oop i suggest to invest money in a propper book or two. And i dont mean clean code and such. Start with the basics do projects and repetition, repetition, repetition. You'll eventually get there. P. S. Unlike the others i won't suggest to watch any youtube videos on oop. The topic ( as is common in programming) is so vast that you can't comprehend whats happening from watching some videos. My expirience is that you get even more confused because people tend to do things very different and dont explain everything in the detail you need, to make sense out of it. You end up like a monkey typing code you dont understand, because you lack the basics. If you watch videoes on YouTube choose the ones that try to explain a certain problem, not a topic or a whole idea.
29th Sep 2020, 5:35 AM
jack
jack - avatar
+ 6
Lothar I got confused with concept of classes ,encapsulation,polymorphism, inheritance and their syntax look a bit hard to understand can you please explain me the concept of Object Oriented Programming easily . I learnt OOP in Sololearn w3schools also but I am stil confused with its syntax.they look so vast😱😨
27th Sep 2020, 10:36 AM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 6
Maybe because it's more complex than procedural programming.
28th Sep 2020, 3:47 AM
Sonic
Sonic - avatar
+ 6
Just think of the class as being a place to put all the ingredients like properties and methods needed for your object. Once you have done this you will have to create an object from it, the object is like a self contained usable version of the class that contains all the ingredients for you to use. If you create 2 objects of the same class both objects are seprate from one another just like in real life when you see 2 identical cars which look the same but you know there 2 separate objects that have there own properties ie one car gets damaged but the other is intact.
28th Sep 2020, 9:53 AM
D_Stark
D_Stark - avatar
+ 5
Have you gone through the Python or Java course herein?
27th Sep 2020, 2:46 PM
Bohdan
Bohdan - avatar
+ 5
PART 2 ====== JavaScript objects, as a matter of fact, need a blueprint for construction. This blueprint is called prototype. If no prototype constructor is provided, the base Object prototype is used. So `{}` is similar to `new Object()` A class (actually an object factory in JavaScript) can be created as in other languages. class Human {} To further understand OOP there are many terms which you must understand. I will explain some of the common terms here. Attributes: variables that hold state of an object or hold references to other objects. Methods: Functions that are specific to an object. They will likely modify an object state or return the state. Encapsulation: The process of grouping related data into a class and setting modifiers on which objects can access the said data. Inheritance: When an object extends another object by inheriting its blueprint and adding new attributes and/or methods to the blueprint. Composition: When a object stores a reference to another object has an attribute.
29th Sep 2020, 6:05 AM
Ore
Ore - avatar
+ 5
PART 3 ====== Polymorphism: The ability of a class to produce objects of different form. Constructor: A function that describes actions to be performed when a object of a specific type is created. Destructor: A function describing actions to be performed when an object lifecycle has expired. There are so many other terms. It will be wise to seek a good tutorial on this subject. But hopefully this is a good introduction.
29th Sep 2020, 6:11 AM
Ore
Ore - avatar
+ 4
Arnav Kumar PART 1 ====== OOP is a complex paradigm that I can not explain completely here. I hope to just give an introduction and leave you to learn it yourself somewhere else. The whole idea of object oriented programming is to encapsulate related data into small objects. These small objects have their attributes and methods with which they interact with other objects in unique ways. The interaction between several of these related objects make up the bigger picture. An analogy: The real world is full of many objects, both living and non-living. These objects exist independently and have their own internal state some of which may not be accessed directly by an external medium. But these objects interact with each other to produce the bigger picture. That is what OOP feels like. About the connection between JS and Java objects: They are similar but not exactly the same. ....will continue in another response
29th Sep 2020, 5:48 AM
Ore
Ore - avatar
+ 3
Ya I have completed java kotlin c++ and python without understanding OOP and just ignored them
27th Sep 2020, 3:55 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 3
I am confused with objects and classes in JavaScript we use objects they have methods properties but in other programming languages like python there is no object like in JavaScript there are classes that look like objects in JavaScript they also have methods and properties . I know that the classes are like the blueprints for making objects but in JavaScript I can make objects without using classes so why I do need to use classes there
28th Sep 2020, 3:55 AM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 3
Lothar I am good at functional programming but the concept of class and objects and their properties and method are confusing me Though I can make objects in JavaScript write there properties and methods vary easily but when it comes to make an object using classes it seemed to be hard for me
28th Sep 2020, 3:59 AM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 3
Public means as much as other parts oth your programm can see this property or method as well. Private means just the opposite, only members of this class can see methods and property so they wont be accessible in other classes. Void is a return parameter that defines that a method ( js the equivalent would be function) has no return therefore the keyword return is not valid with any return type ( can still be used to exit the function) Protected is much like private except that its visible to derived classes ( Inheritance) Internal is only visible with in you application/ programm. Virtual makes classes available to be overridden using the override key word. Most commonly ToString() method in c# is overridden to adjust the string output ( i doubt your user wants to know the type of class youre using so you have to adjust output) Thats that in short
29th Sep 2020, 5:27 AM
jack
jack - avatar
+ 3
Arnav Kumar You do not need to have a glossary while learning. As you learn, you will discover new things and understand new terms gradually.
29th Sep 2020, 6:16 AM
Ore
Ore - avatar
+ 3
Arnav Kumar Java and C++ support OOP well enough. Python is definitely lacking some core features. I don't know about Kotlin. I would say start with Java because it is easy compared to C++ or Python.
29th Sep 2020, 6:45 AM
Ore
Ore - avatar
+ 2
But I want to learn oop!
28th Sep 2020, 8:24 AM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 2
Kirabo Ibrahim no it's syntax can you help me with that
28th Sep 2020, 9:51 AM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 2
D_Stark I know how classes and object relate to real life objects Can you please help me with the code syntax of classes and objects and keywords used in them
28th Sep 2020, 10:06 AM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar