Help with object oriented programming (javascript) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 16

Help with object oriented programming (javascript)

So I understand the fundamentals. Objects have properties, which are variables. They also have methods, which are functions. I understand object literal syntax, which we use to create stationary objects. I understand object constructor functions usting this keyword Which we can use to create multiple objects of the same type, but with different arugments. Ive watched moshes videos on oop, but here is my struggle. I go to write a program, but even though i understand OOP in theory, i dont understand how to implement my ideas through it. I always end up writing procedural programs relying heavily on functions. I think if i had an example of the same program, one written in a procedural-manner, and one written in OOP, then id be able to see how to convert my mindset from procedural to OOP. Any thoughts or advice?

21st Dec 2018, 5:41 AM
Phillip Mark England
Phillip Mark England - avatar
11 Answers
+ 22
Phillip Mark England First... I really appreciate the clear context you established in your question. It really helped me understand exactly where you are. I'd be willing to coordinate a live screen sharing session where we can do some real time, impromptu programming as follows: 1. Intentionally write some Javascript in a procedural way. 2. Convert that Javascript to OOP and talk through the concepts and thought processes to consider. I've done this many times for others over the years and it was always very entertaining. I've recently made use of some live code collaboration tools so I could have the other person code while I provide guidance. It's a great learning device. I've never done this live and recorded though. However, it should be interesting. Morpheus could attest to similar experiences with me. DM me if you'd be up for doing this. We could even make it watchable by the SoloLearn community during the live session.
21st Dec 2018, 9:36 AM
David Carroll
David Carroll - avatar
+ 9
David Carroll Tag me too if we are having a live session. 😃 Phillip Mark England it would be an awesome opportunity to see how a simple procedural code can be transformed into production grade OOP based code. The way David does it is by starting with simplest basics and keep on making it robust by incorporating various language features, You ll be able to assess your current level, where you need help and where to go next. To have a feedback like that might give you awesome clarity.Also, just to provide some context about David, he mentors senior developers working in corporate environment dealing with big stakeholders, so rest assured we ll be getting the best guidance.
21st Dec 2018, 4:16 PM
Morpheus
Morpheus - avatar
21st Dec 2018, 6:44 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 8
David Carroll Thank you Sir ☺! I am pumped up regarding it, you are awesome! We are just lucky to have you in both sololearn and at work. Actually Its hard for me to tell here how much care you put into grooming us. I just hope that I ll be able to catch up when the sprint starts. Phillip Mark England I should say that I had a somewhat similar dilemma with my learning in JavaScript/Nodejs and what to do next. I was very lucky to be guided by David. Btw I had this js fact series that you might like. Many thanks to Gordon for compiling it all in one place https://code.sololearn.com/Wyr76080kKxS/?ref=app
21st Dec 2018, 7:19 PM
Morpheus
Morpheus - avatar
+ 7
Morpheus is too kind. 🙏 The cool thing for Morpheus is he gets paid to have these sessions with me each day for about 2 to 3 hours. 😜 But it's a great investment in grooming him to be our next prodigy and the rest of the team as we prepare for quite a few major feature releases in 2019.
21st Dec 2018, 6:00 PM
David Carroll
David Carroll - avatar
+ 6
Thank you all for the feedback!
21st Dec 2018, 12:36 PM
Phillip Mark England
Phillip Mark England - avatar
+ 3
Count me in!
22nd Dec 2018, 6:25 PM
Jacob Joiner
Jacob Joiner - avatar
+ 1
Sir yes sir, Count me in as well.
24th Dec 2018, 10:07 AM
Mr. Spok
Mr. Spok - avatar
+ 1
I developing whole my life in php this why I have the logic to understand JS but OOP confused me a little bit.
24th Dec 2018, 11:56 AM
Mr. Spok
Mr. Spok - avatar
+ 1
I'm interested too
25th Dec 2018, 10:43 PM
onyebuchi
onyebuchi - avatar
+ 1
You can look at procedural and OO programming using English grammar. It boils down to what you focus on first. Procedural programming is action-centric data-secondary, so you wind up with functions similar to VERB( SUBJECT, OBJECT ). OO programming is data-centric action-secondary, so you wind up with methods similar to SUBJECT.VERB( OBJECT ). To start from scratch with OOP, focus first on all the data you need to store. Any bits of data which are closely related to each other can be grouped into a single object. Only after you have an idea on the data, you now look at how the bits of data interact on each other. To convert from procedural to OO programming, look at each of the functions you created and the arguments passed into it. Highly likely one of those arguments is a complex data structure which you are manipulating and then returning. That argument is good candidate for being an object, and the function could be a method of it.
1st Jan 2019, 9:02 PM
Shardis Wolfe