94

A Little Background

I'm 28 today, and I've never had any formal training in software development, but I do have two higher education degrees equivalent to a B.A in Public Relations and an Executive MBA focused on Project Management. I've worked on those fields for about 6 years total an then, 2,5 years ago I quit/lost my job and decided to shift directions.

After a month thinking things through I decided to start freelancing developing small websites in WordPress. I self-learned my way into it and today I can say I run a humble but successful career developing themes and plugins from scratch for my clients - mostly agencies outsourcing some of their dev work for medium/large websites.

But sometimes I just feel that not having studied enough math, or not having a formal understanding of things really holds me behind when I have to compete or work with more experienced developers. I'm constantly looking for ways to learn more but I seem to lack the basics.

Unfortunately, spending 4 more years in Computer Science is not an option right now, so I'm trying to learn all I can from books and online resources. This method is never going to have NASA employ me but I really don't care right now. My goal is to first pass the bar and to be able to call myself a real programmer.

I'm currently spending my spare time studying Java For Programmers (to get a hold on a language everyone says is difficult/demanding), reading excerpts of Code Complete (to get hold of best practices) and also Code: The Hidden Language of Computer Hardware and Software (to grasp the inner workings of computers).

TL;DR

So, my current situation is this: I'm basically capable of writing any complete system in PHP (with the help of Google and a few books), integrating Ajax, SQL and whatnot, and maybe a little slower than an experienced dev would expect due to all the research involved.

But I was stranded yesterday trying to figure out (not Google) a solution for the FizzBuzz test because I didn't have the if($n1 % $n2 == 0) method modulus operator memorized.

What would you suggest as a good way to solve this dilemma? What subjects/books should I study that would get me solving problems faster and maybe more "in a programmers way"?

EDIT - Seems that there was some confusion about what did I not know to solve FizzBuzz.

Maybe I didn't express myself right: I knew the steps needed to solve the problem. What I didn't memorize was the modulus operator. The problem was in transposing basic math to the program, not in knowing basic math.

I took the test for fun, after reading about it on Coding Horror. I just decided it was a good base-comparison line between me and formally-trained devs.

I just used this as an example of how not having dealt with math in a computer environment before makes me lose time looking up basic things like modulus operators to be able to solve simple problems.

ChrisF
  • 38,878
  • 11
  • 125
  • 168
moraleida
  • 939
  • 2
  • 7
  • 9
  • 63
    When I read this: `I'm basically capable of writing any complete system in PHP (with the help of Google and a few books)` and combine this with you not knowing `if($n1 % $n2 == 0)`, I wonder about the exposure you've had to things written in PHP. I think most things you do go beyond a simple modulo calculation. Could you give some more insight into what you think you are able to do? – phant0m Jun 13 '12 at 16:33
  • I meant I'm able to work my way around solving any problems however slowly. I knew which structure the answer should have and I had used modulus calculation before, referenced from the php manual on a 30s google search, but not enough times to memorize its syntax. – moraleida Jun 13 '12 at 16:43
  • "Code: The Hidden Language [...]" is one of the best books I have ever read. – fredoverflow Jun 13 '12 at 16:59
  • 2
    Hmm, you seem pretty up to speed. Just continually improve, [realizing this takes time](http://norvig.com/21-days.html), and learn good [problem solving](http://programmers.stackexchange.com/a/115334/27114). – Spencer Rathbun Jun 13 '12 at 17:25
  • 10
    I'm also a self taught programmer.. been at it over 10 years now, all web, all the time.. back then there were no web development classes... i think there's some benefit to learning on your own. you're really going to want to learn about the fundamental OO principles and design patterns. they'll help you out a lot having them in the back of your head when attacking problems.. I generally find that I dont always have the vocab that others have, but if you enjoy coding, and enjoy writing elegant solutions, then eventually you'll be able to code your way into whatever you want – hanzolo Jun 13 '12 at 17:30
  • 56
    Relating to the `stuck b/c I didn't memorize %` issue, it's worth noting that there are other ways to do this: (assuming $n2 != 0) `if (is_int ($n1 / $n2))` or `if (($n1 / $n2) == (int) ($n1 / $n2))` Knowing keywords is one thing, and knowing how to express the underlying ideas in the absence of a built-in solution is another. – grossvogel Jun 13 '12 at 18:01
  • 4
    I'd like to throw a slightly different suggestion at you here. Reading programming books isn't necessarily the answer, instead try reading books like [this](http://www.amazon.co.uk/Critical-Reasoning-A-Practical-Introduction/dp/0415445876/ref=pd_sim_b_4). Any good programmer needs highly developed skills in critical thinking. Think outside the box - programming books don't contain everything you need to learn to be a good programmer :) – MattDavey Jun 13 '12 at 18:08
  • 18
    @grossvogel Exactly! One of the reasons people like Fizzbuzz is that there are so _many_ ways to solve it. It's not just a trick to see if you know the modulus operator. One key programming skill is the ability to translate a problem from the form in which it's stated into the form that's best for your knowledge / tools / resources / etc. – octern Jun 13 '12 at 19:00
  • 18
    Not knowing the modulus operator is not a reason to fail FizzBuzz. When you find something missing you have to be able to work around it. – Loren Pechtel Jun 13 '12 at 20:35
  • 1
    I encounter little gotcha's every day. If you're learning a new language, you just have to be able to Google well. There's no short-and-easy way of transposing math perfectly to a language. You have to follow its rules (and with programming languages you have so much less to learn than a regular one like German!). – Caleb Jares Jun 13 '12 at 21:12
  • 5
    PHP is [a horrible programming language](http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/) and you should not try to learn programming by using PHP. Learn Java, and learn programming by coding in Java, because it was specifically designed to be easy to learn and hard to screw up. It also forces you into many helpful programming patterns that are important to learn even if they can be tedious at times. There is also a ton of example code, tutorials, and other instruction in Java freely available. – Old Pro Jun 14 '12 at 05:04
  • 1
    @moraleida You can enroll and learn in online courses such as coursera https://www.coursera.org/ or Udacity http://www.udacity.com/. Since you are a self-learner, these courses would definitely take you to the next level – Ubermensch Jun 14 '12 at 06:11
  • Also, as Old Pro switch to an other language such as Python or Haskell (or any other, these two are my preferences and are poles apart and getting over them would just expand your knowledge a lot) . PHP is mostly for designing website front-ends – Ubermensch Jun 14 '12 at 06:16
  • 8
    "I'm 28 today, and I've never had any formal training in medicine, but I do have two higher education degrees equivalent to a B.A in Public Relations and an Executive MBA focused on Project Management. After a month thinking things through I decided to start freelancing prescribing paracetamol for headaches. [...] So, my current situation is this: I'm basically capable of performing surgery (with the help of Google and a few books)... But I was stranded yesterday trying to figure out (not Google) a solution for a case because I didn't have memorized difference between lungs and stomach." – vartec Jun 15 '12 at 12:06
  • @vartec I'd say comparing any prfessional field to medicine and surgery is the academic equivalent of Godwin's Law. You won, here's your badge. – moraleida Jun 15 '12 at 12:31
  • 3
    @moraleida: right, plumbing it the correct comparison :-P http://www.codinghorror.com/blog/2012/05/please-dont-learn-to-code.html – vartec Jun 15 '12 at 13:51
  • @vartec I'll take it that your're just being ironic. If I was in this for the money/hype I could just as easily have kept to the executive career which indeed paid much better and with less effort. :) – moraleida Jun 15 '12 at 14:07
  • 2
    I can do more: "Unfortunately, spending 6 more years in med school is not an option right now, so I'm trying to learn all I can from books and online resources. This method is never going to have CDC employ me but I really don't care right now. My goal is to first pass the bar and to be able to call myself a real M.D." :-P – vartec Jun 15 '12 at 14:39
  • I interview people, and I ask similar questions. I've had people come in who didn't know the modulus operator. The good ones wrote the loops, called a IsDivisibleByThree(int n) method, then tried to write that seperately. Some came up with a working solution without it. I'd then show them mod, see if they can use it. Points being, A) there's more than one way to skin a cat, B) If you're practicing, not knowing the answers teaches you more, so that's okay, C) When it counts, solve the problem be any means neccessary. – TarkaDaal Jul 19 '12 at 14:59

14 Answers14

144

In your case, as you're self-taught and already have what seems to be a good, healthy and no-BS approach to learning. Still some suggestions...

Practice Makes Perfect

I think you should dive into progamming exercises, like the:

Even grab the past exam questions of known universities around you, or of local (or remote) programming competitions. For example, we have a nice one in France for aspiring high-school programmers is called Prologin, and it does provide every year a good series of head-scratching puzzles (probably French only though, sorry, but that's the sort of things I mean).

For more: Where Can I Find Programming Puzzles and Challenges?

Classic Books and References

We could also recommend a very long list of amazing books, but I'd say the Zen answer is that there's no single right way to Enlightenment.

It would be hard to tell you which ones are top of the list. So keep reading a ton of stuff to learn general pitfalls to avoid and best practices to follow, as you are correctly doing now.

For more:

Pushing the Limits

Also, look for head-scratching material, like:

Not necessarily to be taken as an example of things to do nowadays, but worth trying to figure out what the hell is happening in there.

Peer Systems are Motivational

You may also want to lurk around (and get involved in) the following communities to improve your skills incrementally by being confronted to others.

Part-Time Education

If you don't have the time or motivation to engage in another 4 year course or something similar (which may not even be necessary or rewarding anyways, and expensive), you could consider looking for teaching material online. Of course, these are not limited to computer science.

Thanks to the original MIT OpenCourseWare effort, there are now tons of universities that followed suit, and you can find a lot of university-level course material for free. It's not always easy to navigate and read through it on your own, but some are pretty well done. To start from the ground up and go pretty high up, consider also looking at the Khan Academy.

Some go a bit further, and offer real online-courses for free, where you similarly have access to the course's material, but where they also provide paced lectures and regular self-assessments. For instance, visit Coursera or Udacity.

Most of the above often publish their lectures on Youtube or iTunesU, so you'll find plenty of material if your thirst for knowledge wasn't already quenched by all the previous links.

If you want something that provides a closer experience to the "real" university, you can consider remote universities, which also allow you to work part-time, but require you to follow the pace, and to have both self-assessments and end of year exams (sometimes on-site), like with the OpenUniversity and its international variants.

Passion Keeps You Going

  • Find a pet project: create your own or join one or more existing software projects and contribute.
  • Code, code, code. And then code some more.

(and get enough eyeballs looking at your code to criticize you and hqve different perspectives)

The French say:

C'est en forgeant que l'on devient forgeron.

Keep doing what you're doing, and eventually you'll be an expert. Takes time and work.

See also I'm Having Trouble Learning for more suggestions.


PS: Though it's a very controversial tool for interviews, and doesn't help to identify good candidates, I do often use FizzBuzz to at least weed out the incredibly "bad ones". So get crankin' on this practicing thing! :)

haylem
  • 28,856
  • 10
  • 103
  • 119
  • 3
    C'est super ça! :) Thanks for the list. Project Euler and the puzzles seem very nice. And I already use some other SE sites. Will dive into it. – moraleida Jun 13 '12 at 17:09
  • @moraleida: Glad you liked the answer. You're welcome. – haylem Jun 13 '12 at 17:15
  • About your PS: I'm not really worried about interviews right now, as I really don't want to go back to being an employee. I took the test for fun, after reading about it on Coding Horror. I just decided it was a good base-comparison line between me and formally-trained devs. :) – moraleida Jun 13 '12 at 17:22
  • 4
    +1 just for _why_ FizzBuzz is used right at the end... Too often I see comments here or on blogs about people criticizing it because they assume companies are using it to identify super-coders. (To those companies: You're doing it wrong!) – Izkata Jun 13 '12 at 18:06
  • 1
    This is listed on some of the links, but I feel it warrants a call-out: I would also look around http://rosettacode.org. It has a large number of different problems solved in a large number of programming languages. It's good practice in reading code, which is as important as writing it, as well as a great way to see lots of different approaches to solving the same problem. And if you find a problem that's not yet solved in a language you know or want to learn, that's a programming challenge for you right there. – Mark Reed Jun 13 '12 at 22:28
  • Only perfect practice makes perfect. – Pieter B Jun 14 '12 at 06:40
  • This answer is awesome. Just the kind of motivation a programmer needs. – JJ_Jason Jun 14 '12 at 09:18
  • @PieterB: Yes and no. You can't start by doing perfect practice, and you may not have the luxury to have the perfect practice. As you refine your skills with imperfect practice, you also refine your own training process. The importance is to keep an open mind, and to be open to criticism from others, and to stay critical and analytical yourself. You can't always know for a fact that the others are right in their criticism, so you need to assess everything yourself. If there was such a thing as a perfect practice, it would mean we're in a dead field where there's no more evolution. – haylem Jun 14 '12 at 10:07
  • @haylem What I mean is with getting the right practice is that if you practice enough but with bad habits you get very good at doing it wrong. Without getting solid background you're going to hit that brick wall sooner or later. – Pieter B Jun 14 '12 at 11:55
  • @PieterB: I assumed that's what you meant, so I fixed it by saying exactly that: you can only get this solid background if you can validate it as being solid and making sure your practice aims you towards the right direction. – haylem Jun 14 '12 at 12:25
  • @Dynamic: "practising" is the correct spelling in British English. My partner and co-workers scream bloody murder at me every time I use the US one. Same with "apoligize" for "apologise". Seems like they're finally getting through to me :) – haylem Jun 16 '12 at 12:52
  • @haylem Sorry about that. – Dynamic Jun 16 '12 at 12:58
  • @Dynamic: no no, no pb, I left the edit in as I'd have normally used your spelling myself. Was actually surprised I used the B.E. one! But just wanted to point it out in case you'd be (like I was) unaware of this if you are non-English native. Didn't mean to tell you off. – haylem Jun 16 '12 at 20:38
  • +1, great answer. However, I'd have one addendum to add to your general point about keeping reading: maybe don't just focus on reading particular books, papers, blogs. I find I learn quite a lot by following other developers on twitter and reading the related links they post. You don't necessarily have to actively engage that knowledge, but if you're interested and you read it, it'll probably sneak in and you'll find it useful in the future. I find places like http://www.asp.net post useful pieces too; I'm sure there are places like that for other tool sets. – Andy Hunt Jul 02 '12 at 09:30
  • @AndyBursh: thanks, glad you like it. I agree that following "thinkers", "power readers" or some industry "giants" is a great idea. However I'd advise caution: it's easy to then develop a feeling of trust, which can be unwarranted, and let your guard down and see things the way they do too easily. Diversification is key to keep it at a critical thinking level and not sink into fan-dom. But indeed, it keeps you on your toes and acts a very regular refresher when things fall in your feed-reader (same as with lurking arounde SO and P.SE, actually ;) ) – haylem Jul 02 '12 at 09:36
  • @haylem Oh of course! Don't let yourself sink in to that state. I find the best way to avoid that whilst still benefiting is to follow as many as possible, from as many areas as possible. That way, you get the broadest range of views. – Andy Hunt Jul 02 '12 at 09:39
