Help For The Copy & Paste Generation Of Coders [closed] - php

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I myself am one of these types of coders, who never learned coding in a formal setting, but am instead, self-taught by the use of copy and paste scripts, and pre-authored works available through GPL projects and premium software's(which is often the way commerical script companies show you how to change, or update code in their script ie. "Copy & paste this on line 234, etc..")... this are my beginnings.
I don't understand how what I do works, but I am getting good at what I do with code, though I feel because of my informal learning methods, that I lack in knowledge, some of the really simple, but necessary principles of web coding in general(the ins and outs of servers, browsers, etc). I feel as though I have started from the inside of understanding code, the practical side.. and lack the basic fundamentals, and theorized understanding of what I am doing.
I also know quite a few others who are the same, who started learning in the same communities as I, and are pretty much at the same point as me... Feeling as though something big is missing from the picture.
I see the lacking in my discipline when I attempt to use PHP authoring tools, which I find very challenging to understand... and this is becoming a downfall on the time frames in which I complete my projects(having to hand code everything). I also find it difficult to ask for help at times, for lack of the specific language that comes with programming, and being able to use the right words to explain the intricacy of my problem.
I was a hairdresser by trade, I worked as a bartender, and hotel manager, I'm a business consultant by profession. I've been learning web development slowly now for 3 years, and I have taken on quite a few commercial projects over the past 2 years, but I'm obviously feeling some lacking in my skills & overall knowledge.
Basically, Id like to ask any experienced coders who've had similar beginnings to give me an idea on how I can adapt my coding disciplines to be more effective and productive. What would someone with such an informal understanding of programming want to seek to learn, and understand. What are the things I must know as a programmer... and what is a basic overview of the whole picture???? Feel free to direct me to articles
Any help is always appreciated.
Lea
Edit: Just to give a round up of my actual capabilities. I am a programmer, I do author my own code from scratch.. and sell my work. I can write PHP functions, and classes, use mysql, have a good working understanding of html & css, and am very good in the design aspects(web graphics), and am learning javascript/ajax/jquery, as I am using jquery in most of my projects. Thanks for all of the answers so far!

Realise that "copy and paste programming" is not actually programming, despite the name. The act of "programming" is figuring out how something should work, and what code is needed to make that work. Therefore, when you copy and paste some code, it is someone else who did the programming. This isn't a bad thing necessarily, as you shouldn't always need to write code yourself. But to call yourself a programmer, you do need to have written the code yourself.
You will want to start humble. Don't try to write a large complex application as your first step into programming. There is a good reason why most people who are taught programming are first taught how to print "Hello, world". This is because there is a lot more that you will need to know than just what code to use - you need to know where code execution starts and how it flows, and that sort of thing. You need to be able to look at the code and step through it mentally, knowing where program execution will go next, so you understand how it will work.
Take a tutorial or course in programming. There is so much free stuff online. Do not trust any tutorial that just gives you large chunks of code, make sure it forces you to actually come up with some code yourself. Do exercises such as sorting strings, calculating fibonacci sequences, and the like, and "echo" or "print" the results. Learn about conditional statements (like "if") and the "for" loop and play with these to do various things.
GUI or forms programming is more complicated; make sure you know the fundamentals of the language before you go looking through any API or framework documentation to see what the language can do. You'll need to know how execution flows, how to write functions, what types of variables you can use etc before you can effectively use an API or framework anyway. It is boring not being able to do cool graphics or forms and sticking to basic text or number processing, but you have to walk before running. Make sure you are doing, not just reading. When you learn about something new like the Array type, the "while" statement, try it out. By actually doing it, you'll "get it" a lot faster than just reading a book or website and you may be more likely to remember it.
Read books about programming. Some people say you should learn C before you learn anything else. I don't necessarily agree, but if you do learn C then the book to read is "The C Programming Language" by Kernighan and Ritchie. Many programming books are very interesting but either not suitable for beginners, or aren't going to teach you how to actually begin programming. This one is an exception.
Use a decent text editor with syntax highlighting and line numbering. That's all you should need. A big IDE that also does code completion and the like is not necessarily helpful at the learning stage. Don't spend too long choosing one or setting it up. If you don't already have one, just get Notepad++ (if you're on Windows) and be done with it. If you don't like it you can change it once you get more proficient. Or if you've already paid for Microsoft Visual Studio then use that, but don't go out and get it just for the sake of learning a language. Avoid falling into the trap of spending all your time sharpening your tools and no time using them.

The easiest and fastest way to do this? Find a mentor, or a set of mentors. Not necessarily a real-life mentor, they can be offline, although a real-life mentor is more practical.
You can find these people when you participate in local software development communities, e.g., forums, or user group meetings. Frequent these places, both offline and online; the amount of knowledge that you will learn is immense, not to mention the benefit of being able to bounce ideas off of other people.
Code Complete and Pragmatic Programmer are likewise excellent book suggestions above. I suggest you go with Code Complete first, as it tackles on how to make your code sensible and elegant, which you certainly can use immediately.
Goodluck!

