As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I was wanting to ask fellow developers on there opinions on this topic. Basically im working on a project which I didn't design. I'm here to fix up the code and make it as modular and maintainable as possible.
Now, the problem is most classes are well over 3000 lines long :S nightmare.
there are third party libraries in place to help aid with UI design and the code is not very pretty for the most part, especially when it comes to maintaining it which im attempting to do.
I ask, do you feel it is bad practice to call a number of functions from within a function? since the majority of this code is relevant to the class, and its very difficult to break out into another class without passing everything as a parameter ^^. So what I have been doing is breaking out specific functions into separate methods and calling from the method in which they originally derived.
Can someone perhaps shed some light on what they think the best approach should be?
I much appreciate any feedback on this discussion.
It's not bad practice. It's generally good practice. I refer you to Steve McConnell's Code Complete 1st edition chapters 4-5 for more information.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Earlier, a friend of mine sent me a block of code over instant message. It took some working to hammer into place, because they had a series of custom types defined in a header they use in all their projects, just for shorthand - byte, ushort, uint, ulong, and so on.
I was about to chastise them for embedding such custom shorthand into their code, but... is it actually bad practice? Instant messaging is not the normal method for code sharing, and if I'd had the entire functioning project the header with the definitions would have come with it. The shorthand types are all intuitive, and often save typing, but on the other hand that might just lead to laziness.
Is there any kind of official verdict on this?
If the environment doesn't define the types you want to use, then why not define them yourself? Keeping all such definitions in a single header file helps to prevent inconsistencies. It also means you can base your definitions on the most appropriate types that do already exist, and easily update them if you port to a different platform or compiler.
I cannot see why anyone should consider this bad practice.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I know this could be seen as subjective off-the-cuff (thus a poor question), but bear with me.
Boost has recently become available on the project on which I'm working, and I don't have much experience with it. Boost has so many parts and features that it's hard to know where to get started in learning it - especially since I'll be trying to learn it while making production code.
So, I would greatly appreciate it if someone could list around 3 to 5 features which are very useful in general, every-day programming and state why they're useful. I'm not asking you which is best, or trying to get a debate - I just want to know some good features to start learning and using immediately. I don't need code samples either, I'll be more than happy to research how to use the features myself after I know which ones are sensible to start learning now.
I'll accept any answer with a concise list of features that are sensible :)
format and lexical_cast are great for string manipulation, I find them invaluable. I use them every day.
bind is great for ad hoc functors, you'll find it is reused throughout many of the boost libraries.
multi_index fills the gap of when you need the same data in two search structures at once, it is very handy at times. Keep it out of your headers though.
type_traits defines useful traits for template specializations.
signals is a signal/slot mechanism implementation, great for event driven designs.
shared_pointer is critical. It lets you automatically handle memory usage.
http://www.boost.org/doc/libs/1_47_0/libs/smart_ptr/shared_ptr.htm
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm having a C++ seminar in 30 minutes :-)
Because I incorporated most of the examples I usually do on the seminar into the lecture I don't have anything to do with my students. I just gave them a broad overview of templates (from basics to advanced topics).
Any tips what to do?
It can be something that I will explain (step-by-step), or something they will have to code.
Replicate containers - like a list or a vector.
How about trying to implement templates that mirror or are similar to those currently in the STL?
It will give them practice in developing them.
You can challenge them with a "can-be-a-real-system"... and ask them what possible best-practices...
Once you've delivered the basics of templates, point them in the direction of the standard template library and have them get their head around using std::list, std::vector etc to store arrays of objects and iterate through them.
It's easier to implement your own template code, once you understand their advantages. So using the STL should be their next step.
After that, point them at boost ;)
If you haven't yet covered the STL, you could introduce them to that. It is a good example of why templates are extremely useful.
You could also introduce them to iterators using this approach. IMO, learning the STL is one of the most useful things you can learn in C++ :-)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
I'm confused should i learn C++ or ASM?
I'm just a hobbyist so no big deal but i need some advise.
thank you
Very Subjective but I would say learn C. Its the most basic language you will ever need to know. (If you know it you can grasp how assembly works without learning it). Then build on it and learn C++. If you don't know C (pointers, memory management, simple stack/function usage), I would learn it first before piling on C++ (with classes, inheritance, overloads, more complicated memory management).
Thats just my opinion though...
If you're a hobbyist, anything that seems interesting and fun to you will work.
The real question is : what software do you want to make? The project is the important thing.
Then the constraints relative to this kind of software will drive you to make your choice.
C++, ASM is very interesting, but nothing you should nowadays use as your primary language.
Are you a hardware hobbyist? ASM
Are you a game or other software-specific hobbyist? C++
Are you a My Little Pony hobbyist? PonyProg
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Does anyone know of free C++ assessment tests?
I would like to practice my C++ skils before interviews. Brainbench used to have it for free; now they want $49.99 and I think it's rip off..
Most of those "C++ questions" and pay-for-view packets are a ripoff and often a scam.
If you are interviewing at a big company, explicitly Google their name and c++ interview questions. Enough people post the interview questions online, and these companies are way too lazy to actually change this question set. Examples include Google, Bloomberg, and others.
If you want to ace interviews that ask about c++ corner cases, consider the c++ faq or the C++ faq lite (http://www.parashift.com/c++-faq-lite/). It's not questions, but it's the most valuable C++ resource IMHO.
And if you don't use C++ on a day to day basis, try to write some code and compile. I was humbled after too many years of Java to see how much of the syntax is no longer natural to me.
You might want to try My CPP Quiz as that has a set of very comprehensive C++ questions. If you can get through those easily you could consider yourself having a satisfactory understanding of basic C++.
http://www.mycppquiz.com
There is plenty of algorithmic problems to solve at SPOJ. Some of them are straightforward, well known algorithms implementations (see also The Problems classifier) some are harder. The online judge service will check your code's correctness online.