473,803 Members | 4,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++ equivalent to spaghetti code

Hello all,

I would like to bring to your attention a concept
and a term for it that I think is long overdue.

But first: In the bad old days of programming,
before subroutines were even available,
people used to write "spaghetti code", which
was an unreadable, unmaintainable mess of
"goto" statements.

With the increased availability of more
languages such as Pascal and C, and the
focus in programming courses on the importance
of modularity and abstract data types,
one might have thought that the days of
commonplace incomprehensibl e code were over,
or at least that the worst case scenario
in average code was improved.

In the case of C++, this is not so.
C++, with its multiple inheritance,
templates, and vastly bloated class libraries
such as STL and Boost, which permit and
seem even to require illegible coding practices
in which 5-deep derived classes are not
unlikely, has led to the C++ equivalent
of spaghetti code.

But how to describe it? Commonly people
simply call it "bad coding practices" but this
is too general. It's like calling a traffic accident
"bad driving practices". What then is the
term for an "accident" in C++? To describe this
build-up of tangled incomprehensibl e bloat,
I shall propose a new term:
C++ plaque.

It is similar to the plaque build-up in
Alzheimer's insofar as it impairs memory,
makes the programmer confused about
what is located where and what day it is.
In addition, when C++ plaque accumulates,
it decreases the programmer's ability
to function in his/her daily work life, ergo
anything (s)he produces will be much more
likely to crash, e.g. KDE.

Fight code pollution by not polluting.

C++ plaque: The cure is within you.

Thank you for your attention.
Jul 15 '08
40 2691
On 20 Jul., 10:23, James Kanze <james.ka...@gm ail.comwrote:
On Jul 19, 11:25 am, terminator <farid.mehr...@ gmail.comwrote:

C was never really a good general purpose language. *It was
never used (nor even usable) in commercial software, for
example.
This is not correct. My guess would be that there is loads of C-based
software around. Speaking for myself, I have been developing
commercial software in C from the days before C++ became popular. The
software was a financial package which is still today very
successfull.
I was one of the programmers evaluating C++ as a replacement and even
though I liked it very much, I had to reject it: we programmed for a
segmented architecture (yes - it was so long ago!), and the current C+
+ compilers we found did not have sufficiently good support for that.
Had the compiler given us suficient support for the architecture, I
would certainly have recommended C++.
Also many of the database-products out there (e.g. Oracle) are written
mostly or entirely in C.

/Peter
Jul 20 '08 #21
[followups set to clc]

peter koch said:

<snip>
My guess would be that there is loads of C-based
software around. Speaking for myself, I have been developing
commercial software in C from the days before C++ became popular. The
software was a financial package which is still today very
successfull.
I was one of the programmers evaluating C++ as a replacement and even
though I liked it very much, I had to reject it: we programmed for a
segmented architecture (yes - it was so long ago!), and the current C+
+ compilers we found did not have sufficiently good support for that.
Had the compiler given us suficient support for the architecture, I
would certainly have recommended C++.
Also many of the database-products out there (e.g. Oracle) are written
mostly or entirely in C.
Re-post (as far as I'm aware, I first posted this back in 2006):

An Oracle programmer (a very good one, I hasten to add) once told me of a
chap who came to his place of work in the early 1990s, attempting to
persuade them to convert from C to C++. The poor chap spent an hour or so
presenting an object-oriented database methodology to the Oracle guys. He'd
obviously worked very hard on it. As he was winding up his presentation and
heading rapidly towards "are there any questions?", he suddenly noticed
that just about everybody in the room was regarding him with utter
astonishment. He panicked, and said "What's the matter? Have I got
something wrong?" Came the reply, "No, no, maybe one or two bits could be
improved here or there... it's broadly okay though... but - we did all this
*years* ago! And you want us to write it *again*?"

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 20 '08 #22
Richard Heathfield <rj*@see.sig.in validwrites:
James Kanze said:

<snip>
>C was never really a good general purpose language. It was
never used (nor even usable) in commercial software, for
example.

So MS Windows is not commercial software? Interesting.
Last time I looked, UNIX was not particularly uncommercial either.

--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Jul 20 '08 #23
Alf P. Steinbach <al***@start.no wrote:
>
It would be very surprising, to say the least, if no or just a very few
commercial applications were written in C.
All of my company's major commercial applications are written
predominantly in C, including one that's completely object oriented
but predates C++ by about a decade.
--
Larry Jones

These child psychology books we bought were such a waste of money.
-- Calvin's Mom
Jul 20 '08 #24

"James Kanze" <ja*********@gm ail.comha scritto nel messaggio
news:01******** *************** ***********@b1g 2000hsg.googleg roups.com...
Funny, I use it for that, with no problem. (Well, I'm not sure
what you consider web programming, but Firefox is written mainly
in C++. But maybe you don't consider that web programming.)
I'm maybe wrong, but I was under the impression that for Firefox they use
gtk+, which is written in C...



Jul 20 '08 #25
On Jul 20, 10:50 am, "Alf P. Steinbach" <al...@start.no wrote:
* James Kanze:
C was never really a good general purpose language. It was
never used (nor even usable) in commercial software, for
example.
I'm not sure that statement is valid.
It would be very surprising, to say the least, if no or just a
very few commercial applications were written in C.
There are certainly a few. Way back when, however, the X/Open
group proposed standardizing a form of Cobol (under Unix!)
because C was felt to be unusable for business applications.

At least certain types of business applications require some
sort of decimal type. If the language doesn't have it built in
(as Cobol and PL-1 did), and it doesn't have operator
overloading, expressions quickly become unreadable. For those
applications, at least, if the language doesn't have a built-in
decimal type, and it doesn't have operator overloading, then
it's really unusable for those applications (although you'll
doubtlessly find some masocists doing it).

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jul 20 '08 #26
"Lorenzo Villari" <vl****@alice.i twrites:
I'm maybe wrong, but I was under the impression that for Firefox they use
gtk+, which is written in C...
Gtk+ is indeed written in C, but it's object-oriented and has bindings
for a number of languages, including C++.

sherm--

--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
Jul 20 '08 #27
On Jul 20, 1:51 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
James Kanze said:
<snip>
C was never really a good general purpose language. It was
never used (nor even usable) in commercial software, for
example.
So MS Windows is not commercial software? Interesting.
Yes. Commercial can be used in several senses (and I'm not sure
of the usual English usage here). There's a lot of software
written in C that is commercial in the sense that it is sold
(i.e. commercial as opposed to free software). What I was
talking about, however, was the application domain. You can't
really do accounting in C, for example, because it has neither a
built in decimal type (like Cobol), nor operator overloading on
user defined types (like C++). More generally, C is pretty bad
for text handling as well.

Of course, a lot of early Unix systems only had C, and between C
and assembler, you used C, even if it wasn't the ideal language
for the job. (Although the old X/Open group did try to
standardize a Cobol dialect for Unix.)

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jul 20 '08 #28
James Kanze wrote:
) Yes. Commercial can be used in several senses (and I'm not sure
) of the usual English usage here). There's a lot of software
) written in C that is commercial in the sense that it is sold
) (i.e. commercial as opposed to free software). What I was
) talking about, however, was the application domain. You can't
) really do accounting in C, for example, because it has neither a
) built in decimal type (like Cobol), nor operator overloading on
) user defined types (like C++). More generally, C is pretty bad
) for text handling as well.

