LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-05-2008, 03:48 PM   #1
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
To Object or not to Object...that is the question.


Well not really a question but a opportunity to discuss the pros and cons of Object Orientated programming.

In a recent thread there appears to be some confusion about the benefits of O-O programming. Rather than going off topic too much in that thread here is a new thread to give the discussion some more air time.
 
Old 08-05-2008, 07:02 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Well, my largest project to date is a hybrid of POSIX C and C++, about 50/50. I couldn't have done what I wanted to with only one. Not only that, but the project existed on paper for months before I wrote any code and it came out like I envisioned, but a hundred times better. Again, that wouldn't have been possible with one or the other.

For large, complex, multi-library, multi-program, complexly-interacting projects you really need both. If you manage to get by without one or the other, you probably use a high-level language or library routines that incorporate the one foregone, otherwise you probably have one hell of a mess.
ta0kira
 
Old 08-05-2008, 11:40 PM   #3
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 248

Rep: Reputation: 32
I completely agree with ta0kira

Earlier when I was learning c++ and object oriented concepts, I thought the same thing can be achieved with c language also with proper design.

Now I am working on a huge project.

Here to get the things done, I will be able to do or handle with the combination of both C and C++ very efficiently rather than only with one language.

The main reason may be probably that the kernel is in c language rather than c++.

when I raise any exceptions or start any threads it is with respect to the process. But I want it with respect to objects.

Last edited by chakka.lokesh; 08-05-2008 at 11:41 PM.
 
Old 08-06-2008, 05:02 AM   #4
neioo
LQ Newbie
 
Registered: Jan 2008
Location: Sant Quinti de Mediona
Distribution: Gentoo
Posts: 25

Rep: Reputation: 2
Thanks for open this post. I will keep an eye on it.
 
Old 08-06-2008, 05:11 AM   #5
vladmihaisima
Member
 
Registered: Oct 2002
Location: Delft, Netherlands
Distribution: Gentoo
Posts: 196

Rep: Reputation: 33
I do not understand when you say that you your project is 50/50 C/C++. C is almost completly included in C++. Maybe some weird syntax is not supported, but you do not have to use any of C++ features. So the whole project can be considered C++, but not all the project uses all the features of C++.
 
Old 08-06-2008, 09:28 AM   #6
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Original Poster
Rep: Reputation: 148Reputation: 148
So here are a few of my thoughts...
The confession, I have a bias towards OO development. I create classes even if it takes me more time hitting those wee buttons on the keyboard but I find it easier when designing an application to break it down into terms of classes. I also feel that the application is easier to maintain since I can locate the code quicker because the methods reside within the class structure. Protecting data from external interference gives me a nice warm feeling even if I don't add sufficient error checking in the set methods, I know that when I have time I can get back to those methods and add the code.
 
Old 08-06-2008, 01:01 PM   #7
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by vladmihaisima View Post
I do not understand when you say that you your project is 50/50 C/C++. C is almost completly included in C++. Maybe some weird syntax is not supported, but you do not have to use any of C++ features. So the whole project can be considered C++, but not all the project uses all the features of C++.
The functions of libc are grandfathered in, but are still C. Also, POSIX C functions aren't a part of C++. By "50/50" I mean half standard non-C C++ code (e.g. abstract classes and templates) and half traditional and POSIX C, mostly in .h and .c files.
ta0kira
 
Old 08-06-2008, 11:26 PM   #8
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 248

Rep: Reputation: 32
Quote:
Originally Posted by ta0kira View Post
Also, POSIX C functions aren't a part of C++.
Can u please explain more elaborately???

thanks.
 
Old 08-07-2008, 12:18 AM   #9
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by chakka.lokesh View Post
Can u please explain more elaborately???

thanks.
Well, nothing in man 2 is a part of C++, and many things in man 3 aren't either, but most of those that aren't are a part of the POSIX specification and are necessary in most non-trivial Linux C(++) programs.
ta0kira

PS Also, I don't think that C++ incorporates C "as ammended" since they have their own ISO. I think they explicitly need to incorporate a version, but I don't have a standard nearby to check. Anyway, that's not the discussion. Even if all of C is in C++, it's still a procedural feature of a hybrid language.

Last edited by ta0kira; 08-07-2008 at 12:28 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Allthough squid has 1 object, it still asks object to http server markraem Linux - Server 0 10-08-2007 11:40 AM
Shared Object / BRK question warrenahuntjr Programming 1 07-12-2005 05:29 AM
structre object question cranium2004 Linux - Networking 0 01-31-2005 04:49 AM
perl object Oriented Programming Question eastsuse Programming 1 08-20-2004 12:29 PM
Event driven object-to-object: C++ template class mecanism ( NOT STL or STDC++) bretzeltux Programming 2 12-23-2003 02:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration