Two Plus Two Publishing LLC
Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > >

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old 08-17-2014, 01:31 PM   #1
Ovalman
grinder
 
Join Date: Mar 2009
Posts: 524
I really can't get my head around OOP

Learned ZX Spectrum BASIC in the early 80's and spaghetti coded my way.

Things like
10 Let a=1
20 a=a+1
30 If a=30 Gosub 100
40 Print a
50 Goto 10
100 Print "a is 30"

I recently came back to programming and find many things so alien. I think my problem lies with the Object Orientated Programming method. I understand what it is (sort of) but I can't seem to apply it with any code I've written. I seem to go back to spaghetti coding which is what I understand.

Most if not all programming courses on Youtube are geared towards the newbie programmer but I've learnt many bad habits that I can't shake off. I'm trying to learn Android (Java) but I've also dabbled in Python and C#. It's not the actual language that's the problem as I understand about loops and variables but it's the actual structure of a program.

If you were creating a program from scratch, how would you go about it?

Can someone explain to me how to break things down from an idea into actual code?

I'm pretty frustrated BTW.

Last edited by Ovalman; 08-17-2014 at 01:35 PM. Reason: typo
Ovalman is offline   Reply With Quote
Old 08-17-2014, 04:05 PM   #2
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: La La Land
Posts: 23,167
Re: I really can't get my head around OOP

This is an incredibly complex question. You are asking people to describe, in one post, years of knowledge.

You don't even offer any code to examine, no specifics of what you are trying to solve, nor describe in any detail the problems you are running into.
daveT is offline   Reply With Quote
Old 08-17-2014, 05:49 PM   #3
ganstaman
Carpal \'Tunnel
 
ganstaman's Avatar
 
Join Date: Sep 2008
Location: central nj
Posts: 9,601
Re: I really can't get my head around OOP

Quote:
Originally Posted by Ovalman View Post
10 Let a=1
20 a=a+1
30 If a=30 Gosub 100
40 Print a
50 Goto 10
100 Print "a is 30"
Unimportant, but line 50 is set up to make for a boring program.

Quote:
Originally Posted by Ovalman View Post
If you were creating a program from scratch, how would you go about it?

Can someone explain to me how to break things down from an idea into actual code?
I agree with daveT. Do you have a particular idea in mind that you were failing to code? Where is it that you're getting lost?
ganstaman is offline   Reply With Quote
Old 08-17-2014, 05:50 PM   #4
kazana
Pooh-Bah
 
kazana's Avatar
 
Join Date: May 2006
Location: que, said che
Posts: 5,659
Re: I really can't get my head around OOP

If you're in the process of trying to get your head around OOP, it's best to start with small, trivial "programs" - not a complex application.

Do some basic inheritance cases and see how the instances behave. Then move on to one of the next more complex paradigm.

Once you've got a better intuitive feeling of OOP, you'll start automagically associating structures/approaches with a problem set at hand.
Then it's a matter of somehow finding out if you indeed do have a good approach for the problem at hand which can be not too dissimilar from playing football with a basket full of snakes.
kazana is offline   Reply With Quote
Old 08-18-2014, 09:56 AM   #5
jjshabado
Carpal Tunnel
 
jjshabado's Avatar
 
Join Date: Jul 2006
Posts: 22,555
Re: I really can't get my head around OOP

Live everyone else said, you're asking a very generic/open-ended question thats not really possible to answer in this thread.

You can do some googling for noun/verbs and object oriented programming. It's probably the easiest way to be introduced to it. The noun/verb strategy is fairly simplistic and flawed in practice but a decent starting point.

Super quick googling (funnily enough most google hits are about how flawed this strategy is):

http://www.eventhelix.com/realtimema...m#.U_IGXIBdVNM
http://books.google.ca/books?id=GEJ_...0verbs&f=false
http://objology.blogspot.ca/2011/09/...ng-advice.html
jjshabado is offline   Reply With Quote
Old 08-18-2014, 12:30 PM   #6
animas
journeyman
 
Join Date: Nov 2012
Posts: 237
Re: I really can't get my head around OOP

This is my layman's understanding of OOP. I hope it helps at least a little bit.

OOP is based on objects. Objects are different kinds of data structures that can hold characteristics inherit to said data structures -- methods (or procedures for manipulating the data of objects) and variables (or data that relates to these objects).

In OOP, the most basic of objects are primitive types -- float, integers, character strings, etc. When you declare a specific number of one of these classes, you are creating what they call an instance of a class. So, for example, you declare in the interpreter a = 1.0; You are creating an instance of type floating-point. Very basic, but this is the gist of creating an object.

To take OOP further, you can design your own data structures in the form of classes, that allow you to create objects that model real life objects. So, for example, you might want to create a class called triangle, whose inherit characteristics(variables) are hypotenuse, adjacent, and opposite, and whose procedures (methods) might be a list of theorems from triangular geometry.

Psuedocode for creating an instance of class triangle might use the length of the sides of a triangle. So: new Triangle triangle1 (50, 40, 30); where the numbers are the length of the sides of the new object and triangle1 is the name of the new object.

That new object might have methods for determining the different size of the angles of the triangle. These functions will be defined for the object when you create the user-defined class, called Triangle.
animas is offline   Reply With Quote
Old 08-18-2014, 04:48 PM   #7
Ovalman
grinder
 
Join Date: Mar 2009
Posts: 524
Re: I really can't get my head around OOP

Android (using Eclipse) overwhelms me, I can't get text fields into variables for instance. I know OnClickListeners do the job but I'm unsure how to apply them. I end up with so many errors that I usually end up ditching the code and starting again.

Java, Python and C# seems a bit easier to tackle (even though Android uses Java) but don't do what I need.

Sorry for the very generic question but I'm just looking a few pointers to help me which some of you have already given. I'm maybe unsure myself how to go about learning to program and why my question is so ambiguous.

I have a couple of idea's for the mobile platform so I really want to learn Android (Java).

Thanks for the replies, it's helped somewhat (i'll give that book in your 2nd link a read jjshabado)
Ovalman is offline   Reply With Quote
Old 08-18-2014, 05:29 PM   #8
maxtower
Carpal \'Tunnel
 
maxtower's Avatar
 
Join Date: Sep 2005
Posts: 7,907
Re: I really can't get my head around OOP

Quote:
Originally Posted by Ovalman View Post
Android (using Eclipse) overwhelms me, I can't get text fields into variables for instance. I know OnClickListeners do the job but I'm unsure how to apply them. I end up with so many errors that I usually end up ditching the code and starting again.

Java, Python and C# seems a bit easier to tackle (even though Android uses Java) but don't do what I need.

Sorry for the very generic question but I'm just looking a few pointers to help me which some of you have already given. I'm maybe unsure myself how to go about learning to program and why my question is so ambiguous.

I have a couple of idea's for the mobile platform so I really want to learn Android (Java).

Thanks for the replies, it's helped somewhat (i'll give that book in your 2nd link a read jjshabado)

It sounds like your problem isn't so much OOP, as it is just lack of experience. To get started with Android, there's a couple key concepts you'll need.
1. Many tutorials use XML to produce widgets on the screen. Maybe you should try to do this programmatically first so you will better understand the connection between XML and Java/Android SDK.
2. Because user events can happen asynchronously, you need to understand a little bit about threading in a program. That's where all those listeners come in to play. The events don't happen sequentially relative to some of the other code you're writing.
maxtower is offline   Reply With Quote
Old 08-18-2014, 09:46 PM   #9
iosys
old hand
 
iosys's Avatar
 
Join Date: Sep 2011
Posts: 1,753
Re: I really can't get my head around OOP

Quote:
Originally Posted by Ovalman View Post
Most if not all programming courses on Youtube are geared towards the newbie programmer but I've learnt many bad habits that I can't shake off.
I disagree but that doesn't matter depending on what your learning preference is and I assume it's not watching videos.
There are many good courses on youtube that don't teach you bad habits...

Maybe consider looking at your code and compare it to code that you consider is elegant by someone else.
Also maybe you should just learn how to navigate documentation if you get frustrated by slowness.

btw what these bad habits?
iosys is offline   Reply With Quote
Old 08-19-2014, 06:54 PM   #10
chezlaw
Limey Bastard
 
chezlaw's Avatar
 
Join Date: Jan 2004
Location: London
Posts: 36,056
Re: I really can't get my head around OOP

Quote:
Originally Posted by Ovalman View Post
Learned ZX Spectrum BASIC in the early 80's and spaghetti coded my way.

Things like
10 Let a=1
20 a=a+1
30 If a=30 Gosub 100
40 Print a
50 Goto 10
100 Print "a is 30"