60
I didn't have the if($n1 % $n2 == 0) method memorized.

I haven't been coding for very long (started teaching myself SQL about 27 months ago and started coding in Perl about 20 months ago), but the quote above sounds like some things that I've heard from former students:

How am I supposed to memorize which integration technique to use for every problem?

I didn't memorize whether I should add or multiply probabilities, or use "n choose k" or use factorials.

Wait a minute! You said that x equaled 2 yesterday! Now it equals zero?!

Okay, that last one was probably a bit harsh...but the point I'm trying to make is that problem solving is not memorization. If it was, then some genius could program a computer to solve every problem, and none of us would ever have to think again (what a hellish world that would be...).

Now, it is true that any intellectual endeavor consists of at least a little bit of memorization. In particular, if you're going to code in PHP, then you should understand the basic data types (numbers, strings, arrays), basic things that you can do with them (for numbers: addition, subtraction, multiplication, division, and modulus; for strings: concatenation, substrings, replacement, and at least some knowledge of regular expressions; for arrays: concatenation, tacking on elements, splicing out elements, looping, counting elements, etc), and the basic logical structures that one can use (if/then/else statements, foreach loops, while loops, etc).

Then, when you encounter a problem, use the problem to provide the context for what tools you need. For FizzBuzz, you need to tell when a number is divisible by 3, 5, or 15. Okay, so we're dealing with numbers....what basic tools allow us to tell when one integer is divisible by another? Well, the modulus operator. So, use that. (Of course, if your number is $n, you could be fancy and see if the last digit of $n is 0 or 5, and/or if the digits of $n add up to something divisible by 3, but I digress...) You need to do this for each number between 1 and 100, so to avoid getting carpel tunnel, use a foreach loop.

The morale of the story is that if on one hand you say "I'm basically capable of writing any complete system in PHP" and on the other hand you can't code FizzBuzz, then the first assertion is incorrect. Some of my former calculus students swore up and down that they understood the concepts, but they just couldn't do the problems on the exam...or the homework problems...or the quiz problems. They were wrong about their understanding as well.

