Good development practices

N

Nickolai Leschov

Hello,

I have done some programming, mostly on embedded systems but now I would
feel like I have to learn good development practices (i.e programmer's
good manners). Let's say I want to build an application using some
established open source library or application. Do I just download the
source and hack away? Or I'd better do it in some controlled manner, i.e
set up some source control system so that I can always compute the diffs
from the original code? Or maybe I should try to keep my changes
separate from the original code base? How do I do it?

Where do I learn about things like that? I'm sorry for asking this here,
where we dicuss standard-compliant C/C++ programming, but I really don't
know any other place now. I do program in C/C++.

Regards,
Nickolai Leschov
 
V

Victor Bazarov

Nickolai said:
[..] I
would feel like I have to learn good development practices [..]

Where do I learn about things like that? I'm sorry for asking this
here, where we dicuss standard-compliant C/C++ programming, but I
really don't know any other place now. I do program in C/C++.


V
 
L

Lew Pitcher


Hi, Nickolai

[snip]
Where do I learn about things like that? I'm sorry for asking this here,
where we dicuss standard-compliant C/C++ programming, but I really don't
know any other place now. I do program in C/C++.

OK, first thing is to recognize that there is no such thing as
"standard-compliant C/C++ programming", because there is no standard
that defines something called "C/C++".

However, there /are/ standards for the C language, and /different/
standards for the C++ language. You are going to have to choose which
language you want to learn about wrt "standard-compliant" programming.
If you are planning to program in /both/ C and C++, you'll have to
learn both standards, and a bunch of things about inter-language calls
(which, IIRC, the C++ standard talks about, but the C standard does
not).

Having said all that, neither comp.lang.c nor comp.lang.c++ seem to me
to be the best place to discuss the theory of "standard-compliant
programming". Both of these newsgroups discuss the practice of
"standard-compliant programming", and try to leave the theory to other
groups.

HTH
 
M

Malcolm McLean

Lew Pitcher said:
OK, first thing is to recognize that there is no such thing as
"standard-compliant C/C++ programming", because there is no standard
that defines something called "C/C++".
Standards-compilant C/C++ would be a language that anyone would call C, or C
with a few twiddles, but actually conforms to the C++ standard.
Many thousands of such programs are written.
 
M

Martin Ambuhl

Malcolm said:
Standards-compilant C/C++ would be a language that anyone would call C,
or C with a few twiddles, but actually conforms to the C++ standard.
Many thousands of such programs are written.

Or a language that anyone would call C++, or C++ with a few twiddles,
but actually conforms to the C standard. Many thousands of such
programs are written.

Your parochialism is showing. The fact is that there is no C/C++
language, and no standard to conform to. Not to bother with the obvious
point that the expression 'C/C++' is a violation of the standards of
either C or C++.
 
C

CBFalconer

Malcolm said:
Standards-compilant C/C++ would be a language that anyone would
call C, or C with a few twiddles, but actually conforms to the
C++ standard. Many thousands of such programs are written.

No. Run the following program to get the idea:

#include <stdio.h>

int main(void) {
int C;

C = rand(void);
if (C) printf("C / C++ == %d\n", C / C++);
else printf("C / C++ is undefined\n");
return 0;
}

and I expect the vast majority of results to be the value 1.
 
M

Michael DOUBEZ

Nickolai Leschov a écrit :
Hello,

I have done some programming, mostly on embedded systems but now I would
feel like I have to learn good development practices (i.e programmer's
good manners). Let's say I want to build an application using some
established open source library or application. Do I just download the
source and hack away? Or I'd better do it in some controlled manner, i.e
set up some source control system so that I can always compute the diffs
from the original code? Or maybe I should try to keep my changes
separate from the original code base? How do I do it?

Where do I learn about things like that? I'm sorry for asking this here,
where we dicuss standard-compliant C/C++ programming, but I really don't
know any other place now. I do program in C/C++.

You can learn some of it from de Herb Sutter and Andrei Alexandrescu:
http://www.amazon.fr/Coding-Standards-Rules-Guidelines-Practices/dp/0321113586

Michael
 
N

Nickolai Leschov

Lew said:
OK, first thing is to recognize that there is no such thing as
"standard-compliant C/C++ programming", because there is no standard
that defines something called "C/C++".

