![]() |
| | #16 |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,381
| I'd suggest that you should write code non-stop until you run out of ideas. As soon as you find yourself thinking, "Hmm. I'm not sure how to do this next part..." that's a good time to stop and compile. This avoids creating a break in your concentration. The result will probably be a thousand syntax errors -- that's OKAY. Just look at the first one, and go fix it. Recompile, and repeat. Don't try to fix all the errors in a single pass. Often times, many errors all stem from a single typo. You may find that 3 different typos can create hundreds of errors. Avoiding the break in concentration is very important while in the learning phase. Switching between problem-solving mode and syntax-fixing mode can be taxing. |
| brewbuck is offline | |
| | #17 |
| C\C++ beginner Join Date: Nov 2007 Location: Somewhere nearby,Who Cares?
Posts: 375
| Great stuff tanx dude |
| Masterx is offline | |
| | #18 |
| /*enjoy*/ Join Date: Apr 2004
Posts: 159
| thank you for this perfect code ... |
| enjoy is offline | |
| | #19 |
| Registered User Join Date: May 2008 Location: Kentucky
Posts: 13
| Begging to differ on the act of commenting code. I try to make myself comment every line as I code. Actually, I've had more than one instructor and/or associate insist that such is the best practice. The best practice actually may be a bit backwards. Start with pseudo-code. (I'm just sure you all pseudo-code first. (couchchokespit)) Then put your actual code in right next to the pseudo-code. By doing this your code is pretty much commented already. Dale L |
| nakedBallerina is offline | |
| | #20 | |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
Code: //fill in data for the current BLT operation // We need to know where the blit starts, where it ends and how wide and high it is. // A stride is needed to know how many bytes the image bltinfo.x = rect.x; bltinfo.w = rect.w; // Note blits start from "bottom" going up. bltinfo.y = rect.y + rect.h; bltinfo.h= rect.h; bltinfo.dataAddress = &img.data[img.x + img.y * img.stride]; // Remember, we go UP, so stride is negative. bltinfo.stride = -img.stride; // Now tell the chip to perform the operation. DoBlt(&bltinfo); -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. | |
| matsp is offline | |
| | #21 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| Comments (for students) tend to emphasis knowledge of the language as much as anything. Comments for pros are really just to explain what isn't obvious from just reading the code. Play to your audience basically - there is no set style.
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
| | #22 |
| Registered User Join Date: Jul 2008
Posts: 1
| perfect ! |
| swliang is offline | |
| | #23 |
| Registered User Join Date: Jul 2008
Posts: 1
| The coders who have it right are the ones who document at all stages - before, during, after - especially before. If you don't do it before, then regardless of how accomplished you think you are, your middle name is always 'Spagetti', like Joe 'Spagetti' Smith. If you DON'T know what you are going to code BEFOREHAND, and can't or won't explain it to yourself, you are in deep doo doo from the first line of code onwards, because you are lazy. Actually writing the code, is like painting the house you built. DO IT LAST !!! Start with an architectural drawing, plan out the construction, get the right tools, make a solid foundation, build a sound structure, ensure the fundamentals for expansion are in place, finish the plan - according to the plan ... then paint it. If you did things right, you can modify, reconstruct or rebuild things, and still meet code standards. Else call "Holmes on Home" to rescue you. It is easy to paint and repaint a solid wall or ceiling, right? Last edited by bertking2; 07-04-2008 at 03:08 PM. |
| bertking2 is offline | |
| | #24 |
| Registered User Join Date: Apr 2006 Location: United States
Posts: 3,201
| I'm not one for speaking in metaphor, but developers usually don't have that kind of time. Their goal is if they can get it to work at all, get something shipped. It's good for newbs to plan because they'll become more familiar with language tools, and learn how to make/follow a program spec. It does get easier. |
| whiteflags is offline | |
| | #25 | |
| CSharpener Join Date: Oct 2006
Posts: 5,242
| Quote:
If you do - you will always try to find "that kind of time" to write comments at least...
__________________ If I have eight hours for cutting wood, I spend six sharpening my axe. | |
| vart is offline | |
| | #26 |
| Registered User Join Date: Jan 2009
Posts: 1
| Great thread. |
| Andre Santos is offline | |
| | #27 | |
| Complete Beginner Join Date: Feb 2009
Posts: 312
| Quote:
Saying that developers are happy if they get it to work at all and have it shipped is maybe true if they're writing a web-based calendar in PHP or if they are working at Microsoft. But consider a company that builds an operating system for a nuclear power plant, or maybe just the software for the airbag in your car (as a friend of mine did for BMW). You don't want these people to ship the code as soon as it works, right? There are good reasons these advices are passed around, so let's see why: 1. USE COMMENTS This is true for beginners and advanced programmers alike. Comments make it easy for others to understand your code, and as soon as the project increases to, say, 10.000 (2.000.000) lines of code, it will also be much easier for you. There is a line between "impossible" and "give me 5 minutes", and if it comes down to it, you can only cross it with comments. But there's even more to it: if you are used to attach a comment to each of your functions, you are forced to think about what you did and how/why you did it. I've found more errors in my own code by writing comments than by testing/debugging. Which leads directly to my next point: 2. THINK BEFORE YOU WRITE A common mistake among beginners is to blindly start typing characters in their text files and then wonder why the compiler/machine has a different opinion about the code's semantics. In the traditional waterfall model of software development, the time spent on actually producing the code is about 10-20% of the overall development time. The rest is thinking (>70%) and fixing errors (10% to 20 years). At university, we had to develop a small game (actually, a 3D-, networked, multiplayer game). We spent about 4 weeks thinking about the design, layout, necessary methods, classes and their relationships (yes, we were using C++), and when we were ready, it took us about 4 days to implement it in 20.000 lines of code. By then, we were all complete beginners at C++. When was the last time you wrote 20.000 lines of code from scratch nearly error-free in 4 days? So, don't listen to people telling you to not invest further thinking in your own code. Use your head. Gets you ahead. Greets, Philip | |
| Snafuist is offline | |
| | #28 |
| Registered User Join Date: Feb 2009
Posts: 278
| Amen. And a program doesn't need to be 10,000 lines before it gets confusing if you don't document/comment. A program of just a couple hundred lines can be confusing. Especially to someone else or to you a couple weeks after you write it. |
| Bladactania is offline | |
| | #29 |
| Registered User Join Date: Mar 2009
Posts: 48
| A good tutorial for me. I just read the white bible (K & R) in this morning. there is no "ctype.h" inclued at the book smaple code. :-)
__________________ -------------------------------------------------------- Newbie C/C#/C++ swimming/cycling/running There is nothing more powerful than an idea. Except for an idea put into action. -------------------------------------------------------- Last edited by userpingz; 05-29-2009 at 07:14 AM. |
| userpingz is offline | |
| | #30 |
| Registered User Join Date: Jun 2009 Location: US of A
Posts: 300
| Simply fantastic !!!!! I always used to wonder how those big lines of codes are written but now i know the secret too !!!!!!! Thanks a lot |
| roaan is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| init adopts zombie process? | password636 | Linux Programming | 4 | 07-01-2009 10:05 AM |
| How can you make a parent process wait for a child? I'm gettin a seg fault. | mr_coffee | C Programming | 3 | 10-15-2008 09:24 AM |
| Problem with forking a process | Unitedroad | C Programming | 10 | 10-04-2007 01:43 AM |
| process programming | St0rM-MaN | Linux Programming | 2 | 09-15-2007 07:53 AM |
| Happiest moment during development process.... | Nutshell | A Brief History of Cprogramming.com | 16 | 04-02-2002 11:40 AM |