Stop making excuses and learn the basics.

  • 6
    I don't memorize, I metabolize and make these things a part of my intuition. Always seek to expand that. – ncmathsadist Jun 14 '12 at 00:28
  • @ncmathsadist - Yes, expanding intuition is key, but even intuition has to rely upon the memorization of a small number of very basic concepts and facts. –  Jun 14 '12 at 00:42
  • for the record, you dont have to multiply a number by 3 and then add the digits to see if its divisible by 3, you can just add the numbers. for example, 864, 8+6+4=18 which is divisible by 3 and so is 864 – Oztaco Jun 14 '12 at 22:14
  • @leaf68 - Duh! [slaps forehead] you're absolutely correct...lemme edit! –  Jun 14 '12 at 22:20
27

You may think FizzBuzz is a toy problem; when will I ever need to use the modulus operator in a real program. But really you use it all the time. Three common examples:

  1. You are displaying a table and you want alternating background colors for different rows. You check if a row is even (row_number % 2 == 0) and display one color for even rows and one for odd rows.
  2. You have a collection of objects that you are looping through and you want to print out a table with N objects per row; then the criterion for when to add a line break is (item_number % N == 0). I actually had a SO question on this exact behavior though in that templating language the condition if item_number % N == 0 was written as the equivalent (if item_number|divisbleby: N).
  3. You are doing several operations that you want to group into a transaction that only gets committed when the group gets to a certain size for efficiency reasons. Maybe you are using the google data API and you don't want the HTTP header/authentication overhead for creating a new transaction for each operation, so you are batching them together into groups of 50 operations. Or you are saving records to your database and want to commit the transaction when its a reasonable size. Something like if cur_item_number % 50 == 0 then commit_data.

Sure there are other ways of doing all these things. But you can do fizz buzz without using the modulus operator or comparing float division to integer division. For example, for FizzBuzz you could do something like the following pseudo-code.

div_by_3_rem = 0
div_by_5_rem = 0
for(i = 0; i< 50; i++) {
    if(div_by_3_rem == 0 && div_by_5_rem == 0) {
       print "FizzBuzz"
    } elif(div_by_3_rem == 0) {
       print "Fizz"
    } elif(div_by_5_rem == 0) {
       print "Buzz"
    } else {
       print i
    }
    div_by_3_rem += 1
    div_by_5_rem += 1
    if(div_by_3_rem == 3) {
       div_by_3_rem = 0
    }
    if(div_by_5_rem == 5) {
       div_by_5_rem = 0
    }
}

To conclude, if you want to be a great programmer someday, don't jump into learn a language books. Yes, a PHP/Java book will have you getting answers from google/stackoverflow and half-working programs much faster than anything else. But to actually be able to know how to write quality optimal programs and think like a programmer you need some exposure to a real CS books.

Start with a CS book that introduces a programming language and the CS background, with the famous example of Structure and Interpretation of Computer Programs (which will teach Scheme -- a Lisp dialect) or possibly something else like Think Python How to Think Like a Computer Scientist (which I have not read). Both of these are free online.

You need to eventually read a good algorithms book, the best being CLRS's Algorithms (not free), though this free online algorithms book could be a low-cost replacement (though if you can just buy CLRS). The algorithms book will teach you how to think solve computer problems and introduce you to a variety of data structures (Arrays/Linked Lists/Heaps/Binary Trees/B-Trees/HashTables) and important algorithms that you need to know how to use optimally. You don't need to memorize every proof or know how to perfectly write every algorithm (who ever uses a Fibonacci Heap); but you should intuitively know two nested for loop is O(N^2); comparison sorts are at best O(N lg N), binary search is O(lg N), can find median in O(N), why hard disk databases use B-Trees, etc.). At a minimum, strong knowledge of the algorithms book will help you ace technical programming interviews of the google/facebook variety. When reading programming books, don't just skim/read; you'll learn much better if you work/code through examples and problems, and actively think through the logic.

I'd also recommend a book on software engineering (either Code Complete or Pragmatic Programmer) after you get through the CS and algorithms book, which will teach best practices of how to write good code that is maintainable (clear names; comment just when necessary; keep code together; refactor when necessary; use version control; etc).

