<p>Hey guys, I'm a EE major and while I'm not swtching majors, I have to take some CS classes and I like CS. I don't get frustrated at staring at code for a long time and I really like how CS enables you to create amazing things. I can read a CS book and watch tutorials and understand the concepts, but here is the problem, my logical thinking and programming techniques. Whereas some of my friends can get their programs done in X amount of things, I often have to take 2 or 3 times that amout of time.For example, I've had a total of 16 hours of sleep the past four days working on a project that didn't even work in the end. Often I the code I write is buggy, and I have to write snippets and debug and write in more snippets. I can almost never write a huge block of code and am confident that it's logically correct with minor bugs. How can I change this? Can you suggest some resources (books/websites)? or should I just practice more? I don't think practice is that effective when you use the same flawed techniques and thinking that you're used to. And last of all is this something that innate that I just can't change? Some of my friends have the it factor and they get it. I don't. I need to figure out a solution now. Thank you.</p>
<p>First thing, master the fundamentals. What I mean by this is fully understand what different data types are, what methods and their parameters are, etc. This may sound trivial but I failed intro to programming (C++) twice, left that school and started from scratch at the local community college. Once I understood the fundamentals at the CC I started to really understand programming and it took off from there. </p>
<p>When you start on your programming projects do you put any thought into them or do you just start coding? Do you sketch the logic out, i.e. flow charts, user cases, etc.? A coding project is just like a circuit project, you need to apply your critical thinking and logic skills to the problem. </p>
<p>When you look at books and websites pay attention to how they accomplished the different tasks in the code. Question why they did it that way, are there advantages/disadvantages, does the logic make sense, etc. </p>
<p>As a resource, I enjoy Code Project. Most of the projects are detailed and have source code to accompany them. Plus, you can ask the author of the projects questions.</p>
<p>It is just a matter of experience; I often out perform everyone in my class because I simply have years more experience over my class mates. Also, SLEEP. Honestly, even though I have years of experience, just the lack of sleep can really mess with you. One night, I literally wrote an algorithm that took up 200+ lines of code, but after a good night sleep, all I could do was face palm myself… I wrote the same algorithm in like 25 lines of code that morning.</p>
<p>If you usually do top-down programming, try bottom-up. That is, decompose your program into small classes/functions. Test all of those thoroughly and then put them together.</p>
<p>Really, it sounds like you might be going about this completely the wrong way. Before you write a single line of code, you should have a very clear understanding of how you’re going to solve the whole thing: architecture, algorithms, etc. Put this on paper. If when you begin to write a piece of code you need to ask yourself where to get started or how to make it work, save everything, go take a nap, and then go back and repair your unfinished design.</p>
<p>Implement incrementally. I’m not a particularly big fan of test driven design, but it does force very incremental implementation and can give you lots of confidence that your parts work in isolation. Even better is to know that your code is going to work before you write it; then, when it doesn’t, it should be easy to tell why it’s not.</p>
<p>Thanks for the responses.</p>