•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Software Development category of DaniWeb, a massive community of 374,555 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,556 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Software Development advertiser:
Dec 8th, 2006, 7:45 pm
Do you want to create C++ programs faster? You might want to try this coding method.
C++ is supposed to be "superior" to C in terms of usability, upgradability, and all the fancy features. Yes, these are all good features, but if you use C++ the way it was designed, this means writing your program entirely object-oriented.
Now, although object-oriented programs are considered good, they also take time to plan and think out how it's going to work as compared to a similar C program, because it's procedural programming. In fact, I've found myself to be much more productive and sucessful in C when designing my program. This doesn't mean that I'm not going to use C++, it just means I'm going to use it at a later stage. To me, even after planning out every possible class, data and function members, I find that I've made logic errors designing the whole process (usually by the time I'm half-way done coding the classes). Then I have to go back and re-think my logic before I can continue programming.
Another problem I have when writing a program from scratch in C++ is the fact that a truly object-oriented program has classes that are dependant on each other. This means that quite a number of classes have to be coded before the program can run. This might work for some hot-shot programmers who don't make very many errors, but I find that using this method creates millions of bugs and errors in my program, which can only be discovered once I try to run it. Then, I'm faced with the task of debugging and removing all the errors, which can take anywhere from a few days to weeks if it's a more complex program. Not only is this slow, it's depressing and discouraging trying to debug a program that seems determined to keep you from running it.
C on the other hand, doesn't require much planning. You can write sections of your program, test them, remove the 2-3 errors that crept into your little code snippets, and then run it to make sure it's doing OK. Then if you do have an error that you can't seem to fix, you know it originated from the last bit of code that you just entered. This makes coding more encouraging and faster.
Am I saying that C++ is "bad" and that we should all switch back to plain-old C? Absoloutely not. Object-oriented programs have quite a number of advantages over procedural-written programs, not the least of which is maintainability. So what I find is best to do is to prototype my application in C, or at least the base of the program. Once this is working and all in good order, I convert it to C++. And not all at once either. I pick a few simple functions that seem to be related, and create a class out of them. I test the program again, and if it's working, I continue with the next class. If not, I go back to the class and keep working until it runs.
This method allows you to get the best out of both worlds. It allows for quick prototyping, and once you can actually see what you're doing, you can get a better idea of what needs to go where. At this point, you convert the program into object-oriented-ness.
C++ is supposed to be "superior" to C in terms of usability, upgradability, and all the fancy features. Yes, these are all good features, but if you use C++ the way it was designed, this means writing your program entirely object-oriented.
Now, although object-oriented programs are considered good, they also take time to plan and think out how it's going to work as compared to a similar C program, because it's procedural programming. In fact, I've found myself to be much more productive and sucessful in C when designing my program. This doesn't mean that I'm not going to use C++, it just means I'm going to use it at a later stage. To me, even after planning out every possible class, data and function members, I find that I've made logic errors designing the whole process (usually by the time I'm half-way done coding the classes). Then I have to go back and re-think my logic before I can continue programming.
Another problem I have when writing a program from scratch in C++ is the fact that a truly object-oriented program has classes that are dependant on each other. This means that quite a number of classes have to be coded before the program can run. This might work for some hot-shot programmers who don't make very many errors, but I find that using this method creates millions of bugs and errors in my program, which can only be discovered once I try to run it. Then, I'm faced with the task of debugging and removing all the errors, which can take anywhere from a few days to weeks if it's a more complex program. Not only is this slow, it's depressing and discouraging trying to debug a program that seems determined to keep you from running it.
C on the other hand, doesn't require much planning. You can write sections of your program, test them, remove the 2-3 errors that crept into your little code snippets, and then run it to make sure it's doing OK. Then if you do have an error that you can't seem to fix, you know it originated from the last bit of code that you just entered. This makes coding more encouraging and faster.
Am I saying that C++ is "bad" and that we should all switch back to plain-old C? Absoloutely not. Object-oriented programs have quite a number of advantages over procedural-written programs, not the least of which is maintainability. So what I find is best to do is to prototype my application in C, or at least the base of the program. Once this is working and all in good order, I convert it to C++. And not all at once either. I pick a few simple functions that seem to be related, and create a class out of them. I test the program again, and if it's working, I continue with the next class. If not, I go back to the class and keep working until it runs.
This method allows you to get the best out of both worlds. It allows for quick prototyping, and once you can actually see what you're doing, you can get a better idea of what needs to go where. At this point, you convert the program into object-oriented-ness.
This blog entry was written by John Altenmueller, staff writer aka John A. It has received 4,346 views, 0 comments, and 67 linkbacks. 1 voter has rated this entry 4 out of 5 stars.
•
•
•
•
advertising ajax apple asp blogging browser business c c++ code coding competition developer development firefox google hardware html ibm intel internet java linux marketing microsoft mmorpg mobile mozilla networking news open source privacy programming red hat revenue rss search security software sun ubuntu video vista w3c web windows x86 xml yahoo youtube
All Recent Tags Post Comment
•
•
•
•
Only community members can start a blog or comment on blog entries. You must register or log in to contribute.
•
•
•
•
•
•
•
•
DaniWeb Software Development Marketplace
Related Blog Entries
- SF Password Hijack Highlights Importance of Process in City, State IT (2 Days Ago)
- Security Holes Spring Up in Java Framework (8 Days Ago)
- iPhone 3G: It Was All Yellow (10 Days Ago)
- iPhone App Store to open Friday, Jailbreakers could care less (16 Days Ago)
- Cross-Platform RealBasic 3 IDE Ships Today (16 Days Ago)
- Coders Can be Frugal When They Use Krugle (17 Days Ago)
- Microsoft Publishes File Format Specs, 'Open Connections' (18 Days Ago)
- FreeRunner Linux Phone Liberated on July 4 (21 Days Ago)
- Apple Leopard changes spots (24 Days Ago)
- With ‘Ganymede’ Release, Eclipse Community Gets it Done (24 Days Ago)
Related Forum Threads
- Married or not (Geeks' Lounge)
- write java (Java)
- Problem to write C program (C++)
- write apps for windows pda or palmOS pda in C? (C)
- configuring linux as network server and web server (Linux Servers and Apache)
- High-Level Languages (Computer Science and Software Design)
- Not a newbie, think of me as old school... (Visual Basic 4 / 5 / 6)
- mailtos from windows box (Windows NT / 2000 / XP / 2003)
- What Language is used in software like Adobe Photoshop? (C++)