dr jimbob
  • 2,071
  • 1
  • 15
  • 17
  • 4
    Best comment yet; while I see a lot of people saying practice, practice, practice, that's not the way to go. Practice makes perfect they say but that only enforces bad behaviours. To the OP: Expose yourself to other concepts, learn why a quicksort is prefered over a bubblesort. Only perfect practice makes perfect. Get that CS course. – Pieter B Jun 14 '12 at 06:37
  • 2
    Thank you for posting that example code, I already thought I would have to do it myself. – We can build any complex logical circuit using NAND gates alone; we have languages with very few simple operations that are Turing complete; we don’t *need* those fancy operators to solve problems. Solving a problem is not just Knowing the right tools, being able to work on a problem, figuring out a solution that works for your own knowledge is what makes a programmer. – poke Jun 14 '12 at 08:21
22

But I was stranded yesterday trying to figure out (not google) a solution for the FizzBuzz test because I didn't have the if($n1 % $n2 == 0) method memorized.

Nobody memorizes that thing. You're supposed to come up with it on your own. If you know the modulus operator and you know what it does, then it's trivially a great fit to the FizzBuzz problem.

I'm going to go out on a limb here and generally suggest that the problem is PHP. I like to say that Java is the worst language ever designed, and PHP is the worst language ever, because even its creators admit that it was never designed. It's hard to learn good software engineering practices when your environment is practically the definition of how not to do it. And depending on a framework to get everything done is not saying much.

I'm currently spend my spare time studying Java For Programmers (to get a hold on a language everyone says is difficult/demanding)

Java is one of the easiest and worst languages in existence. It only has one thing: garbage-collected manual inheritance. If your friends or advisors say that Java is hard, then find new friends. C++ is a difficult language that includes a lot of concepts, and that nobody will dispute. You could also do C#, which at least has some generics and lambdas.

How are you going to learn to code, when your languages were designed and implemented by people who can't code, and you depend on frameworks for everything that you do?

Old Pro
  • 793
  • 6
  • 11
DeadMG
  • 36,794
  • 8
  • 70
  • 139
  • Maybe i didn't express myself right. I knew the steps needed to solve the problem. What I didn't memorize was the modulus operator. The problem was in transposing basic math to the program, not in knowing basic math. Unfortunately PHP is what I have right now, and it's what pays my lunch so I can't ditch it, as problematic as that might be. But I'll look deeper into C++/C# for sure. – moraleida Jun 13 '12 at 17:33
  • 14
    @moraleida: There's no shame in looking up the syntax for an operator you've not had cause to use. – DeadMG Jun 13 '12 at 17:57
  • I know, and it's what I do day in and day out. I just used this as an example of how not having dealt with math in a computer environment before makes me lose time looking up basic things like modulus operators to be able to solve simple problems. – moraleida Jun 13 '12 at 18:01
  • 2
    @moraleida: in that case I agree there's no real problem. I don't think any professional, interviewer or otherwise, should mind if you can't put your finger on the exact syntax for a different language, as long as you can clearly express what your intent is. – haylem Jun 13 '12 at 18:11
  • 5
    Agreed on most points, but why do you consider Java 'the worst language ever designed'? I'm not a big fan of Java, but this sounds very opinionated. – Casey Kuball Jun 13 '12 at 19:26
  • 7
    -1 for using the question as an excuse to knee-jerk bash PHP when it has zero relation to what was asked. – StasM Jun 14 '12 at 00:29
  • The implementation (via type erasure) is lacking compared for ex. to C#, but Java has /some/ generics. – Francesco De Vittori Jun 14 '12 at 06:54
  • 1
    @Darthfett: I could write an essay on that. Come to the SO C++ chat and you can read it :P – DeadMG Jun 14 '12 at 10:55
11

I think you have to take a hard look on why you were stranded trying to figure out FizzBuzz. So, suppose, you remembered there's an operator that given $n tell you if it's divisible by an number. And you have bad luck to forget what it is. Fine, why don't you proceed to trying to do it in any other way? If you know anything about code, you should be able to find a dozen other ways of doing it. Some of them may look weird - like, for example, putting every multiple of 5 in an array and then checking if $n is among them - and it is a bad solution, but it still would be a solution. However, you're saying you didn't have any, you just were stuck. It may be a symptom of a bigger issue.

There's two things in programming that you need to learn.

  1. Bag of tricks. How to read file in PHP, how to parse XML in Java, how to connect to database in Python. Some people memorize it, but in fact these things are worth memorizing only if you use them every day. Otherwise, you just go to the docs and look it up. These things do not have any substance except for their literal form - you just need to know how the particular magic incantation sounds and what the result will be.
  2. Mindset. This is the most important thing. This is how you program, and this has nothing to do with memorization. You need to understand how to explain things you want done to the computer, which ways there are for doing it and which of them to use in any particular case. Now, given modern tools and modern documentation, it is plausible that one could write an entire CMS in PHP using "bag of tricks" approach, but once you encounter a task that has no ready-made solution, you're "stuck".

