Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: I hate OOP, its starting to give me nightmares...

  1. #1
    Join Date
    Jun 2009
    Beans
    1,618
    Distro
    Xubuntu 12.04 Precise Pangolin

    I hate OOP, its starting to give me nightmares...

    I just don't get OOP, never have, probably never will...

    I have tried to use mvc to organize my OOP into something that isn't just a list of functions, and also works...

    Getting to the point: I have no idea how I should go about writing this application.

    First a small login window pops up where you can create, edit, delete, or login to an account.

    Once you login the main window appears where most of the work is done.

    Other windows can be opened from this main window, but it will remain there until the end of the application.

    Now my first problem is, that I want (Or at least, I think I want) there to be a head model and controller for the entire app, so that the login window can be an offshoot, and everything will work...

    The problem is that this means the model and controller have to create children for the login window, but the view has to be connected to the children rather than the top-levels.

    If that happens then I have to create views with the controller? What the hell?

    I thought they were all supposed to be seperate?

    I don't get this at all...

    Small demo:
    Code:
    m = myModel()
    v = myView()
    c = myController()
    
    class myModel:
        #create sub-model for login form
    class myController:
        #create sub-controller for login form
    class myView:
        #do whatever it is that a view does
    class subModel:
        #work the profile selector
    class subController:
        #and this has to patch the whole application together or something?!
    Sorry if I'm confusing you, as you can see I don't have any idea what I'm doing...
    Comitas. Brevitas. Nulla ambitio.

  2. #2
    Join Date
    Sep 2009
    Beans
    88

    Re: I hate OOP, its starting to give me nightmares...

    What language are you doing this in?

    Im not really sure if i understand what youre getting at here, so my apologies if this answer isnt helpful.

    I'd probably start with a parent class called Window, which implements the most basic and essential aspects of all windows (resize, move, etc) and force virtual functions that must be inherited by children objects. You could then create subclasses, like, LoginWindow or MainEventWindow that implements the above virtual functions in their own way (for their own exection), and other functions needed by then.

    You could then create some sort of window decorator class(or probably class hierarchy) that Window Objects create. This might be something like, parent class: WindowObject, with subclasses, Button and ScrollBar.

    I dont know what you mean by a window controller? Maybe some sort of data structure that stores all of the currently created Window objects(vector, array)?

    Ive mainly had experience with OOP in c++ and this is where a lot of my answers are coming from

  3. #3
    Join Date
    Jun 2009
    Beans
    1,618
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: I hate OOP, its starting to give me nightmares...

    I'm writing in python with pyGTK and gtkmvc modules, gtkmvc is designed to keep programmers from making non-OO like mistakes...

    It means there should only be one way to do what I'm trying to do, unfortunatley, I still screwed up

    http://sourceforge.net/apps/trac/pygtkmvc/wiki
    Comitas. Brevitas. Nulla ambitio.

  4. #4
    Join Date
    Oct 2008
    Beans
    561

    Re: I hate OOP, its starting to give me nightmares...

    object are just there to help you split up the code, its not hard but i know what you mean, books always seem to describe it interms of shapes or colours, which for me made it as clear as mud.

    basically for this project you will probably want at least two classes (i dont really know what youre wanting to do, but broadly speaking...) a gtk one and a behind the scenes one(more if you have completely separate, unrelated pieces of behind the scenes code), those can be kept completely separate from each other appart from the passing of objects, the main advantage is supposedly so that to can say swap out gtk for qt bindings without having to go through all of your code etc, plus you then have well define communication channels between classes.
    Check out my little app. Tnote

  5. #5
    Join Date
    Jan 2007
    Location
    Utah
    Beans
    550

    Re: I hate OOP, its starting to give me nightmares...

    You really have to have the proper exposure to OOP in order to understand its benefits. There are many design patterns you can use to get the job done.

    If you use OOP well, it can save you a ton of work. The idea is that you can change an object's underlying behavior without having rewire how all the other objects talk to it. By giving each object a clear objective (no pun intended), it can likely be used in multiple cases and maybe even reused in future projects.

    It is worth researching. I cannot count the number of times that OOP has saved me. I later realize I coded something wrong, so I go back, gut out the object, recode it, and everything works fine (I don't have to go anywhere else in the code and change anything because the object's purpose was still the same).

  6. #6

    Re: I hate OOP, its starting to give me nightmares...

    OOP is just a paradigm for doing stuff, not a magical technique that fixes everything It is verry good for some things, like game dev, and very bad for a lot of other things.
    im dyslexic, please don't comment on my spelling
    blender 3d artist, visit my portfolio
    Quad-Ren, Open source, resolution independent 2D graphics engine
    Screen space is a precious resource, don't waste it

  7. #7
    Join Date
    Jun 2009
    Beans
    1,618
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: I hate OOP, its starting to give me nightmares...

    3 completely conflicting answers, one even more confused OO noob

    Ok, lets say I do want to do OOP, and I'm using the MVC template, all I want is to have a parent model and controller for the entire app, and open 2 windows without one being above the other...

    Does anyone know how I do this? I don't want to have to do some "self.parent.parent.parent.parent.newObj" code later on in the program yknow?
    Comitas. Brevitas. Nulla ambitio.

  8. #8
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: I hate OOP, its starting to give me nightmares...

    I think you (the OP) are confusing a lot of things and that way making your path to OOP much harder than it really is.

    1) OOP is just about organizing your code thinking about objects that have some propierties and do some actions... and interact with eachother. That's it. Some languages like Python will give you explicit syntactic devices to handle OOP in an easier way than without them.

    2) MVC is not OOP. Moreover, MVC is a really hard thing to learn if you don't have OOP clear. Try some simpler: Create a class that holds the implementation and a class that holds the user interface; design the first one that way that you can imagine the second is a human that executes the code in the implementation class as if it were "typing" into a shell.

    3) OOP is not the programming silver-bullet, neither any of the remaining paradigms or design patterns is. OOP is useful because we humans tend to think in terms of objects, but sometimes is much better to think in terms of stateless functions (functional programming) or in terms of data (logical programming)... or in terms of code itself (metaprogramming). IMO, the best thing for a lot of problems is a combination of OOP with standard procedural programming.

    4) GTK+ is a pretty monstrous thing. And it's a place were I drop my general advice of "learn the higher level first". IMO, PyGTK is easier to learn having dealt with C GTK+ because PyGTK, even though it has done a great job translating it into Python, it shows a lot of C-isms that make PyGTK code slightly weird compared to "idiomatic Python". (Curiously, PyQt didn't gave me that impression of C++-isms... though I confess I haven't worked that much with Qt in general than with GTK+).

    I hope you're working with the PyGTK API docs at your side...

  9. #9
    Join Date
    Apr 2005
    Beans
    105

    Re: I hate OOP, its starting to give me nightmares...

    If you don't get OO, you won't understand it by learning MVC

    This is 'a brain-friendly' book about design patterns, which might help you understand OO better.

    Like someone else already said, MVC is a paradigm that can be implemented in many ways.
    It simply means separation of your app into M, V and C, but by itself it doesn't tell you how to implement that separation.

    MVC can be implemented as a combination of some basic design patterns (e.g. observer, strategy, command...), so it might be helpful to understand them first.

    You said "...I have to create views with the controller? What the hell?", but that actually is one way of doing it.
    Read this.

    I think it is very important that you don't see it as a 'silver bullet' that is suitable for any kind of UI. Also, I think most people find it complex at first, don't think you're alone
    Last edited by mehaga; October 13th, 2009 at 08:46 PM.

  10. #10
    Join Date
    Jun 2009
    Beans
    1,618
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: I hate OOP, its starting to give me nightmares...

    I certainly don't think of it as a silver bullet, but I've been trying to work with it for the past year (about 40 hours of failures) and I am still right where I started (I have this thing with maths and programming ideas I don't already understand, either it comes as a revelation or I won't understand it at all...)

    Is there an other way to use OOP in a GUI application other than MVC? Is it worth it? (Considering functional programming means its impossible to actually destroy a window, only hide it, or else you have to bundle the whole damn thing into one huge file)

    Thanks for the links vekaz, will post back about my most recent mind-twists...
    Comitas. Brevitas. Nulla ambitio.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •