FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Everything object oriented - WHY?!





davidv
Every large project that I've done on my own (10k+ lines of code) and large projects I've worked on with other people (20k+ lines of code) ALL follow the object oriented programming paradigm. My question is, why?

Why is it that nearly all commercial projects all like to use OO? Don't get me wrong. I know quite a bit about OOP in a variety of languages and I love it to bits. Objects are incredibly powerful and makes a whole bunch of tasks much simpler and clearer but aren't there other ways of doing something? Functional ways?

Can anyone provide me (from a commercial perspective) why I would follow OOP over some other method?
jcreus
davidv wrote:
Every large project that I've done on my own (10k+ lines of code) and large projects I've worked on with other people (20k+ lines of code) ALL follow the object oriented programming paradigm. My question is, why?

Why is it that nearly all commercial projects all like to use OO? Don't get me wrong. I know quite a bit about OOP in a variety of languages and I love it to bits. Objects are incredibly powerful and makes a whole bunch of tasks much simpler and clearer but aren't there other ways of doing something? Functional ways?

Can anyone provide me (from a commercial perspective) why I would follow OOP over some other method?

In my opinion and experience, for simplicity, clearness, easeness to look at it. And, in my experience, it does make me code better, and gets me a feeling that i've programmed right Smile

And, regarding clearness:

PyGTK (totally object oriented, Python) you can do something like this:

window = gtk.Window()
window.set_title("Title of the window")
window.show()

GTK (C):

gtk_some_long_function_with_backslashes(GTK_TEXTAREA(object),"some parameter");

Clearly much more understandable the first one.
Fire Boar
It just makes more sense. Most code is designed to either take some input and give an output, or to alter or use some kind of data structure in a particular way. The latter is actually the most common, and fits in best with object-oriented programming: the object is the data structure in question.
Peterssidan
If you want to try something different, not OOP, try one of the functional programming languages like Haskell or Erlang. It's a quite different experience from OOP.
davidv
Fire Boar wrote:
It just makes more sense. Most code is designed to either take some input and give an output, or to alter or use some kind of data structure in a particular way. The latter is actually the most common, and fits in best with object-oriented programming: the object is the data structure in question.


Speaking of data structures, I've only ever had experience with creating and measuring them and so like with most programs, when I kill it, everything in the data structure dies along with the rest of the program.

I'm wondering how would I use one in a real world setting? Say, have 10,000,000 links and I'm storing them in a PQ where the links that are clicked on most are stored at the beginning of the queue and the links that aren't clicked on as much are further down the queue. Every time I load a site, wouldn't I have to somehow get all the links stored from somewhere and then place it all into the PQ? Wouldn't it be faster if I were to just store them all into a database and then just perform a query based on whatever?

I'm under the impression that data structures are used for temporary storage (e.g. stores data on session), small amounts of data (respect to databases) and databases being non volatile where we store huge amounts of data... but, I think I'm wrong here. I was talking to some PhD students a while ago and we were talking about efficient ways of storing very large amounts of data in data structures and then being able to very quickly access it, but wouldn't I still need to load all the data into the data structure first, every time? Yeah, so how are data structures (which hold very large amounts of data) used in a real world setting is what I'm confused about.
amagard
First of all: OO design allows you to design artefacts according to how they are in real world: having attributes and methods. For example a person with an employee number, name and address ( attributes ) who can enter or leave a company ( methods ). From software engineering perspective this makes it easier to design complex systems with all sorts of artefacts.
In a class - a template to create an object - you can keep attributes and methods together, making a class a means to easily implement, maintain and change objects.
With encapsulation you have the means to hide object internal methods to the outside world, thus making objects safer and easier to use. Inheritance makes it easy to create new variations of an object class, thus saving you implementation effort. If for example you have designed a rectangle in a graphical editor knowing how to draw itself on the screen it is less effort to implement a triangle or circle afterwards.

Thus, to sum it up, benefits are:
    clearer and easier design, more in alignment with real world

    less implementation and maintenance effort
Fire Boar
davidv wrote:
Fire Boar wrote:
It just makes more sense. Most code is designed to either take some input and give an output, or to alter or use some kind of data structure in a particular way. The latter is actually the most common, and fits in best with object-oriented programming: the object is the data structure in question.


Speaking of data structures, I've only ever had experience with creating and measuring them and so like with most programs, when I kill it, everything in the data structure dies along with the rest of the program.

I'm wondering how would I use one in a real world setting? Say, have 10,000,000 links and I'm storing them in a PQ where the links that are clicked on most are stored at the beginning of the queue and the links that aren't clicked on as much are further down the queue. Every time I load a site, wouldn't I have to somehow get all the links stored from somewhere and then place it all into the PQ? Wouldn't it be faster if I were to just store them all into a database and then just perform a query based on whatever?

I'm under the impression that data structures are used for temporary storage (e.g. stores data on session), small amounts of data (respect to databases) and databases being non volatile where we store huge amounts of data... but, I think I'm wrong here. I was talking to some PhD students a while ago and we were talking about efficient ways of storing very large amounts of data in data structures and then being able to very quickly access it, but wouldn't I still need to load all the data into the data structure first, every time? Yeah, so how are data structures (which hold very large amounts of data) used in a real world setting is what I'm confused about.


Well, that's only really a problem with things like fire/forget scripts (e.g. PHP). Suppose that instead there is a server backend which runs continuously, answering requests when they arrive. In this scenario, the data can remain in memory for as long as needed, perhaps with a database or file serialization for persistence. Most real programs do in fact follow this model. Scripting is only really common for websites and one-off or scheduled jobs.

Also, "data structure" is really incredibly broad. ANYTHING can be a data structure. For example, the Windows 7 desktop is probably represented by something similar to this: a data structure, consisting of a collection of desktop icons, any desktop widgets, and a panel consisting of the Start menu (which is itself a data structure), a collection of pinned and active programs and a taskbar (a collection of running background programs).
davidv
Fire Boar wrote:
davidv wrote:
Fire Boar wrote:
It just makes more sense. Most code is designed to either take some input and give an output, or to alter or use some kind of data structure in a particular way. The latter is actually the most common, and fits in best with object-oriented programming: the object is the data structure in question.


Speaking of data structures, I've only ever had experience with creating and measuring them and so like with most programs, when I kill it, everything in the data structure dies along with the rest of the program.

I'm wondering how would I use one in a real world setting? Say, have 10,000,000 links and I'm storing them in a PQ where the links that are clicked on most are stored at the beginning of the queue and the links that aren't clicked on as much are further down the queue. Every time I load a site, wouldn't I have to somehow get all the links stored from somewhere and then place it all into the PQ? Wouldn't it be faster if I were to just store them all into a database and then just perform a query based on whatever?

I'm under the impression that data structures are used for temporary storage (e.g. stores data on session), small amounts of data (respect to databases) and databases being non volatile where we store huge amounts of data... but, I think I'm wrong here. I was talking to some PhD students a while ago and we were talking about efficient ways of storing very large amounts of data in data structures and then being able to very quickly access it, but wouldn't I still need to load all the data into the data structure first, every time? Yeah, so how are data structures (which hold very large amounts of data) used in a real world setting is what I'm confused about.


Well, that's only really a problem with things like fire/forget scripts (e.g. PHP). Suppose that instead there is a server backend which runs continuously, answering requests when they arrive. In this scenario, the data can remain in memory for as long as needed, perhaps with a database or file serialization for persistence. Most real programs do in fact follow this model. Scripting is only really common for websites and one-off or scheduled jobs.

Also, "data structure" is really incredibly broad. ANYTHING can be a data structure. For example, the Windows 7 desktop is probably represented by something similar to this: a data structure, consisting of a collection of desktop icons, any desktop widgets, and a panel consisting of the Start menu (which is itself a data structure), a collection of pinned and active programs and a taskbar (a collection of running background programs).


Ahh yes, that cleared up things for me. Thanks Very Happy
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.