From you description looks like you started with the first part, but somewhat lacking on the second part. Good CS course usually helps with that a lot, but is not the only way. Trying to solve different problems and read about how these problems need to be solved, reading fundamental books quoted here - all that would help. Once you got the programmer's mindset, you'll discover that getting into using a new bag of tricks won't be much of a problem. You'd have to google here and there, of course, but you will never be stranded.

StasM
  • 3,377
  • 2
  • 23
  • 28
  • 1
    *“and read about how these problems need to be solved”* – In fact, look at different solutions for the same problem. Try to understand each of them, compare what they have in common and what they do differently. Understand those things and you’ll automatically pick up different ways of thinking around the same problem. – poke Jun 14 '12 at 08:27
  • I would agree completely on mindset. Once you grasp the mindset and the concepts, learning the underlying language constructs are much easier, and you will start thinking of alternative ways to do things as a matter of course. (Such as for fizzbuzz, all numbers divisible by 5 will end in either 5 or 0, so no need for the modulus operand on that portion) – JohnP Jul 05 '12 at 15:51
9

You get good at development the way you get good at anything else: practice. There is a nice concept in the programming world called the code kata. This is essentially an exercise where you code a solution to a relatively small problem, analyze what's good and what's bad, scrap it all, and do it again. FizBuzz is a kata in its own right. So, do it, and do more. When you find things that don't seem to be very good or just don't work, do research and be thorough about it. Ask questions on Q&A sites, read articles and blogs, see how others handle this, and then practice what you've learned.

In the course of doing this practice, you'll learn how much additional mathematical/theoretical background you might need. If you bump into concepts that you just can't wrap your head around, then read about them and their prerequisite knowledge and decide on a case by case basis if you want to take a course or what-have-you in order to expand your theoretical background.

Erik Dietrich
  • 5,605
  • 4
  • 30
  • 34
8

... because I didn't have the if($n1 % $n2 == 0) method memorized.

I'm interpreting that to mean, you didn't know about and/or didn't remember the modulus operator. If this is the case, the place to start is to review the language constructs in the language you are using. Review anything which you don't 'know cold', and learn anything you just don't know.

John MacIntyre
  • 5,748
  • 4
  • 33
  • 48
  • 4
    +1. While the other answers talk about how to become a better craftsman, it's possibly even more important to know which tools actually exist. Ever try to remove a broken screw without an [easy out](https://en.wikipedia.org/wiki/Screw_extractor)? There are other ways to go about it, but it's a forehead-slapper when you finally learn the tool that's made for it. I'd say the OP should've perused any [list of PHP operators](http://www.w3schools.com/php/php_operators.asp) long ago and played around with the ones that were unfamiliar. – Tim Lehner Jun 13 '12 at 20:48
5

Keep coding, keep learning. Eventually, with enough dedication, you'll look at FizzBuzz and wonder why you even had to think about it. Lots of companies do a FizzBuzz-style question as a very early part of their interviews, so failing this one time means you've at least learned something about the hiring process.

Just keep writing code, coming up with project ideas, and researching.

joshin4colours
  • 3,678
  • 1
  • 24
  • 37
4

May I recommend learning JavaScript before Java, C++? Reasons for you:

  1. Used in front-end design (jQuery, some of your WordPress plugins, Twitter feeds, loading databases into your browser via JSON with little to no back-end work, form validation, etc)
  2. Can be used server-side via Node.js
  3. Can be used to build hybrid apps for iOS, Android, Win8, etc
  4. Studying JS will help you understand webpage performance in different browsers & devices better
  5. JS was designed to be more newbie friendly
  6. You already know HTML & CSS (I hope ;), so that helps with JS

Free Newbie Resources

http://www.codecademy.com/tracks/code-year
https://stackoverflow.com/tags/javascript/info
I had about 10 more links, but SE won't let me post them until I hit 10 rep.

Learning C++, Java, etc are also helpful, but not IMHO does not have the over all impact on web programming as JS does, since you can use it on both front & back end. Have fun!