However, there /are/ standards for the C language, and /different/
standards for the C++ language. You are going to have to choose which
language you want to learn about wrt "standard-compliant" programming.

Yes, I know what is C and what is C++, they are different languages, I
just wrote "C/C++" to save time, not because I think they are the same
or something like that.
Please don't be so pedantic. You know what I meant, don't you?

My question is about good practices applicable to both C and C++,
(that's why I post this to both newsgroups) with emphasis on "good
practices", not "C/C++"
Having said all that, neither comp.lang.c nor comp.lang.c++ seem to me
to be the best place to discuss the theory of "standard-compliant
programming".

This is the term I used to name the topic of discussions in this
newsgroup is I see it. I mean programming in the language, not specific
implementation.
 
B

Bart van Ingen Schenau

Yes, I know what is C and what is C++, they are different languages, I
just wrote "C/C++" to save time, not because I think they are the same
or something like that.
Please don't be so pedantic. You know what I meant, don't you?

Actually, no we did not know that.
There are just too many people about who really think that there is a
language called "C/C++" to assume that a poster knows about the
distinction between C and C++ when he uses the term C/C++.

And if you can't stand pedantery, comp.lang.c and comp.lang.c++ will
not meet your tastes, because they are full of it.

To answer your original questions:
- Using source control is always a good idea. Agood source control
system lets you easily find out when and why certain changes were
made. This I use often in finding the cause of bugs that I try to
solve.
- When writing an application that uses third-party software (open
source or not), you should regard the third-party software as 'read-
only'.
Even if you are allowed to, writing your application intermixed with
library code is likely to break all sorts of things. In the very
least, it breaks the principle of modularity.

Bart v Ingen Schenau
 
P

Philip Potter

Nickolai said:
Yes, I know what is C and what is C++, they are different languages, I
just wrote "C/C++" to save time, not because I think they are the same
or something like that.

From the clc++ FAQ:
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.4

'Do not refer to "C/C++." Some people get testy about that, and will
(unfortunately!) ignore everything else you say just to correct you with
something like, "There is no such language." It borders on pathetic, but
you'll probably be okay if you say "C or C++" instead of "C/C++." Sigh.'

A shame you had to learn this the hard way.
 
J

jkherciueh

Bart said:
Actually, no we did not know that.
There are just too many people about who really think that there is a
language called "C/C++" to assume that a poster knows about the
distinction between C and C++ when he uses the term C/C++.
[snip]

I think your claim is plain false. I never met someone who "really think(s)
that there is a language called 'C/C++'". Also, I have never encountered
the case that a poster using "C/C++" reacted with even the slightest amount
of surprise when informed that there is no language that goes by the
name "C/C++". I wonder if there are, say, three threads from the archive
where it actually transpires that a poster thaught there is a language
called "C/C++". Could you quote even one? (Maybe, there is a difference in
comp.lang.c and comp.lang.c++. My observation is based upon the C++ group.
So, it could be possible that the C forum is teeming with posters who
actually think C/C++ does name a language.)

All that I have observed is that there are some people who regularly
_pretend_ that those using the phrase "C/C++" do refer to some language of
that name. That joke was funny the first time I saw it, but it wears off
over the years.


Best

Kai-Uwe Bux

ps.: Come to think of it, maybe there is a C/C++ language. I think Comeau
offers a compiler for that one :)
 
F

Flash Gordon

Bart van Ingen Schenau wrote, On 18/01/08 10:47:
Actually, no we did not know that.
There are just too many people about who really think that there is a
language called "C/C++" to assume that a poster knows about the
distinction between C and C++ when he uses the term C/C++.

Also please note that in significant area what is good practice in C++
is not even possible in C. A simple example is using new/delete in C++
which do not exist in C. I know the OP wanted the non-language stuff,
but it is the language stuff which is topical here and there are
significant differences.
And if you can't stand pedantery, comp.lang.c and comp.lang.c++ will
not meet your tastes, because they are full of it.

True.

- When writing an application that uses third-party software (open
source or not), you should regard the third-party software as 'read-
only'.

Apart from submitting bug fixes back to the developers.
 
J

James Kuyper

Lew said:

Hi, Nickolai

[snip]
Where do I learn about things like that? I'm sorry for asking this here,
where we dicuss standard-compliant C/C++ programming, but I really don't
know any other place now. I do program in C/C++.