I recently came back to programming and find many things so alien. I think my problem lies with the Object Orientated Programming method. I understand what it is (sort of) but I can't seem to apply it with any code I've written. I seem to go back to spaghetti coding which is what I understand.

Most if not all programming courses on Youtube are geared towards the newbie programmer but I've learnt many bad habits that I can't shake off. I'm trying to learn Android (Java) but I've also dabbled in Python and C#. It's not the actual language that's the problem as I understand about loops and variables but it's the actual structure of a program.

If you were creating a program from scratch, how would you go about it?

Can someone explain to me how to break things down from an idea into actual code?

I'm pretty frustrated BTW.
Only answering as I also learned to program on a spectrum.

imo you're approaching it wrong, take a basic course in programming on udacity or similar and just play it with a straight bat.
chezlaw is online now   Reply With Quote
Old 08-21-2014, 11:54 AM   #11
Benholio
Carpal \'Tunnel
 
Benholio's Avatar
 
Join Date: Jun 2004
Location: Atlanta, GA
Posts: 8,292
Re: I really can't get my head around OOP

Quote:
Originally Posted by chezlaw View Post
Only answering as I also learned to program on a spectrum.

imo you're approaching it wrong, take a basic course in programming on udacity or similar and just play it with a straight bat.
Seconded.
Benholio is offline   Reply With Quote
Old 08-21-2014, 09:55 PM   #12
Low Key
Carpal \'Tunnel
 
Low Key's Avatar
 
Join Date: Jan 2007
Location: Thank you, Florida
Posts: 33,333
Re: I really can't get my head around OOP

I recommend joy of code and greenfoot, really easy to understand the basics, plus you're making little games in the process ^_^
Low Key is offline   Reply With Quote
Old 08-22-2014, 12:27 AM   #13
Alobar
Born Ready
 
Alobar's Avatar
 
Join Date: Nov 2003
Location: 3rd turtle from the bottom
Posts: 41,298
Re: I really can't get my head around OOP

I thought android was (and still is, cuz I still have a ton to learn) really hard to lean compared to python and java. There arent really very many good resources to teach it in the way there are for lots of other languages. There arent any good lecture style or video courses on it imo. The best course of action is just finding a good book (I would recommend Big Nerd Ranhc Guide for andriod) and then using stackoverflow.

Thats assuming you have a decent understanding of Java, which if you are completely lost with OOP might not be the case? I wouldnt worry so much about OOP in particular, I think its just something that comes with more practice and knowledge. If you are writing lots of code, and reading other peoples code and working on making your code better, it just starts to make sense. I mean you can write really complex programs without using OOP, it just makes everything easier and the entire process more efficient. I dunno how good your Java is, but the Standford Java course is really good. if you have the basics down you can also just look at one of the many MOOCs out there and take an interesting class that uses java as its language, and then you are forced to write code for your assignments, and youll be reading other peoples code, and I think it will really help.

Im still a noob tho, so take all the above for what its worth
Alobar is offline   Reply With Quote
Old 08-22-2014, 10:36 AM   #14
splashpot
Carpal \'Tunnel
 
Join Date: Nov 2004
Location: splashing
Posts: 8,203
Re: I really can't get my head around OOP

Quote:
Originally Posted by Alobar View Post
I thought android was (and still is, cuz I still have a ton to learn) really hard to lean compared to python and java.
Android development is java.

Quote:
There arent really very many good resources to teach it in the way there are for lots of other languages. There arent any good lecture style or video courses on it imo.
https://www.udacity.com/course/ud853 - taught by google developers
https://www.coursera.org/course/android - this one starts in a month but if you click preview lectures, i think the videos are available now

These courses still assume a proficient level of java knowledge though.
splashpot is offline   Reply With Quote
Old 08-22-2014, 11:26 AM   #15
Alobar
Born Ready
 
Alobar's Avatar
 
Join Date: Nov 2003
Location: 3rd turtle from the bottom
Posts: 41,298
Re: I really can't get my head around OOP

Quote:
Originally Posted by splashpot View Post
Android development is java.
what??? Now Im really confused!!

I know its not another language, but the person I was addressing knows that as well, so I thought the meaning of what I was saying was clear enough. maybe not.


Quote:
https://www.udacity.com/course/ud853 - taught by google developers
https://www.coursera.org/course/android - this one starts in a month but if you click preview lectures, i think the videos are available now

These courses still assume a proficient level of java knowledge though.
I never ran across that first one, thanks for the link. I'll have to watch the videos. That coursera course isnt very good (Ive taken it), I mean its worth it I guess cuz its free and its one of the better free lecture ones on android ive done, but you arent going to be able to take just that and be able to do anything worth a **** on your own or even have that be your main source of lean and you fill in the gaps with other resources.

I guess thats what I mean in regards to android and lectures, I have yet to find any lecture source (even a pay one like treehouse, which sucks btw) where you can use just that as your main point of learning and then use other resources to fill in the gaps and come to a decent understanding of whats going on.

Thats just my experience with it. I've done a TOOOON of self learning on all kinda of subjects, and teaching myself how to make android apps is the first time ive ever struggled or gotten frustrated with the available resources. obviously everyone is going to be different.
Alobar is offline   Reply With Quote
Old 08-28-2014, 08:59 PM   #16
Bantam222
veteran
 
Bantam222's Avatar
 
Join Date: Aug 2006
Location: Seattle
Posts: 2,381
Re: I really can't get my head around OOP

I agree with Alobar. Self learning Android was one of the trickier things I have had to do. I'm very comfortable with Java, that was not the issue.
Bantam222 is offline   Reply With Quote
Old 08-29-2014, 11:09 PM   #17
vento
journeyman
 
Join Date: Mar 2009
Posts: 311
Re: I really can't get my head around OOP

Quote:
Originally Posted by Bantam222 View Post
I agree with Alobar. Self learning Android was one of the trickier things I have had to do. I'm very comfortable with Java, that was not the issue.
I am starting to learn java as well and the whole concept of OOP is somethingim gradually learning. Any good books other resources how to structure your program and design it in order to use OOP without line of code written yet. What im interested is how people design their OOP programs. Would be great if you know tutorials walking you the process for some simple programs. Could be even with pseudocode..how to draft classes on paper, write down methods under them etc

Obviously you cant just create perfect plan and execute it and people work different ways but understanding how people approach the problem and map the program beforehand would make it so much easier to code.

Anyone know good recources to learn methodical approach designing/creating programs?

Last edited by vento; 08-29-2014 at 11:27 PM.
vento is offline   Reply With Quote
Old 08-30-2014, 12:48 AM   #18
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,507
Re: I really can't get my head around OOP

Quote:
Originally Posted by vento View Post
I am starting to learn java as well and the whole concept of OOP is somethingim gradually learning. Any good books other resources how to structure your program and design it in order to use OOP without line of code written yet. What im interested is how people design their OOP programs. Would be great if you know tutorials walking you the process for some simple programs. Could be even with pseudocode..how to draft classes on paper, write down methods under them etc

Obviously you cant just create perfect plan and execute it and people work different ways but understanding how people approach the problem and map the program beforehand would make it so much easier to code.

Anyone know good recources to learn methodical approach designing/creating programs?
Just start winging it from the keyboard it has been known to happen.

As far as developing new code embrace the concept of refactoring, it is something that is pretty much inevitable. To me the key is coming up with good base classes that are "naturally" (for lack of a better word) extensible. I could get really into the weeds with this so I'll just say there are a lot of resources including books that will take you through example programs that illustrate the key concepts. Here's one I think is good, Python 3 Object Oriented Programming. Work through the examples as you go through the book and maybe experiment with some changes. Nothing like having to fix code that doesn't work to help you learn in my view. So yeah be bold in experimenting.

Last edited by adios; 08-30-2014 at 01:03 AM.
adios is offline   Reply With Quote
Old 08-30-2014, 05:47 AM   #19
Craggoo
culled
 
Craggoo's Avatar
 
Join Date: Sep 2006
Location: R.I.P. ItzPenzoo 12-09-11
Posts: 12,533
Re: I really can't get my head around OOP

When you learn something new, find a way to apply it.

For example, if you had just learned about a function recursively calling itself re-write an old function that replaces for/while loops with recursive calls.
Craggoo is offline   Reply With Quote
Old 09-03-2014, 03:43 PM   #20
Alobar
Born Ready
 
Alobar's Avatar
 
Join Date: Nov 2003
Location: 3rd turtle from the bottom
Posts: 41,298
Re: I really can't get my head around OOP

Quote:
Originally Posted by splashpot View Post
https://www.udacity.com/course/ud853 - taught by google developers.
I know thats not what this thread is about, but thought id comment for people who come across this and who are interested in android. I worked through this class and thought it was excellent, easily best one ive seen for android.
Alobar is offline   Reply With Quote
Old 10-21-2017, 07:37 AM   #21
Ovalman
grinder
 
Join Date: Mar 2009
Posts: 524
Re: I really can't get my head around OOP

Returning to this thread because I eventually released an app on the Play Store but also to note that no matter what if you get stuck, KEEP TRYING!!!

Thinking back,my problem wasn't really about OOP but that the whole subject was overwhelming. To learn Android not just involves Java but it involves knowing your way around development tools and learning other things like Xml, Sqlite, Html, OOP and a host of other things that you'll need to make a program work.

What I really got stuck on was getting data from Xml to Java. One Youtube video told you to do it one way while another showed a different way. It was all so confusing because like many things in programming, there's usually more than one solution. Coding loops, variables, arrays etc is the easy bit, putting it all together is the problem.

I took many courses and got stuck at this problem but it was taking the free Udacity course when everything clicked.

OOP was not so hard and spaghetti coding is fine if it solves a problem. What really confused me about OOP was talking about houses and cars which may suit a 16 year old learning to code but didn't suit me as a 49 year old coming back to coding. OOP should only really be introduced after you've learned to link everything together.

It's only been a 7 year journey to get where I am but I released a simple fixture list with a widget for my local football club. It's not complicated and I know it has a few mistakes (it checks every 2 hours to see if there is a change to the widget instead of just after each game) but it serves a purpose and it's not my main reason to get into coding. The thing is, it wasn't a copy and paste, I understood the code and while it's not perfect it's something I've made myself.

I've several other ideas on the go including my main reason for coding, a business app which is near completed and involves Sqlite, arrays, loops, OOP and all the other bits that's needed to make it work. I get stuck many times (I'm stuck on back up and restoring my database atm) but I have a working app atm that's idiot proofed with no crashes (well at least until I release it to others!)

While I've just dipped my toes into the subject and I've still much to learn so my advice is don't just give up, you will get there in the end.

Last edited by Ovalman; 10-21-2017 at 07:56 AM. Reason: added: Coding loops, variables, arrays etc is the easy bit, putting it all together is the problem.
Ovalman is offline   Reply With Quote
Old 10-29-2017, 11:55 AM   #22
leavesofliberty
Carpal \'Tunnel
 
Join Date: Jul 2010
Location: probably busto
Posts: 6,260
Re: I really can't get my head around OOP

Find a tutor. Oh nevermind, you seem to be doing that already.
leavesofliberty is offline   Reply With Quote
Old 11-08-2017, 05:26 PM   #23
Sean
newbie
 
Join Date: Nov 2017
Posts: 47
Re: I really can't get my head around OOP

Try reading a book.
Sean is offline   Reply With Quote
Old 07-12-2018, 02:48 PM   #24
TB303
adept
 
Join Date: Sep 2008
Location: not dead yet
Posts: 750
Re: I really can't get my head around OOP

Learned to program on ZX speccy too....and also struggled with OOP. My advice.... FxxK IT! Learn C instead. Also javascript and other modern FUNCTIONAL PROGRAMMING languages. OOP is bs, everyone I speak to who programs in the OOP paradigm takes 10 years to write the simplest of software, all the code they're writing to save them time for reuse later on, simply never gets reused! I never did computer science and I've worked in the field for 15 years, ok I struggle when someone throws their C# code at me for help (thankfully java is long dead).

Abstraction = bs word people use to make sure everyone knows they took a CS course after flunking what they went to uni for
Inheritance = biggest joke in OOP, DO NOT DO IT
Polymorphism = forget it....

OOP is dead. Trust me. Get into Scala or something.
TB303 is offline   Reply With Quote
Old 07-12-2018, 03:49 PM   #25
antialias
journeyman
 
Join Date: May 2018
Posts: 302
Re: I really can't get my head around OOP

Quote:
OOP should only really be introduced after you've learned to link everything together.
I don't agree with this. I've taught people who had previously learned spaghetti code and those who have never coded at all.

It is way easier to get people who have never coded to develop good coding skills than those who started off with spaghetti code.
The latter have to unlearn a lot of stuff that might get quick results on tiny tasks but lead to no end of pain on even moderately complex one (and mostly to code that is so complex that they eventually have to trash everything and start over).

Not to mention that spaghetti coders are less than useless in any kind of team environment.
antialias is offline   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Forum Jump


All times are GMT -4. The time now is 05:12 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2008-2017, Two Plus Two Interactive
 
 
Poker Players - Streaming Live Online