Hello.

Apart from practice and books (like C++ coding standards by Sutter and Alexandrescu) what is the fastest and surest way to acheive coding standards in c++?

Supriyo

Recommended Answers

All 28 Replies

Don't know the fastest, but you could start here

Join the open std C++ mailing list.

Join the open std C++ mailing list.

Can you provide me any links to it?

Don't know the fastest, but you could start here

Thanx.
Apart from this can you recommend any other sources?

To learn the very basics of c++, go to http://www.cplusplus.com. More advanced can be learnt through books like complete reference and others.. Whatever u study, practice makes programming easier

To learn the very basics of c++, go to http://www.cplusplus.com. More advanced can be learnt through books like complete reference and others.. Whatever u study, practice makes programming easier

Thanx.
But what are the rules of practice?

What exactly do you mean by rules? There are no rules for Coding style - such coding standards are usually based upon one or more of:

  • Personal Preference
  • Conventional wisdom (i.e. what do 'most other people' do?)
  • Consistency with existing code (If you're modifying someone else's code)
  • Style imposed by your employer/project leader (these are the only "rules" which exist)

If you really want a 'rule' to follow, then there's only one worth listening to, which is Be Consistent. i.e. don't write code in a whole mixed bag of styles - the most readable code is usually that which follows the same 'theme' throughout. If you can do this, then few people will complain, provided your code is well-formed.

You also might like to read this bit of advice from Bjarne Stroustrup
http://www2.research.att.com/~bs/bs_faq2.html#coding-standard

commented: Agreed +28

What exactly do you mean by rules? There are no rules for Coding style - such coding standards are usually based upon one or more of:

  • Personal Preference
  • Conventional wisdom (i.e. what do 'most other people' do?)
  • Consistency with existing code (If you're modifying someone else's code)
  • Style imposed by your employer/project leader (these are the only "rules" which exist)

If you really want a 'rule' to follow, then there's only one worth listening to, which is Be Consistent. i.e. don't write code in a whole mixed bag of styles - the most readable code is usually that which follows the same 'theme' throughout. If you can do this, then few people will complain, provided your code is well-formed.

You also might like to read this bit of advice from Bjarne Stroustrup
http://www2.research.att.com/~bs/bs_faq2.html#coding-standard

Thanx.
But how can I know whether my code is well-formed?

Can a standalone programmer design large scale C++ projects?

Can a standalone programmer design large scale C++ projects?

In theory, if said programmer is very experienced. However, experience does not come by learning "good coding style rules" by heart.

In theory, if said programmer is very experienced. However, experience does not come by learning "good coding style rules" by heart.

Thanx.
So the alternative is to work with a large team?

>>Can a standalone programmer design large scale C++ projects?

No because one person doesn't have the time to do it. It takes a team of people to design them so that the project gets the benefits of all their ideas and knowledge. I know Windows Word and the Windows operating system were not designed by just one person but by a large team of people.

I have a very large program in C++ that is running without any errors from the compiler. But how can I know whether the code is well formed and mantaining coding standards?

I have a very large program in C++ that is running without any errors from the compiler. But how can I know whether the code is well formed and mantaining coding standards?

By looking at it. Seriously though, there is no such thing as the coding standards. Quality of code isn't something that can be determined by a computer program on a scale of 100 or something.

Some things that might be indicators for bad code are the following:
- lots of manual memory and resource management
- heavy use of C strings
- nondescript variable and function names
- no logical class structure
- little or no error checking and input validation
- unnecessary use of platform-dependant solutions
- hard to read and badly structured code
- ...

But in the end only a moderately experienced C++ programmer can truly give a well-founded opinion on the quality of the code.

commented: agree +28

But since the project is very big will it possible to change it according to the opinions of a moderately experienced programmer or shall I have to start new?

How to acheive the coding standards in C++?

I think the issue here is first to define "big". What does that mean to you, size of an OS kernel (2million lines) , size of a big application (500,000 lines) etc. That gives you an idea of how much time a rewrite will take.

Next define the problem, why do you care how it is written: is it because you are not confident in the results or it crashes often etc., are you extending it to something else or adding functionality, or maybe you need to maintain it in its current state and just fix use bugs, or do you need your users to understand the code. [The latter is encountered say in scientific software, when you may need the users to see that the code implements the algorithms correctly]

The you want to define how complex the field of the program is, is it highly mathematical were algorithmic errors are likely, or maybe numerical rounding errors etc, or is it simpler [in algorithmic complexity] e.g. a GUI.

Once you and we have some of those answers this discussion can go forward. I seem to think that you don't need a c++ standard but more likely to want a static analysis, e.g. like the converity systems [note: useful but very very expensive]

Beyond that, I agree with the posts above, there is no such thing as "the standard", but a lot of things in a code that make me worry and the first one is lack of consistency. After that, poor use of const, lack of references, poor variable/method/class names, lack of comments [particularly around algorithms], overly larger dependence trees etc.

Layout etc, is nearly irrelevant, because I just pass it via a layout manager and it formats the code the way I like it. (e.g. opening/closing braces lined up etc), whilst other developers lay the code out differently, that way the team all work on code in a format they individually prefer.

commented: agree +28

But since the project is very big will it possible to change it according to the opinions of a moderately experienced programmer or shall I have to start new?

Don't change a program just to improve its coding style. "Don't fix it if it ain't broken". If the program is already finished or nearly finished then make style changes only when something else needs to be changed.

Can a small team of less than moderately experienced programmers design large scale C++ software?

Can a few less than moderately experienced programmers design large scale C++ software?

Can a few less than moderately experienced programmers design large scale C++ software?

Stop endless question with no progress. The questions you are repeating are already answered. I say yes and no. Yes if you use some library. for example, i don't have to port my codes to Linux or Mac with wxWidgets. Already big team have worked on Xplatform issues.

I don't mean to discourage you but why don't you dive in? Somebody already said there is no such a thing as "standard coding", so is the definition of Big project. I think you can do it but it depends on definitions of "big" and "standard" you have in your head. ;)

That said, many people have done that some are:
Eran Ifrah - CodeLite
Kevin Hock - Bitwise IM
Julian Smart - Alot of things at Anthemion

so the best way is using library to solve the problem and only code one if there is none.
There are scale of project that can't be done with one person "practically". Something Like Ubuntu Lucid, MacOSX, Windows 7 just can't be done by one person.

So drop your fears in trash can and start coding and finish up your project.
Then take cup of coffee :icon_wink:

commented: excellent final summation post +3

What are the design steps in creating a C++ class?

Use UML to design your system. may be some use case and then class diagram.
Then Create class and make objects.

Use UML to design your system. may be some use case and then class diagram.
Then Create class and make objects.

Can your recommend me any source to the above?

Can your recommend me any source to the above?

You mean like GOOGLE? :icon_wink:

commented: Yup +4

The questions he's asking look suspiciously like exam practise questions on design methods and coding theory... ;)

If this is true, I suggest you ask your lecturer. They are there to help. Asking them questions about something you don't understand will not penalise you in any way ;)

@Ketsuekiame, nice one dude !!

Hey Supriyo,

Standards wont come all of a sudden. I am a final year game programming student. Have written quite a few games and lotsa programs. Even now i dont write a perfect standard program. Standards are something u fix. Just keep practicing. Write plenty of codes, automatically u will get professionalism and standards which u are asking for. And moreover, 1 programmer cant do a software on his own. Even Mr. Bill Gates had Mr. Paul Allen on his side. So keep practicing. Standards aren't taught, its all experience.

xtrmR

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.