OK, first thing is to recognize that there is no such thing as
"standard-compliant C/C++ programming", because there is no standard
that defines something called "C/C++".

I've never understood the seriously negative responses that the use of
the term "C/C++" provokes. I will concede that it's entirely possible
that someone might use the term in the mistaken belief that it refers to
a single language, but off-hand I cannot remember ever seeing any
unambiguous evidence that someone was making that mistake. It seems
quite clear to me that in most cases, including this one, it is being
used to simplify a statement that is talking about both languages. It is
a natural pairing, because the languages are so closely related - it's
trivial to write code does just about anything you want it to do while
compiling identically under both languages (except insofar as you need
to make use of an external library which only has a C++ interface).

"standard-compliant C/C++ programming" clearly means "standard-compliant
C programming and standard-compliant C++ programming", and is a very
reasonable way of expressing that concept in a shorter form. I program
in C/C++" is an equally reasonable way of saying "I program in C and in
C++". I don't understand what it is that you find objectionable about
that usage.
 
L

Lionel B

Bart van Ingen Schenau wrote, On 18/01/08 10:47:
Huh? Why on earth should you not (license permitting) patch/hack/modify
third-party software to your heart's content and use it in your
application? The entire open source software world relies on being able
to do this.
 
J

James Kuyper

Bart van Ingen Schenau wrote:
....
There are just too many people about who really think that there is a
language called "C/C++" to assume that a poster knows about the

Could you cite an example? I don't doubt that you can, but I'd be
surprised if you can find one quickly. I've been reading comp.std.c and
comp.std.c++ for more than a decade, and I've seen "C/C++" used, and
criticized, many times. Off-hand, I can't remember a single criticism
that was actually justified, though there were probably one or two cases.
 
B

Bart van Ingen Schenau

Huh? Why on earth should you not (license permitting) patch/hack/modify
third-party software to your heart's content and use it in your
application? The entire open source software world relies on being able
to do this.

I am not saying that you should not modify the library at all (licence
permitting), but that such modifications should not be done as part of
developing an application.

If, during the development of an application, you find that a
modification to a supporting library is needed, I would execute the
modification as a separate project.
For a small patch, the distinction between the two projects can be as
small as the mental hat you are wearing, but I would still regard them
as logically separate projects.

Bart v Ingen Schenau
 
B

Bart van Ingen Schenau

Bart van Ingen Schenau wrote:
...


Could you cite an example? I don't doubt that you can, but I'd be
surprised if you can find one quickly. I've been reading comp.std.c and
comp.std.c++ for more than a decade, and I've seen "C/C++" used, and
criticized, many times. Off-hand, I can't remember a single criticism
that was actually justified, though there were probably one or two cases.

My experience is mostly based on what I read in the group
alt.comp.lang.learn.c-c++.
Perhaps the situation is better in the groups that deal with only one
of the languages.
As you asked for an example, here is one:
http://groups.google.com/group/alt...._frm/thread/7968e41fe7f5a0c0/bd6ca478ac969048

Bart v Ingen Schenau
 
F

Flash Gordon

Lionel B wrote, On 18/01/08 12:52:
Huh? Why on earth should you not (license permitting) patch/hack/modify
third-party software to your heart's content and use it in your
application? The entire open source software world relies on being able
to do this.

Because you then cannot easily take the next version of that SW that has
some new and wonderful features.

Most of the OSS world works on people submitting patches back to the
projects rather than taking local copies and hacking it around. That way
everyone gets the benefits of you changes and you get the benefit of
being able to use new versions of the libraries.

However, this is a topic for another group, possibly comp.programming.
 
J

James Kuyper

Bart said:
My experience is mostly based on what I read in the group
alt.comp.lang.learn.c-c++.
Perhaps the situation is better in the groups that deal with only one
of the languages.
As you asked for an example, here is one:
http://groups.google.com/group/alt...._frm/thread/7968e41fe7f5a0c0/bd6ca478ac969048

Bart v Ingen Schenau

The relevant statement from that thread was:
> I am attempting to move to C/C++ from a Java background.

I saw nothing to indicate that he meant anything other than

"I am attempting to move to C and C++ from a Java background."

Can you cite one statement he made that is inconsistent with this
interpretation?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top