• This topic has 34 replies, 18 voices, and was last updated 5 years ago by PJay.
Viewing 35 posts - 1 through 35 (of 35 total)
  • OOP for [complete] idiots
  • PJay
    Free Member

    A while back I posted about a slightly naive idea I had that I might have a go at programming as a hobby (I tinkered a bit 20-30 years ago).

    I’ve been having a look at Monkey C (Garmin’s own language for programing ConnectIQ devices) and even the beginners guide assumes a working knowledge of OOP (including familiarity with C and/or Python) and throws around terms such as Method, Class, Object etc. which completely befuddled me (looking for definitions online is proving equally frustrating as one term is usually defined related to another with other terms such as Abstraction, Polymorphism, Inheritance thrown in to boot).

    I’m feeling very out of my depth and wondering whether I should just ride my bike!

    From the good old days I understand subroutines, procedures, functions and global/local variables which I suspect equips me for OOP about as well as a sledgehammer would an IT technician.

    I guess that I just need to understand the minimum to allow me to get going for now. Are there any really basic OOP resources out there before I look for another hobby?

    kelron
    Free Member

    Probably best off trying to learn a specific language rather than learn OOP as an abstract concept. I started learning Python recently and feel like I’m making sense of it a lot more than past attempts at programming.

    Klunk
    Free Member

    when moving from C to C++ I read lots of books on OOP it never really clicked until i started actually using it for proper projects (though I probably found thinking in C++ the most helpful book). The thing with OOP there is usually a million ways to crack a nut and none of them wrong 😉

    sirromj
    Full Member

    The thing with OOP there is usually a million ways to crack a nut and none of them wrong 😉

    Or put another way, there’s a billion different types of wheels and don’t you dare reinvent one of them.

    tor5
    Free Member

    Arguably OOP in the Gang of Four sense is giving way to a more “traditional” functions approach as stuff moves towards micro services and serverless architectures, there’s no need for clever ways of designing systems to be infinitely extensible and live for a thousand years if you can throw away your lambda and write a new one in a day. Learn Python or Javascript.

    oldnpastit
    Full Member

    You can overthink it.

    There’s a book called “Design Patterns: Elements of Reusable Object-Oriented Software”. Whatever you do, don’t read it.

    PJay
    Free Member

    I think that I just need to know what Classes, Methods and Objects actually are – the Monkey C documentation mentions them a lot.

    al2000
    Full Member

    A method is a function, a class encapsulates variables and methods, an object is an instance of a class.

    DavidBelstein
    Free Member

    Do a python tutorial on methods, classes and objects, there will be loads of them and one will click with you.

    Methods, like functions in some languages, a group of statements designed to do something, you call the method each time you want to do the thing, eg calculate_mpg(miles, fuel_used)

    Classes, a group of methods and property definitions, to group related operations and attributes. Heartbeat class contains a property called pulse, methods called set_pulse, get_pulse, calcFitness

    Object, an actual instance of that class, you an have a bunch of objects, like Doctor Who would have 2 heartbeat objects perhaps.

    Create an object of classHeartbeat:

    Heartbeat myHeartbeat = Heartbeat()

    call a method on the object:

    myHeartbeat.set_pulse(120)

    this is the tip of the iceberg but I’d say it’s the bare minimum to get started.

    anyway someone will pull that definition apart rapidly and I hope my boss ain’t reading, do a python tutorial 🙂

    DavidBelstein
    Free Member

    Or what al2000 said.

    UrbanHiker
    Free Member

    Get a copy of dive into python 3(make sure it’s v3), it’s freely available on the net. Read it from cover to cover, doing the exercises. It’ll take you a week or two of evenings. By the end you’ll have a good grasp of Python, a rudimentary understanding of objects, classes and methods. You’ll be able to do some really complex things on your PC. And probably know more than most programmers. It will give you a good grounding to move on from.

    Or you could continue to read about this that and the other. There is an infinite world of this that and the other on the internet. But its way better to get a solid understanding of one thing, rather than just getting confused, frustrated, by multiple things.

    al2000
    Full Member

    Agree that getting a solid understanding of one thing is a very good move, and once you’ve got one major language under your belt, learning others is largely a case of syntax (unless you’re talking major paradigm shifts like OO to functional).

    I think that before recommending any particular language, it would be worth finding out what the OP would like to achieve.

    UrbanHiker
    Free Member
    al2000
    Full Member

    Ah, well for PC (Windows) development I’d definitely recommend learning C#. That thread doesn’t really answer the question about what the OP would like to do with their newly learned abilities though.

    dudeofdoom
    Full Member

    If your planning to program MS Windows definately go the C# route and download the free Visual Studio Community edition you’ll like the programming experience with this.

    molgrips
    Free Member

    I learned about OOP from reading Java in a Nutshell.  The first half of it was all about OOP.

    I was about to type it all out, but you’re probably better off reading something online and then asking specifics of what you don’t understand on here.

    But I could write half a page to get you started if you are still struggling to find something.

    funkynick
    Full Member

    While recovering from spinal surgery recently, and being rather bored, I did an edX course on python programming run by MIT which was very good and did quite a bit on OOP which, while I kind of knew what it was beforehand, I didn’t really understand it. The course actually explained it very well, and you do graded assessments to see if you understand it.

    I think it was called Introduction to Computer Science and Programming using Python if you are interested.

    PJay
    Free Member

    I think that before recommending any particular language, it would be worth finding out what the OP would like to achieve.

    Following on from my previous thread it was suggested that I think of a project to try rather than just picking a language; I thought that I’d have a crack at writing a ConnectIQ app for my Garmin Oregon (ultimately with the idea of perhaps trying to write a basic remote control widget for my GoPro).

    I’ve got the editor and SDK up and running but am struggling to get to grips with Monkey C (this is Garmin’s own development language and seems to be a mishmash of other languages); it rather assumes a working knowledge of C, Python or Ruby (which I’ve never heard off).

    My limited programming experience comes from well before OOP.

    dudeofdoom
    Full Member

    Ahh good old Monkey C , never really got why they just didn’t adopt Python,Ruby or JavaScript.

    I can get why the OPs a tad confused 🙂

    The world of programming languages works at a crazy pace building on top of concepts and assumes that everyone know them.

    Pick one mainline language (Python,JavaScript or C# play with it for a month and get your head around the OOP and other programming concepts ) then go back to monkey c and you’ll be fine.

    Stackoverflow.com also worth visiting if you have questions.

    whitestone
    Free Member

    I wouldn’t choose Javascript as an OO language. It treads its own path and is frankly a bit weird especially when compared to the likes of C++, C#, etc!

    Some of the concepts that were in favour ten years ago are now avoided and new concepts have been added to languages in their place. OOP uses its own terms for things in traditional programming just to confuse things.

    Class: this is a template, a pastry cutter if you like. It’s the programming concept of a real world object or often one that’s useful to the program. You can’t actually use a class in your program without the following

    Object: An actual instance of a class. This is what your program uses.

    Method: OO term for a function but it’s one that’s always associated with a class.

    Class Mammal{

    Move();  // method

    Speak(string message); // method

    };

    Class Dog extends Mammal { // This class has access to everything in the Mammal class

    WagTail(); // specific method for dog

    integer: legs; // class member variable

    };

    Dog pooch  = new Dog(); // create a dog object from the Class

    pooch.WagTail(); // call one of the methods

    pooch.Speak(“Woof! woof!”); // call one of the methods from the parent class

    The above is a very basic outline of OO, there’s concepts of public and private methods and variables; method overloading where you can have two methods with the same name but different parameters. Once you get into a language there are a whole host of features that you might never use but just confuse things until you get used to things.

    molgrips
    Free Member

    JavaScript is a mess, avoid it. It’s only popular because browsers use it and that means people know it. People seem to use it to hack out apps quickly and messily.

    Java on the other hand was designed around clear principles from the start.

    kcr
    Free Member

    There’s a book called “Design Patterns: Elements of Reusable Object-Oriented Software”. Whatever you do, don’t read it.

    Ha! Everyone buys that one. The spine of my copy is almost uncreased…

    It’s a while since I’ve worked as a developer, but some of the more involved OOP stuff does become a bit of a purist academic exercise. It is worth getting your head around the the basic concepts of Classes, Objects, etc, as outlined above. There will be lots of good tutorials online for this. People used to talk about the “OO paradigm shift”, where you’ll find that it finally clicks into place. You don’t need to worry about the more arcane design pattern stuff.

    TurnerGuy
    Free Member

    There’s a book called “Design Patterns: Elements of Reusable Object-Oriented Software”. Whatever you do, don’t read it.

    Ha! Everyone buys that one. The spine of my copy is almost uncreased…

    And what, pray, is wrong with it ?

    I’ll tell you what is wrong though. That book, and others from the same time, were an attempt to consolidate ideas and produce a simplified vocabulary, but then t0ss3rs like microsoft tried to FUD the space again by naming every possible langauge idiom they could think of as a ‘Pattern’.

    TurnerGuy
    Free Member

    I learned about OOP from reading Java in a Nutshell. The first half of it was all about OOP.

    must have revised it significantly since I read it as I thought it was one of the worst books about an OO language that I had read.

    molgrips
    Free Member

    I read the one that said “new for Java 1.1!” on the cover 🙂

    dudeofdoom
    Full Member

    JavaScript is a mess, avoid it

    I don’t disagree but there’s a lot of it about and it’s very popular so you can pretty much rapidly cobble stuff up and it’ll run on anything you want and there will be a million tutorials and sometimes the results can be quite pretty.

    TBH for a hobbyist programmer starting the only use I’d suggest for the design pattern books would be to raise your monitors height.

    TurnerGuy
    Free Member

    I’ll have a go but I’m sitting in a hospice at the moment so it might not be any good.

    In programming there is a constant desire to manage complexity – and as time goes by people attempt to create larger and larger systems, which consequently have more complexity.

    in many languages you have thngs called structures, or structs, where all the data that relates to a particular concept can be grouped together – for example a concept could be a person, and the data would be all the attributes that describe that person.

    There could be several functions defined that can manipulate a person, providing a result based on their attributes, or manipulating their attributes.

    In a procedural language these functions might be passed a reference to the structure they were to process.This could be extended into the ‘modular’ programming style, where the references would be ‘handles’.

    in an object based language you have classes, which are an extension of the idea of a structure, where all the data related to a concept can be grouped together, but you can also define the functions that manipulate that concept within the class itself – where they become methods. Think of a method as a function that is passed the reference to the data it is to work on as its first parameter, which is the case in many languages but the compiler/debugger mask this.

    Additionally you can define access control to the data in the class so only those methods can manipulate it – reinforcing the idea of a concept. You might see the word behaviours being used instead of methds.

    This ‘encapsulation’ of the data and the methods that relate to it allows you to treat that concept as a black box, you see the concept and its behaviours but don’t really care about how it is modelled internally anymore.

    Therefore you have moved to a higher level of abstraction and the complexity is less.

    Then OO languages add modelling of hierarchies of classes that are related – with shared or similair behaviours modelled by derivation, virtual functions, etc.

    This is all well and good as it can model a domain better, so helping you manage complexity, but it can easily be overdone and tall hierarches of classes can be created, actually increasing complexity and making things harder to re-engineer to reduce the complexity.

    The idea of interfaces came along somewhere in this evolution and initially they just looked like a lightweight attempt to model the types that classes represent. But it seems to be better to think of as conduits of information passing between objects.

    You can then divide OO languages into static and dynamic, and they both have proponents, but I prefer static, and massively so for actually writing production code of any complexity.

    You can normally tell the maturity of a Javascript programmer by whether he has realised it is not a tool for writing production systems, imo 🙂

    Java is actually probably a good language to start with – the Bruce Eckel book is free and quite decent.

    https://sophia.javeriana.edu.co/~cbustaca/docencia/POO-2016-01/documentos/Thinking_in_Java_4th_edition.pdf

    Some other langauges just add syntactic sugar on top of Java, or if they are dynamic just add ‘clever’ shortcuts.There are also a lot of good books published by Sun on Java, which may seem academic but are good if you want to learn something in depth.

    I would avoid the microsoft space as I can’t think of many decent books and microsft seem to keep messing up their languages by adding features to make them ‘cleverer’, which can just hid the fundamentals which you want to learn.

    TurnerGuy
    Free Member

    I read the one that said “new for Java 1.1!” on the cover 🙂

    I’ve read a lot of books and wasn’t impressed with this guy, seemed to miss the whole point of OO.

    The C# in a nutshell books however are much better.

    PJay
    Free Member

    Thanks to everyone for taking the time to reply; there are some fantastic responses. It all still seems a tad confusing; I might have another tinker with Monkey C, but Python does seem to be the language of choice for beginners.

    As above I’m very out of date and, if I stick with it, will be learning (or trying to learn) not only a new language (with a lot of new OO concepts) but a new device and OS too; oh for the simple days of BASIC!

    CountZero
    Full Member

    Just browsing through Boingboing, and I spotted this, which might help:

    How to make a bouncing ball simulator in Python

    CountZero
    Full Member

    toby1
    Full Member

    It all still seems a tad confusing

    There is a reason people who really get it are well paid, it’s not something you can pick up and run with in a weekend. I sometimes wish it was though (recruitment would be so much easier)!

    footflaps
    Full Member

    A method is a function, a class encapsulates variables and methods, an object is an instance of a class.

    Pretty much all you need to know. I’ve spent years writing OO code and still couldn’t tell you exactly what Polymorphism is without googling it (and then instantly forgetting it). However, there are a subset of people who will spend months arguing over the subtleties of it on StackExchange etc, but I suspect it’s just the SW Engineers equivalent of a bicycle helmet debate.

    TurnerGuy
    Free Member

    It all still seems a tad confusing

    it’s just information overload – that’s why you should start with the basics and principles and then build on it.

    Find a good, well-recommended book and work through it – forget reading blogs and stuff – there might be a few good ones but there is lots of noise out there to get past. It takes an effort to write a book, not so much a blog entry…

    At any one time 50% of the programmers out there have < 5 years experience, due to the number of new programmers coming into the industry, and you don’t want to be reading of their ‘journeys’ of discovery.

    PJay
    Free Member

    I’ve spent hours staring at the Monkey C Connect IQ examples but just can’t work out what’s going on (I felt like my Grandparents must have back in the 80s when we tried to get them to play computer games) and, rather deflatedly, I’ve just uninstalled everything for the second time.

    I’ve put Python on the system and, well, it’s just like BASIC isn’t it (I am only halfway through the first Code Academy lesson)? I see a Raspberry Pi in the future.

    I may revisit Monkey C if I get a handle on Python.

Viewing 35 posts - 1 through 35 (of 35 total)

The topic ‘OOP for [complete] idiots’ is closed to new replies.