ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
I'm learning Java, and I understand the concepts of OOP. I don't understand when/why you would use it. Could someone give me a link to a website or a book on this subject. Appreciate it!
You use it all the time
There are so many sites out there, what about checking out the javax.swing package. You can see the uses of OOP in there.
Component - > Button (as an example) a button is a component.
From a business perspective. You may have a class such as Person, then you could have buyers, sellers, managers, workers. You really would want to use it then.
As for links, gee, just search on www.alltheweb.com and take your pick.
The need for OOP is when you are developing some components and you have the need to reuse them. Take for example C. There, you have to hardcode all the data structures if you have to develop an application. Now in C++, we have OOP and we can use templates and STL.
The best advantages of OOP are inheritance, data hiding and Polymorphism. If you need a good book on the subject , try Bruce Eckel book. It is ThThinking in Java
1. OO is possible in C. It is not a language feature, but a mindset. See the GTK+ source.
2. Parametric polymorphism (templates in C++) does not make OO. It facilitates generic programming, like used in the stl.
3. There are times that OO like structuring are not beneficial, and even harmful. OO programs tend to be larger and often slower. Use OO (and design patterns !!) if you need reusability. Use straightforward imperative/functional style in leave functions/methods.
Generally OO is a good thing, but IMHO programming in an OO style won't automatically give you lots of reusable code. Code reuse comes more from careful design than from using a particular paradigm.
I agree with DIYLinux in that OO is a mindset, but I don't think that any one learning to program can immediately develop that mindset in c and start understanding the GTK+.
IMO you have to first learn through some language that supports it, like C++, or java or python, and then branch on about developing that mindset in other languages like c.
And most importantly, reusing classes and templates, and STL is a lot more easy than just reusing c functions.
You know, i've been studying C++ and such for over half a year now and i've noticed that even to this day myself and my peers STILL aren't exactly OOP primed. Sure we know how to do it, but we don't always see the benifits. Just hard to get your mind over the normal structured alternatives.
Well, for this problem, you have to force yourself to use OO for even small problems. And one of the advantages of C++ is the structural alternative for small problems. And I would suggest learning java, as it is similar and your OO capacity will improve by the exposure.
me and coolman0stress are very different. because i learned Java and OO pogramming 1st. i have a hard time not coding that way. When I write C programs, i tend to make many files to serperate stuff out and make it as OO as possible because that is what im used to.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.