We all learn differently, so don't feel handicapped because of the way you've entered the field.
I guess the simplest, easiest thing I can suggest would be to get yourself a PHP book (seeing as that's what you're familiar with right now) and start from there to build up confidence.
In your spare time, just create some very small basic apps to practice without any pressure. Then take on a language like Python, Java or .NET.. depending on what takes your fancy. With a language or two under your belt, then you can take on books like Code Complete, which will cover some of the more esoteric areas of software development.
Good luck, this is a profession where you really never stop learning.

in case you're interested to becoming a better programmer, i must recommend that you read the pragmatic programmer, don't worry, it's not a full text of codes which will make you pull your hair out but useful lessons which can only be distilled from years of programming experience written in an easy to read but still very informative kind of way :)

I'm not at all convinced that the premise of the "Copy & Paste Generation" is any kind of new phenomenon. Only the tools are available to a wider audience now than before.
If you want to really hone your skills, it might be worthwhile to take some classes, either at a local community college or in a self-directed learning environment through the use of some of the many, fine online resources or books

I believe Code Complete is another book along the same lines of the Pragmatic Programmer that has already been recommended.

I have been your situation before, senior year of high school in an internship I "learned" c and shell programming mostly via copy and paste, and later on at various times when I may have been in a similar situation with specific technologies.
My recommendations:
Take a class at your CC. The one you want is the one that is the prerequisite for the advanced programming classes. They probably also offer a "I've never touched a computer before" level class but this one won't be the formal prereq for the follow on classes. This will probably be in Java.
Work your way through one of the better programming books that includes exercises. Kernighan and Ritchie's C Programming Language is a classic. This would be my recommendation because C is similar enough to PHP to be familiar, but different enough that you will be able to keep them separate. I say this even though you will probably never write a single line of production C. Paul Graham's ANSI Common Lisp is also a suitable choice.
If you are really hard core and have the dedication, you can try Structure and Interpretation of Computer Programs, by Abelson and Sussman. This is the book used in the first programming course at UC Berkeley ( http://webcast.berkeley.edu/course_details.php?seriesid=1906978389 ) and at MIT ( http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-001Spring-2005/CourseHome/ ). This may be too difficult to attempt outside a school environment. It's designed for bright young students with nothing to do but study and with the regular opportunity to get tutoring from grad students. I include it only for completeness.
I would avoid any web programming books. You already know web programming. I get the impression that you are feeling like you are hitting a bit of a wall, and looking at a way around or over that wall, rather than trying to go directly through it.
I would advise against looking into any web oriented book because it will not give you the big picture, it will describe technique only as they apply to web programming. The important things to understand are how a computer actually operates, the difference between the stack and the heap, pointers, the basics of garbage collection, recursion, and it'd probably be helpful to understand at least extension mechanism. I mean, if you understand shared libraries on Unix, or DLLs on Windows, or classpath and jars on Java, or how to create a library in PHP, Ruby, Perl or Python, any one of those will be fine. It's just the concept of loading outside code that's important.

Take a look at The Structure and Interpretation of Computer Programs and see if you think it would help.

Copy and paste programming refers to using the same code several places instead of putting it in a function or class. If all you do is modify existing source code while following a howto guide, what you do is not called programming, just copy and paste.
What you need to do is read a book on programming, whatever you feel your level is. If you feel its copy and paste level, you should start with a beginners book. Forget everything you think you know, read and follow the book. When you've finished you can remember some of the clever code(?) you noticed during your C&P days.

Mastering any skill takes time, but if you keep at it you'll become better. There is nothing inherently different about programming in that sense. Exactly how you learn best, is a highly individual matter, so it's really hard to give any meaningful advice on that. In my experience, combining different types of learning (practical experience, being around other programmers, reading books, formal education etc. etc.) in even-sized doses works better than just pursuing one type of learning (Such as formal education).
You might find these readings interesting, if you don't know them already:
http://www.norvig.com/21-days.html
http://softwarecraftsmanship.oreilly.com/wiki

Related

process of commenting and improving already written program?

Please allow my intro to properly define the scope of my question:
I'm still very new to the programming world. This all started for me when I had an idea for a software program, but no programming experience. I ended up going the outsourcing route to get the program, and after almost a year, we do have it live and functioning.
This specific program is written with php and is 100% web-based. We're using lots of ajax, jQuery, etc.
Now a year into it, I have been learning and learning wherever I can (lots of learning here!!!) I'm mainly focusing on Java now to build up to Objective-C and the iPhone fun (probably like 99% of all other newbie programmers out there).
I'm really learning so much, and one of the biggest things I'm learning about is proper commenting and scalability.
I'm seeing now that this job we just finished is very sorely lacking in both those areas. I am wanting to add and build upon this program, and not only do I not have much experience, but I'm seeing that it's really hard for me to even get an idea about the functions without these comments...
So my question is-what is the best course of action to begin to pick up the pieces on this program? A full re-write is out of the question, and I don't think is needed.
I'm sure this is not the first time some newbie programmer, software developer has been down this path...what do others do here?
Is it common for a programmer to come into a project very far along and then "clean up" the mess in order to make things move forward productively?
If this is the wrong place for this question (and I understand it may well be) can someone point me to where this would be more appropriate?
Thanks!
Joel
We call it "refactoring" and it's an important part of programming.
First, you must have a rock-solid set of automated tests. Usually we have unit tests that we run with a unit testing framework.
http://www.testingtv.com/2009/09/24/test-driven-development-with-refactoring/
Then you can make changes and run the tests to confirm that nothing was broken by your changes.
In some cases, you have to "reverse engineer" the tests around the existing programs. This is not very difficult: you have to focus on the interfaces that are "external" or "major" or "significant".
Since you're reverse-engineering, it's hard -- at first -- to determine what should be tested (because it's an important external feature,) and what should not be tested (because it's an implementation detail.)
I'm really learning so much, and one of the biggest things I'm learning about is proper commenting and scalability.
First, I'm curious what you've learned about "proper commenting" as this varies drastically. For some, it's documenting every class and function. For others, it may be documenting every line of code or no code at all.
After having gone through some of the different phases above, I'm with Uncle Bob Martin who, in Clean Code, says that you document decisions, not what the code does. The code itself should be readable and not need documentation. By adding comments describing behavior, you've created duplication that will eventually become out of sync. Rather, the code should document itself. Using well-named functions and variables help describe exactly what the other intended. I'd highly recommend Clean Code for a full discussion of these concepts.
As for scalability, it's usually something that you want to build in. Scalability might be a function of good design, or a proper design for the requirements, but poor design will make scalability a nightmare.
I'm seeing now that this job we just finished is very sorely lacking in both those areas. I am wanting to add and build upon this program, and not only do I not have much experience, but I'm seeing that it's really hard for me to even get an idea about the functions without these comments...
I see this as an indicator of one of two things:
That the code isn't well written. Yeah, that's highly subjective. -OR-
That you don't yet fully understand everything you need to. -OR-
A little bit of both.
Writing good, intention-revealing code is hard and takes years of practice.
So my question is-what is the best course of action to begin to pick up the pieces on this program? A full re-write is out of the question, and I don't think is needed.
As other posters have mentioned, Refactoring. Refactoring is the process of changing code to improve readability and usability without changing functionality. Get a good book on refactoring, or start reading everything you can online. It's now a critical skill.
Is it common for a programmer to come into a project very far along and then "clean up" the mess in order to make things move forward productively?
Unfortunately it is. It takes a lot of diligence to avoid falling into this trap. Try to make your code a little bit better every day.
I don't know about this being the wrong place or not, but I'll answer as I can:
Is it common for a programmer to come into a project very far along and then "clean up" the mess in order to make things move forward productively?
Yes, in my experience this is very common. I have been doing contract work for over 10 years, and I can't count the number of times I've had to come in and clean up something hastily put together to either make it scale or to be able to add functionality onto it. This is especially common when you outsource the programming to another company, the incentive there is to get it working and out of the door as quickly as possible.
So my question is-what is the best course of action to begin to pick up the pieces on this program? A full re-write is out of the question, and I don't think is needed.
I don't know that there is a "good" answer to this question, the only thing I can tell you is to take it one method at a time and document what they do as you figure them out. If you still have access to the people that initially wrote the program you can ask them if they could give you documentation on the system, but if that was not included as part of the original work spec I doubt they are going to have any.
I'm really learning so much, and one of the biggest things I'm learning about is proper commenting and scalability.
As you have found on your own, proper commenting is important, I'm not convinced on the importance of building scalability in from the beginning, going by the YAGNI principle. I think that as any program grows it is going to go through growing pains, whether that is scalability or functionality. Could someone have built twitter from the start with the kind of scalability in mind that it currently needs? Possibly, but there is the very real possibility that it would flop.
Is it common for a programmer to come into a project very far along and then "clean up" the mess in order to make things move forward productively?
It's definitely common for pretty much EVERY programmer :)
Having said that, remember the IIABTFI principle. If It Ain't Broke, Don't Fix It.
Understanding how the program works and what the pieces are is useful.
Trying to improve it without a specific goal and a business purpose in mind is not.
The big question is how well is the program currently running meeting the needs of those that use it? While it may not be the best looking code, it does work which may mean that you end up doing 101 refactoring exercises around it to get enough of the basics down to make other changes.
While you may be able to ask the original writers of the program, this can be a possible sore spot if they think it is awesome and you think it is crap, for example. It is an idea and one that should be carefully analyzed a bit before one goes and ends up burning bridges because they think you can't appreciate their genius in what was done.
Often this aren't done in an optimal way and so as one learns better ways to do things, things are done in better ways. There is a limit to that of course, but I'd start with the idea that you have some refactoring lessons to help get the basics of the app under your belt and then start putting in enhancements and other stuff to see what was really done in the end.

PHP Practices for first time web-programmer [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have this idea for a website that's been floating around my head for quite sometime now and now have finally decided to get to work on it. Due to the nature of the project and my experience I am getting comfortable with the idea of running it as a PHP+MySQL application on an Apache server.
This is my first time doing web programming of any sort(I have a background in sysadmin and mainframe systems coding) and I am pretty unsure of what practices to take into consideration so that I don't find myself undoing/redoing things later in the project. Considering all the flak the language has taken on StackOverflow(which can be seen here and here) it would be nice to have a set of common mistakes to watch out for for a beginner like me. I did find this thread outlining things to avoid in PHP but most of the points made little sense to someone like me who's just setting out in PHP.
Do you have any suggestions, tips or tutorials outlining common gotcha's in the language which might come back later in the project demanding entire rewrites.
For what it's worth I am currently working my way through Programming PHP(O'Reilly) and PHP in Action(Manning).
I was in a very similar position a couple years ago, having come from a NOS background myself.
I actually started with PHP and MySQL for dummies. Once I had absorbed the knowledge contained therein, I hit the Web (I used SitePoint a lot, like Boushley recommended) and I read a couple of O'Reilley's book on the subject.
Once thing I will tell you, is that if you want to streamline your understanding and your efficiency, I have found great success with a number of MVC frameworks(CodeIgnitor, CakePHP, etc). If you have no idea what MVC is, I recommend finding out. Now that I use MVC, my code is easier to understand, modify, troubleshoot, etc.
And honestly, half of the learning in PHP is running into those common mistakes and learning from them. Its hard to appreciate those 'common mistakes' until you make them.
Don't worry about HOW you are going to learn, just START leaning!
If I could give you one piece of advice, it'd be to use a framework - they will make your life so much easier. They take away all the repetitive code from programming websites, handle security concerns and abstract lots of things, as well as make you build your website using a pattern such as Model-View-Controller.
I highly recommend the CodeIgniter framework for it's simplicity, power, great documentation and ease of use, but there are plenty of other good frameworks too. There are lots of questions on SO on this so have a quick search. There is a fantastic introductory screencast on CodeIgniter (soon to be a series) from BinaryCake, so check that out here.
I hope that's helped! If you have any PHP concerns, feel free to message me - it's my area of expertise (along with CodeIgniter) and I love it!
While still developing, have all errors show up:
ini_set('display_errors', '1');
error_reporting(E_ALL | E_STRICT);
Can save a lot of time (in case of say, typos in variable names). Change this when it goes live to not display or only display "real" errors depending on the type of site and security levels involved (you don't want everyone to know paths and variable names and such..).
Find a variable/function naming convention (under_scores vs camelCase vs..) that suits you and stick to it. Also, classes go in the /class directory, includes in /inc etc. Both these make it easier to understand your own code years from now. Oh, and the same goes for coding style, I guess: choose one and stick to it (indentation, bracket style, ..).
Comment your code :-) Personally I also have a little log at the end of longer files that shows when I did what and why. Each addition is timestamped, and the same timestamp is also in the comments behind the change itself, as the line number on which it sits can easily change. Similarly, in an included file containing a bunch of functions, I have the list of function names in a comment at the top of the file, with a one-line description behind them.
Finally on security (though this should really be your first concern ;-) ), treat all user input as suspect. That's POST & GET data, cookies, user-agent string, search strings - anything that is supplied by the browser. It's trivial to change cookie data or change/add form items.
Read up on SQL injection & XSS attacks, and look at PHP's relatively new data filter functions: http://php.net/manual/en/intro.filter.php
Google any of these to get some good reading
Don't use register_globals
Turn off magic_quotes - escape all user entered input in SQL statements
Escape any user entered input printed with htmlspecialchars()
Plus a lot more... These are some common things to watch out for though.
There are a number of great websites out there with lots of tutorials. One that comes to mind is Site Point. They'll try their best to sell you a book or two while your're there, but they do have some decent articles. This article for instance discusses some common security blunders in php.
http://www.sitepoint.com/article/php-security-blunders/
They have lots of them...
http://www.sitepoint.com/search/search.php?ps=10&q=php&submit=Search
Also a nettuts.com has a load of tutorials an things of that nature. They're more all across the board though.
http://nettuts.com/
And I think pretty much everywhere you look you'll see the common ones like watch out for register_globals, magic_quotes...
one good book to look at that is also free to download here covers beginner to advanced PHP techniques and is good way to learn good standards :)
Use a framework and use Object Oriented Programming
Books are great for learning additional languages, but for your first one, a good video tutorial is a great way to go!
Register for a Lynda.com account (google: lynda trial) and sign up for as many one day trials as you need (or be a good honest person and purchase a week). They have a pretty good beginner and advanced PHP series of video tutorials which are (IMHO) a great way to learn your first language.
A tip: If you can start programming Object Orientedly from the get-go, you will save some time in the future and learn good practice from the start, luckily the advanced tutorials cover this!
Here's a link: http://www.lynda.com/home/DisplayCourse.aspx?lpk2=435
I've never taken this particular course (when I learned a few years ago, it was different), but I just recommended this to a friend (who was just starting), and he really liked it!
Hope this helps!
If you're new to programming in general, A database backed web application is likely to be a bumpy ride. You will probably be programming in at least two, real programming languages, PHP and SQL, and if you're going to do anything of modest complexity, JavaScript too. Keeping them strait will be rough, because they are all quite different.
Just to warm up to programming, you might want to start instead using a more focused learning excercies, such as working through the Euler Project problems, or Code Kata.
Either way, Try to pick up good habits wherever you learn about them, including the popular suggestion here of using an MVC framework for the heavy lifting.

What would be a good sample project to ask a prospective programmer to code during the hiring process?

My understanding is that asking for a work sample is a good way to determine if someone has the skillset you are looking for, as some people just interview well. So I want to ask potential developers to write some sample code for me.
I'm looking for ideas on what kind of small project would be something they could do in an hour or two, and would show that they have a good grasp of OOP, good coding practices, etc. And what to look for once they finish - how to evaluate it fairly and usefully.
For context, I'm a small business owner, interviewing prospective developers, for PHP development on internal projects. I can code PHP but am not an expert (some of the work is refactoring code I've written to be better structured and consistent), and so I'm also looking for what to look for when evaluating the samples, given that I'm not a trained or super experienced programmer.
Especially for people who have done hiring of this type before and used this method.
I was also thinking I could give them some code to refactor, and see how they do on it. Has anyone ever given a refactoring test as part of the hiring process?
Clarification:
I'm not talking about coding during an interview. I'm talking about coding instead of an interview. For context the inspiration for this question came from this article in FastCompany about how work samples are better predictors of job success than interviews:
Why It May Be Wiser To Hire People Without Meeting Them
http://www.fastcompany.com/magazine/136/made-to-stick-hold-the-interview.html
I would create a not necessarily good application and embed some bugs. I would come up with some simple functionality to be added to the program.
Does the applicant find some bugs?
How does the applicant's code integrate into the existing code?
Does the applicant get stuck on something that doesn't really matter?
Does the applicant adapt to the coding standard of the existing code?
After this exercise, discuss the code with the applicant. This may be more valuable than the actual code.
NOTE: with regards to #bpapa answer I would make sure that problem is novel and obviously not to be used in production.
Personally I would refuse to do this when asked. An interview is one thing, and doing programming questions on paper to asses technical knowledge is fine, but actually writing some kind of application for somebody is billable and I wouldn't do it for free. Even if it only is supposed to take an hour.
I think you should focus more on what the person has done in the past, and ask technical questions that you know the answers to (since you said you have limited PHP knowledge and want a PHP developer).
I would heed Joel's advice that giving homework assignments for interviews just weeds out the best programmers (paraphrased from his book). The better programmers have a lot of options and so won't want to go through the exercise of a programming assignment. They just won't apply. That will leave you with the mid-competency people. Unfortunately, in my experience those are the ones most likely to try to look better than they are and if you aren't an expert yourself, the ones most likely to mislead you.
Here's an alternate option. Have them point you at some work they have already done. Not necessarily the code, but the site. During the interview, ask them questions about how they coded it. What data structures did they use? How were the classes or functions organized? What problems did they have to overcome?
Then as traditional programming questions in the interview that they could answer for you ont he spot. This way you can gauge their understanding and their syntax. The two don't have to be the same question.
If you are not an expert then I would suggest you be careful about trying to evaluate other developers. You should probably figure out a better way to assess the dev skills of someone else if you are not that comfortable with your own level.
I am not sure there is a good solution for you.
I'd make the coding samples very straightforward and not have it take an hour or two. Simple coding exercises that take a few minutes should be sufficient - combined with other discussions about best practices, frameworks, design questions, etc.
I like the problems at streamtech. They are pretty easy and can often be done in rather short time, but they show that the applicant is capable of structured thinking and translating this to structured code.
As for evaluation---I would use this as an opportunity to learn. Do the problem yourself first, then compare to the applicant's code. Look up any constructs that you don't know, then ask yourself which version is more obviously correct.
I think the best thing you can do is try to have a real expert sit in on the interview with you. Hire a third party if you need to. I'm not sure it's possible to be able to give a quality assessment of someone who is a more experienced developer than yourself.
The other thing to consider is that really good developers may pick up on the fact that they are more experienced than yourself, and if you indicate that you are one of the developers it may actually put them off (not trying to be offensive, I just mean in the context of you implying that you are not very experienced.)
Give them an address or such as a plain text file and ask them to create a simple script to turn it into XML. I used that once and it worked wonders.
If you want to test them on the spot, ask them to reverse a string. From an organisational standpoint, perseverance, determination and enthusiasm are just as important as being technically adept, IMHO.
Well, everyone seems to be discouraging the coding effort for an interveiw. I'll disagree with the disagreers. To answer your question--if you want an example of what to have them code--drop a simple calculator on the table in front of them and ask them to write a program to create the calculator virtually. Give them half and hour and see how far they get. Some may finish in that time.
Have you ever tried pair programming before? Two people sit down at one machine, they share keyboard and mouse, and talk about what they're doing as they go. I think this is absolutely the best approach, because it will, eventually (after everyone's panic subsides), really indicate how well you two work together.
If you're not a great programmer, this person should be able to teach you and put you at ease. If they're not that good, but you work together well, that might be more desirable than a brilliant but unpleasant person.
At the end of the session, just delete your work. No big deal.
I've never been a part of the hiring process... but in interviews I've done, I was asked once to implement a doubly linked list, and another to work out an algorithm, the classic, how many integer points within a given shape, in this case three points forming a triangle, once in O(n^2) and then again in O(n).
I don't think the way to do it is to make them program something, but to make sure they know how to figure it out. You give them a problem or ask them a question, and tell them to think out loud, and observe their thought process. This doesn't exactly show if they have clean code, but depending on the problem it gives you insight as to wether or not they know what their talking about.
Having a small, well defined task can help you take examine people on a level playing field with a relatively small investment of time on their part. You don't need something complicated to see what people can do.
In the past, I've asked people to write a small web application that exercises a few fundamental concepts. We keep the particulars of what the application is supposed to do really simple.
I would also try to avoid tasks that require a lot of supplemental knowledge (viz, don't ask them to solve a problem from your particular problem domain).
Edit:
Regarding "small, well defined tasks": What I try to shoot for is something that includes a very thorough description of some simple business logic as part of a larger programming task. For example, one of the programming assignments I've given in the past involves setting up a simple Java web application and implementing a few features. We made sure to describe thoroughly how the features were supposed to work to remove ambiguity. This was for a couple reasons:
The point is really to see if the candidate can build a simple application from scratch, not to see whether they can guess correctly about what we want.
If you define the task really well, you get to see more about how thorough someone is with the type of work that they're likely to be doing in a business situation.
We wanted something flexible enough to give to candidates at varying levels of experience.
I should note here that I think programming assignments are most effectively used to check for competency. If you give a really hard assignment, or one that isn't well-defined, odds are that you're not going to get results that tell you what you want to know (unless you're testing specifically for how the candidate handles difficult assignments or ambiguity).
I argree with bpapa about it being an interview instead of a test run, maybe instead consider asking some questions about how they would undergo certain talks to do with the programming...
I once had to sit a Visual Basic MCP exam at the end of which they didn't even bother to give me the result.
Happily though when I asked the question as to whether I would be given the result I was sitting at the Commit/Cancel screen.
So I hit cancel thanked them for wasting my time and walked out.
To answer the question:
For PHP, I think a shopping cart, address book and forum would be good projects. Those usually cover a wide spectrum of web-programming topics - sessions, registration, database, form processing and authentication.
Personally speaking:
It looks like you looking more of an architecture person than a coding guru. I wouldn't penalize the applicant because he cannot come up with the name of an obscure function or need to refer elsewhere. The key thing is that he has the initiative and know where to look (heaven knows how many times I need to look up PHP.NET). A good question for an architecture guy, IMHO, is to tell him you have a data-set, but you have three different ways of displaying them and each view has different operations. If his answer is just a gigantic SWITCH-CASE, then he may be the wrong choice.
Usually weak programmers does not understand recursion pretty well, that's from my observations as far as now, now this does not have anything to do with PHP directly and probably a recursive factorial or fibonacci series wouldn't be a big deal, but let's say to load a tree control with data from a database with some parent-child relationship might be a good sample.
Also as you're not an expert as you said, think off something you can handle confidently.
It usually depends on the language you are hiring for. For example, when I went and gave an interview for PHP, I was asked to write a blog script, using custom MVC framework, whereas when I interviewed for an opening as a JS dev, I was asked to code a certain plugin in jQuery. Its more dependent on you are hiring the guy for ultimately. You dont want to ask someone to write you a music recommendation engine and then have him work on a payments gateway processor.

General programming knowledge?

I am completely new to programming - my interest lies in PHP & MySql for building a dynamic web application for Military Band Administration purposes. i.e. General info and social networking for members + added functionality for the management team to communicate effectively.
OK so the question - as I learn more about PHP there are terms used that I do not understand that must come from a common basis of familiarity between all languages i.e. "stack overflow" appears to be an obvious one - "using too many recursive functions may smash the stack" is another.
So is there a book (a primer perhaps) about programming in general which allows someone like me to have a better understanding of what all this means?
Bear in mind I am 57 years old (young) and am really just starting out.
Steve
Wikipedia is probably your best resource for general information on programming terminology. A large segment of their community overlaps with the programming community, so tech-related pages are normally very accurate, educational, and up to date. See their pages on stack overflows and recursion as examples.
Also, PHP.net is the best place to learn about PHP specifically, but skip the main page and go straight to the tutorial if you're just starting out.
Finally, I highly recommend the book Head First SQL for learning about databases. All of the examples in the book use MySQL. The entire Head First series is great. I hear they have a PHP book as well, but I haven't read that one.
Update: Head First PHP & MySQL is now available.
It sounds like you're missing some of the fundamentals covered in a computer science program. Not to worry, the information is readily available. You don't have to pay someone to teach it (though it's sometimes nice). Wikipedia's computer science entry isn't too bad for highlighting the major fields you're likely to encounter. Topics that are good to know:
Discrete math (Helps to understand formal logic, algorithmic complexity, probability)
Programming fundamentals (sounds like you may have a good start on these)
Data structures (Store and manipulate your data in an appropriate way for a task. For instance, why use a hashtable versus an array versus a linked list? From your list, the stack in a stackoverflow is a data structure.)
Algorithms (Manipulate your data structures in the most efficient way possible or at least know the cost. From your list, using too many recursive functions to "smash the stack" is an algorithmic choice.)
Computer Architecture (Understand what's really happening to your code after it's compiled or interpreted.)
Networks (Learn protocols, what happens to your software when it wants to talk to a machine it's not running on)
Comparative Programming Languages (PHP is just one way to skin a cat. Learn why its designers made the decisions they did and gain exposure to alternatives.)
Operating Systems (Knowing how hardware interacts with your software is good but it's probably more important to understand how it interacts with its operating system. File systems, process management, memory management, security)
Formal Languages/Theory of computation (Models of computing, grammars [used to validate and interpret code], limits of computing. Typically not used day to day as a software engineer. Then again, regular expressions finally made sense after this class.)
Software Design and Life cycle Methodologies (Be deliberate about designing, coding, testing, releasing, and maintaining your software.)
As far as books, I'd start by checking a trusted school's computer science program reading.
Stanford offers a set of classes online for free: http://see.stanford.edu/see/courses.aspx
MIT lets you download course materials for free: http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/
Check youtube for computer science related lectures.
If you want something less school-focused, a quick search on Amazon with any of the topics above will give you results with user reviews.
Obviously, taken together, this list isn't really an introduction. I'd start with a topic that sounds interesting and jump in.
Well it is not book about PHP but I think a book like "Learn to program" from the Pragmatic Bookshelf
might be useful for someone in your situation.
To get a good understanding of the inner workings of computer hardware and software in a very readable (not too technical) manner, I can recommend Code,The Hidden Language of Computer Hardware and Software by Charles Petzold.
The later chapters in particular talk about some of these more general programming concepts that are present in most programming languages. The earlier chapters focus on more the history of the computer and software, so not as relevant to your question.
However it's not a large book so the reading it all should be interesting/useful anyway.
There are better books if you are looking for an introduction to PHP/MySQL programming specifically, however if you want more general knowledge about how software and hardware works, Code is great.
I'm not sure if there's one book that'll teach you "The Fundamentals of Programming." The only way I know of learning all these things is simply practice. Get a PHP tutorial and start building things. Always keep your mind open to learning new things. When you find a better way to do something than a likely very inefficient hack you put together from incomplete knowledge, then use it and learn it and integrate it into your knowledge... after a few years of this you'll be golden.
It's been a couple years since I read it, but Programming PHP did a nice job of introducing the fundamental programming concepts along the way. It didn't do much for helping understand more advanced concepts, like MVC (which is rare in the PHP world), it things like arrays, functions, callbacks, classes, etc, where covered.
I like Corbin's comment, but I'll take the opposite approach.
Basically, with systems today, you really don't need to know all of the low level details of systems. Really, you don't.
If you find this stuff interesting, the entire internet is at your disposal -- and simply let you inner muse guide you through either necessity or simple curiousity. You can go as deep or as high as you want.
The truth is, computing today is simply SO fabulous that the project you want to embark upon is just a perfect opportunity to learn more about the arcane world of computing. The fact that folks can get as far as they can "without having a clue" is testament to how far the field has advanced. It's a good thing.
Is it a good thing to understand the process soup to nuts? Sure. Do you actually NEED that understanding to be productive and get useful results out of your time investment? No, you don't.
And, as you progress, if you actually enjoy this work (you well may not), the field goes as broad as you want.
Computing today is like "Home Depot". You can do it, we can help. There are hundreds of forums and thousands of pages of documentation, books, blogs, and discussion available for most any topic.
The key thing to focus on is simply getting your task done. Don't worry about getting it perfect, don't worry about "doing it the right way", don't "engineer" it. Just hammer bits together until you get something close to resembling what you want to get done using whatever you happen to find or intuit yourself. Because that's the easiest way to find out what you don't know, and how to not do things in your application. Try it and see.
You will be blinded by options, techniques, patterns, frameworks, etc. Not only is there "more than one way to do it", there are HUNDREDS of ways "to do it". Ignore the hundreds, and focus on the "doing it", however seems natural to you.
And don't let the yahoo's in their ivory towers poo-poo your questions, or shred your design. Unless their name is "Babbage" or they were cutting gears for the artillery computers back in WWII, we're all standing on the shoulders of giants here, and we all started somewhere. Honest criticism should always be welcome, but some folks seem to be beyond being able to offer that and instead resort to belittling.
I marvel at the applications I've seen "hacked", "butchered" and "OMG'd" together that folks get real, practical use out of -- and that's the real name of the game.
Good luck on your journey. Success in all your endeavors.
Learning is quite individual, so your mileage may vary, but I find that asking questions in public fora is very helpful. If you don't know a lot of the topic it's easy to ask the wrong questions, or somehow focus on the wrong things. Getting direct feedback from someone more experienced usually helps with that. PHP is blessed in that it has a very large and friendly community. Further, a lot of its users are amateurs or inexperienced programmers, which means that there is a culture of asking basic questions about terminology and the like. I suggest that you tap into this source.
One place to start could be at sitepoint, but there are other places
If you're more of a visual learner I would check out some video tutorials. Start with things like basic programming concepts and then move up to titles like Up and Running with PHP and Advanced PHP and MySQL. Then I'd suggest an MVC framework like codeigniter.
You can find great video tutorials on Lynda.com or Pluralsight.com and several other places.

Introducing Python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
The company I used to work with has two developers working fulltime, and a handful of freelancers. They're in the process of hiring a new lead developer to try to bring order and management to the development.
But, currently, one of the developers has seen the light of Django (the company has only developed in PHP to date) while the other developer is concerned that introducing a new language (Python) is a bad idea right now.
How should they approach introducing this new technology? Obviously with only one of the developers actually knowing Python, there will be no redundancy when that dev is away or leaves the company.
Should they bother to introduce Python, or should they look for PHP-only solutions until such a time when the team actually have more than one Pythonion? Without a team leader, the decisions are having to fall to them.
I recently introduced Python to my company, which does consulting work for the Post Office. I did this by waiting until there was a project for which I would be the only programmer, then getting permission to do this new project in Python. I then did another small project in Python with similarly impressive results. In addition, I used Python for all of my small throwaway assignments ("can you parse the stats in these files into a CSV file organized by date and site?", etc) and had a quick turnaround time on all of them.
I also evangelized Python a bit; I went out of my way to NOT be obnoxious about it, but I'd occasionally describe why I liked it so much, talked about the personal projects I use it for in my free time and why it's awesome for me, etc.
Eventually we started another project and I convinced everyone to use Python for it. I took care to point everyone to a lot of documentation, including the specific webpages relating to what they were working on, and every time they had a question, I'd explain how to do things properly by explaining the Pythonic approach to things, etc.
This has worked really well. However, this might be somewhat different than what you're describing. In my case I started with moderately small projects and Python is only being used for new projects. Also, none of my co-workers were really Perl or PHP gurus; they all knew those languages and had been using them for awhile, but it didn't take much effort for them to become more productive in Python than they'd been before.
So if you're talking about new projects with people who currently use PHP but aren't super-experts and don't love that language, then I think switching to Python is a no-brainer. However, if you're talking about working with a large existing PHP code base with a lot of very experienced PHP programmers who are happy with their current setup, then switching languages is probably not a good idea. You're probably somewhere in between, so you'll have to weigh the tradeoffs; hopefully my answer will help you do that.
If the mandate of the new lead is to put the house in order, the current situation should likely be simplified as much as possible prior. If I had to bring things to order, I wouldn't want to have to manage an ongoing language conversion project on top of everything else, or at least I'd like some choice when initiating the project. When making your recommendation, did you think about the additional managerial complexity that coming into the middle of a conversion would entail?
#darkdog:
Using a new language in production code is about more than easy syntax and high-level capability. You want to be familiar with core APIs and feel like you can fix something through logic instead of having to comb through the documentation.
I'm not saying transitioning to Python would be a bad idea for this company, but I'm with John--keep things simple during the transition. The new lead will appreciate having a say in such decisions.
If you'd really, really, really like to introduce Python, consider writing some extensions or utilities in straight-up Python or in the framework. You won't be upsetting your core initiatives, so it will be a low/no-risk opportunity to prove the merits of a switch.
I think the language itself is not an issue here, as python is really nice high level language with good and easy to find, thorough documentation.
From what I've seen, the Django framework is also a great tooklit for web development, giving much the same developer performance boost Rails is touted to give.
The real issue is at the maintenance and management level.
How will this move fragment the maintenance between PHP and Python code. Is there a need to migrate existing code from one platform to another? What problems will adopting Python and Django solve that you have in your current development workflow and frameworks, etc.
It's really all about schedules. To me the break should be with a specific project. If you decide your direction is Django then start new projects with that. Before you start a new project with a new language/framework, either make sure that you have scheduled time to get up to speed in this new direction, or get up to speed before using on new projects.
I would avoid going with a tool of the month. Make sure you want it to be your direction and commit some time/resources to learning enough to make a good decision.
Well, python is a high level language.. its not hard to learn and if the guys already have programming knowledge it should be much easier to learn.. i like django.. i think it should be a nice try to use django ..
I don't think it's a matter of a programming language as such.
What is the proficiency level of PHP in the team you're talking about? Are they doing spaghetti code or using some structured framework like Zend? If this is the first case then I absolutely understand the guy's interest in Python and Django. It this is the latter, it's just a hype.
I love Python and Django, and use both to develop the our core webapps.
That said, it's hard to make a business case for switching at this point. Specifically:
Any new platform is risky compared to staying with the tried and true
You'll have the developer fragmentation you mentioned
It's far easier to find PHP programmers than python programmers
Moreover, as other posters have mention, if the issue is more with spaghetti code than PHP itself, there are plenty of nice PHP frameworks that could be used to refactor the code.
That said, if this developer is excited about python, stopping them outright is probably demoralizing. My suggestion would be to encourage them to develop in python, but not the mission critical parts of the app. Instead they could write some utility scripts, some small internal application that needs doing, etc.
In conclusion: I don't recommend switching from PHP, but I do recommend accommodating the developer's interest in some way at work.

Categories