In other words: There cannot be any commercial applicaiton written in C,
because in your view it is not well suited to one or two application
types you can think of.

Your argument is fundamentally flawed in two entirely separate, both
equally valid ways.

- That it is not the most well suited does not imply that it is impossible
that commercial software is written in it.
- There are many more commercial application types than the few you
mentioned.
It may be that you're trolling though. It is a very nice blanket statement
you made, one that will rile many people, and with a lot of wiggle room.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
Jul 20 '08 #29
[followups set to clc]

James Kanze said:

<snip>
You can't really do accounting in C, for example,
Really? How strange. I've done loads of accounting in C. (But then I've
always been good at doing the impossible.)
because it has neither a
built in decimal type (like Cobol), nor operator overloading on
user defined types (like C++).
You don't need either of those to do accounting.
More generally, C is pretty bad for text handling as well.
It's easily good enough, given that just about the first thing most people
do in C is start work on their text-handling libraries.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 20 '08 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1763
by: Brent Mondoux | last post by:
Hey everyone, I'm trying to find the best non-spaghetti code way to do the equivalent of a ColdFusion CFQUERY GROUP command so that I can display a FAQ with categories as follows: -- Example: Begin -- General
7
2050
by: CoreyWhite | last post by:
You know what I have to say to the giant spaghetti monster? Do you want to know? Do you? Well I'm tired of sucking on your spaghetti and chewing on your fresh meat balls! It isn't only about writing open source code that's free. That's obviously nice. But the Open Source code just facillitates all of this negative energy in the world, the same as the Windows Operating system and the Giant
0
1286
by: CoreyWhite | last post by:
In any kind of communication and language, even in computer programming. We can see a difference between total spaghetti and celtic knot work. But it is easy to confuse the two, because sometimes a ball of spaghetti still makes sense and sometimes celtic knot work is total nonsense. I don't look at religion as spaghetti, and I don't look at my own writting as spaghetti. The philosophers, thinkers, and intellectuals who create beautiful...
20
6683
by: Victor Smootbank | last post by:
I did program in BASIC for more than 20 years and for me it's still the ultimate programming language. Unfortunately, I was forced to upgrade to C++ and now I'm confused. While programming in BASIC, my favourites were GOTOs and sometimes GOSUBs and spaghetti code was my trademark. How can I write spaghetti code in C++???
35
247
by: Campy Happer | last post by:
Hello all, I would like to bring to your attention a concept and a term for it that I think is long overdue. But first: In the bad old days of programming, before subroutines were even available, people used to write "spaghetti code", which was an unreadable, unmaintainable mess of "goto" statements.
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9564
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.