tomByrer
  • 161
  • 2
  • http://tutsplus.com/course/30-days-to-learn-jquery/ ###Advanced & Free Deep Learning http://thinkvitamin.com/code/tips-on-learning-javascript/ http://www.netmagazine.com/tag/javascript?ct=tutorial http://blog.boyet.com/blog/javascriptlessons/ http://www.nczonline.net/blog/tag/javascript/ http://javascriptweekly.com/ http://jsperf.com/popular I'm sure you know about SitePoint etc ###Pay to learn http://shop.oreilly.com/product/0636920023982.do "JavaScript for PHP Developers" ;) http://teamtreehouse.com/library/search?q=javascript – tomByrer Jun 14 '12 at 05:09
  • 1
    and when you're ready to get a job: http://jobety.com – imns Dec 15 '13 at 23:33
3

You could find and help others e.g. giving.code (disclosure: my site) or Code for America or whatever. This is an excellent way to get more exposure to non-PHP-web-page-making problems and feeling good too.

When you have a problem to solve - or help solve, or just understand - the picking up the code comes naturally along the way. Having a goal is the best way to learn something.

Will
  • 183
  • 1
  • 10
0

So you couldn't solve the FizzBuzz problem. Big deal. Now you can, and I bet you'll never forget all the myriad ways how. Try not to be so eager to brand yourself a bad programmer simply because you couldn't solve one stupid problem off the top of your head.

That's one issue. The other is that you seem to feel a bit behind the programming learning curve. As others have said, keep coding and keep reading. The more you do, the better you'll get. It's as simple as that. Start with whatever you feel is the biggest hole in your background and proceed from there.

Nick Spreitzer
  • 647
  • 3
  • 9
0

I don't think I'd refuse to recommend someone for hire because they did not know it was the modulus operator provided that:

  1. They knew that it was an operator of some sort.
  2. They could tell me what "modulus" was once I prompted them.

It's not always (though usually) %, and some languages are weird. And hell, after a decade I can't honestly say that I know all of the perl operators (and what's the spaceship one do again?) nor can I always remember the bitwise operators perfectly. It's been a few years since I did anything that would even require those.

What might make me hesitate to recommend someone would be if it caused them to have some panic attack over missing that question/test. That might give me the impression they were a little too green (unless it was a very entry level position). No one needs someone who does (or feels the need to) memorize those things. You need someone who understands far broader concepts. No one's going to care if you look that up on google, but you'll have to be confident in the interview that knowing % was no big deal and also that you know to use "operator" as a keyword when you do a quick google search.

Also, this is just an idea... but if your local community college has a compsci program, your other credits would all transfer, and you'd likely only need about 20 credits for the 2 year degree. Could almost finish that in a semester. They'd have you do a data structures course, also hopefully algorithms... might make you a bit stronger.

John O
  • 109
  • 2
-1

Here's a sample course: http://www.ox.ac.uk/admissions/undergraduate_courses/courses/computer_science/computer_science_.html

I suggest read up on the following first: Object-oriented programming (very common, used everwhere, this is where java comes in) Concurrency (to write java programs that don't crash mysteriously in the real world, learn about deadlocks) Database concepts ( most applications need to save data, theory is important here) Programming paradigms (read about at least one non oops language, preferably functional, to expand your thinking and learn new stuff)

When I look at the 4 years of comp science education, to be honest I think there's only a handful of courses that you need to take seriously.

Data structures and algorithms (and you need math here to get really good and be taken seriously by other programmers), computer networking and operating systems come to mind as the most important. Other subjects that deal with lower level code, like being able to code in assembly are arguably not so important for you. Software engineering and testing expose you to concepts that are useful and you can pick that up with time.

Just download a pdf that explains these concepts in an intuitive way and you'll be on your way.

In some comp science courses, at least in mine, the first year is an introduction to all fields of engineering, like mechanical, electrical, civil, etc. There is lots of complicated math, mind you, which again may or may not be relevant for most application programmers today. So, many of the engineers around today actually have only 3 years of real comp science education (Hope this makes you feel better :)

Crux of the answer: you can take some time to study everyday, say an hour or so, and over a period of time become a pretty good programmer. Just keep learning. And remember to write some code everyday.

-3

For me, my strategy is that I only attack the problem that is relevant to what I'm working, So my advice is that you don't have to learn it all, just read those things that are relevant to what you are working, because if you tried to learn it all at once then there is a tendency that you get prostrated and end up hating programming.

Peace