What are some best practices for Django development?

Answer by Joseph Misiti:

Here are some things I have learned over the years that have helped me:

1. Try to setup your projects with the following directory structure

/myproject
   /apps
   /configs
   /settings
   /deploy
   /static
   /templates
   urls.py
   fabfile.py

apps – contains subfolders with specific functionality (static, accounts, etc)

configs – stores all configuration related scripts (gunicorn, nginx, celery, mongdb, redis, etc). It's useful because you can use fabric (put command) to copy these over to the correct locations on a server

deploy – contains all deploy scripts, set up in similar manner to this project[1]

A lot of examples you see online put everything into a single fabfile.py, but that gets really messy as a project gets larger. Having a deploy folder that is organized like django-fabtastic allows you to cut-and-paste it over into other projects if you are using the same technologies

settings – a folder (not a file like settings.py) that is setup based on this reference [2]

You could use local_settings.py, production_settings.py etc. but that yipit guys got it right and that is definitely the way to go

static – contains js, css, images, types/fonts

templates – all your html files

2. Use gunicorn[3] instead of apache. If for no other reason, a print statement in code wont crash the entire site. Gunicorn is less bloated and very easy to configure. And large sites like instagram are using it at web scale so dont let people tell you its not a good idea – it will make your job easier and you can leave the office and drink a lot more beer

3. Use celery for anything that can be made asynchronous (sending emails, uploading photos, etc). Dont make the user wait for the request to return, push it onto a queue and let celery do the work for you. Also, do not use rabbitmq as the celery backend, use redis. RabbitMQ is supposedly more stable and messages cant get lost, but it's also a pain to configure and 99% of people can afford to lose a message because a lost message really doesnt matter that much.

4. If you are going to use a SQL-based solution, then use South for migrations. I  have had a lot of success migrating away (completely) from Django's ORM[7] and sticking to PyMongo[5] + MongoEngine[5]. Development is way more fun if you're using MongoDB, if you do not believe me, try it out. Say goodbye to painful schema migrations. Ya, and I know, MongoDB doesn't scale, but guess what, it does.

5. If you need to make a REST API, then use Django-TastyPie[8]. Unfortunately, there is currently no good solution for constructing RESTful APIs if your backend is MongoDB. If I am wrong, provide a link please because no one on StackOverflow could[9]

6. Do not use test.py for unit tests, put them in a directory called tests/__init__.py and import them in that __init__.py file. Also, trying using
nose, it's really cool.[10]

7. Look and good open source project for reference. The most obviously is the Django project itself[11], but Newsblur[12] and Everyblock[13] are also great references:

That is it- that is 3 years worth of trail-and-error for free!

[1] https://github.com/duointeractive/django-fabtastic
[2] http://tech.yipit.com/2011/11/02/django-settings-what-to-do-about-settings-py/
[3] http://gunicorn.org/
[4] https://github.com/ask/django-celery
[5] https://github.com/mongodb/mongo-python-driver
[6] https://github.com/hmarr/mongoengine
[7] https://docs.djangoproject.com/en/dev/topics/db/queries/
[8] https://github.com/toastdriven/django-tastypie
[9] http://stackoverflow.com/questions/8333874/how-do-i-create-simple-rest-apis-in-django-with-a-mongoengine-backend
[10] http://readthedocs.org/docs/nose/en/latest/
[11] https://github.com/django/django
[12] https://github.com/samuelclay/NewsBlur
[13] https://github.com/dkukral/everyblock

What are some best practices for Django development?

 

Which language is best, C, C++, Python or Java?

Answer by Andrea Ferro:

If you are writing an operating system, I suggest you use C.
If you are writing a very complex application where execution speed is extremely important, I suggest you use C++.
If time to market is key, but execution speed is not important, I suggest you use python.
If your boss told you: "do it in Java or you are fired" I suggest you use Java and look for a better workplace.

Which language is best, C, C++, Python or Java?

 

Why should I learn Python if I already know Java?

Answer by Manan Dhawan:

  • Beautiful and elegant.
  • Easier to learn.
  • No fuss of the curly braces {}.
  • You don't have to define the variable type [Python is smart enough].
  • Nice support community.
  • Many companies use it.
    (Dropbox, Quora, Google, Yahoo Maps, Reddit, Youtube, DuoLingo and many more
    Games: Battlefield 2, Civilization 4 and many more)
  • Many libraries available.
  • We dont have to define the datatype of the variables, hence less confusion.
  • A short Example: Comparison: Swap two numbers in python and java
  • Some screenshots from the internet related to the difficulty level.
  • EDIT: Found an xkcd:

PS: I am a Java Programmer.

You may also be interested in the following answer:
Manan Dhawan's answer to What are the best books / courses for learning Python?

Why should I learn Python if I already know Java?

 

How would one explain object-oriented programming to a beginner?

Answer by Avinash Raj:

I haven't seen a better explanation about OOP till date than the one given by a guy who never had any formal engineering training but always had clear idea about everything he did and preached, be it technology,design or art.

Here, in an excerpt from a 1994 Rolling Stone interview, Jobs explains what object-oriented programming is.

Jeff Goodell: Would you explain, in simple terms, exactly what object-oriented software is?

Steve Jobs: Objects are like people. They’re living, breathing things that have knowledge inside them about how to do things and have memory inside them so they can remember things. And rather than interacting with them at a very low level, you interact with them at a very high level of abstraction, like we’re doing right here.

Here’s an example: If I’m your laundry object, you can give me your dirty clothes and send me a message that says, “Can you get my clothes laundered, please.” I happen to know where the best laundry place in San Francisco is. And I speak English, and I have dollars in my pockets. So I go out and hail a taxicab and tell the driver to take me to this place in San Francisco. I go get your clothes laundered, I jump back in the cab, I get back here. I give you your clean clothes and say, “Here are your clean clothes.”

You have no idea how I did that. You have no knowledge of the laundry place. Maybe you speak French, and you can’t even hail a taxi. You can’t pay for one, you don’t have dollars in your pocket. Yet I knew how to do all of that. And you didn’t have to know any of it. All that complexity was hidden inside of me, and we were able to interact at a very high level of abstraction. That’s what objects are. They encapsulate complexity, and the interfaces to that complexity are high level.

How would one explain object-oriented programming to a beginner?

 

Can I get a job in Google as a programmer after doing BCA from India?

Answer by Chetan Bhasin:

Now, that's a question of my interest. I'm in third year of BCA and there was a time when I was absolutely obsessed with getting a job at Google (someday).

First of all, Google is not the garden you hear about in fairy tales. Research well and think more than just once if you'll be comfortable for their work culture.

As far as the jobs are concerned, I'd say there is a possibility. Google is known to hire people with rather *something unexplainable here* educational background; so there is a good possibility that BCA, no matter however small it may appear to you, may still make a mark.

Other than that, it's not entirely necessary for you to go and apply for a technical job at Google as soon as you graduate. Did you consider studying further or trying out other jobs and then diving into Google someday? Well! I have.

Now that all's been said, here is what I'd suggest if you want to get a job at Google or for any high profile tech company for that matter:

1. Code every day. EVERY-SINGLE-DAY. Alright, maybe not "every-single-day", but you get the meaning.
If you're applying as a programmer then I think it's very important that you're good at coding. Try out different languages. Trust me, VB .NET is not something you'd like to code in as a professional. You'll probably be having Java in your course depending upon your University; make sure that you understand it well. Google, to the best of my knowledge, makes extensive use of Java, Python, and C/C++ in their technologies.

2. DO NOT believe that your college will teach you enough. They never will; they never can. That's something I've learned with experience; and I'm not planning to forget in this lifetime or so.
Coding real C/C++ is a hell lot different from coding in a single file in blue screen Turbo C++ 3.0 which is how they code in most colleges here in India (stupid people!).
Give a shot to different and modern programming languages. Have a look at Google's technologies for that matter. Once you understand programming well, try Google's Golang or Google's Dart. There are a hell lot of courses on Coursera which you should enrol in and complete to learn something out of your comfort zone. Make sure you take up only the work that you can do. You wouldn't want to start everything at once and fail at everything.

3. Do something about your Mathematics and Logical understanding if you lack in that area.
I had always been bad at maths. I remember screaming parents and teachers over my head to study. I did not study. These things will not work. Dare anybody tell you how to study and when to study, tell them to shoo away. Make your own study plans and stick to it. Too much pressures does not only screw things up — it kills, for real!
I have started understanding without interference from bad teachers and screaming people. It turns out I get things much better now. Guess, what they say about taking too much stress is right after all!

If you keep in mind these things, you have a possibility of getting a job at Google. There is one thing that I'd like to say though. Do not just limit yourself to Google. If you think you're good enough, you'll have plenty of other things to do too (perhaps even better than a job at Google). I think, you'll learn all that by the time you reach your third year like I did.

That is all I have to say for now. I'll update this answer depending on suggestions and if I think something has to be added.

______________
Update 1:
Answering the question regarding work culture, future plans, and choice of technologies as asked in the comment below.

Every company has a work culture. Google is famous for it's work culture which you should look up on the internet.

MCA? Well, not bad. There is one thing though, if you've done everything nicely in your BCA, MCA would be like BCA again just with more details. There is no point of doing a further degree if you don't get it from a good institution. Why? It's not as much about the degree as it is about learning. Remember, we're talking about knowledge here; it has and will always remain more important than your degree whether or not you believe it.
An option that many people look up to is joining a company with a contract which sponsors your MS degree for places like BITS or VIT. That can be an option, and a good one for that matter.

It is not absolutely necessary for one to know C/C++, but I'd suggest that you do get strong hold at it. C/C++ are languages that work quite close to the machine and they teach you a lot of things which you might skip otherwise.

Java is in 5th sem, but there is nothing stopping you from learning it before then, or learning any other technology for that matter. Hit Coursera that I pointed out in my answer and it should do wonders for you.

So, you like .NET? Good, as far as I know, Google is far from using any Microsoft technology like .NET. I can't be sure about it though. If you really like it then why not try and do something with Microsoft. Plus, you can't really suggest that VB.NET is your only passion while you have not tried other higher level programming languages. Plus, remember most good programmers are not as dependent on programming languages as they are of their basic working knowledge.

At the end, there are different languages. I suggest that you post another question regarding that. I'm also assuming that Quora is full of such questions so maybe looking them up will help. Search the Interneet, read about them. Choose one you like, but in the mean time. Keep working with C/C++ since you're already onto it.

Can I get a job in Google as a programmer after doing BCA from India?

 

Will I get a job as a programmer if I don’t know GUI programming in C++?

Answer by Sergey Zubkov:

You certainly can get a C++ programming job that doesn't involve GUI, I'd even say it's hard (and increasingly harder) to find a C++ job that does. As a personal anecdote, I've been programming in C++ across several industries (telecom, transportation, finance) and never once programmed or modified any GUI.

Will I get a job as a programmer if I don't know GUI programming in C++?

 

Can a person change his job profile from PHP to C#/testing after one year?

Answer by Daksh Mehta:

First of all, forget and remove from your mind that due to low marks in acedemic is a problem for you to get a big fat package.

If you really are good developer, I strongly recommend you to prove it first by answering questions on stackOverflow, grab some projects online, write a blog and few tricjs and tips tutorial, solve the programming challenges online from the site like TopCoder, Brillient, CodeChef, Hackerearth etc

And in mean to you make your reputation as I said above, there is no shame grabbing php job at startup, and might be you get good package over there once you prove them your skills.

All the best.

Can a person change his job profile from PHP to C#/testing after one year?

 

If you are not good at top coder style technical interviews how else can you impress a startup?

Answer by Gayle Laakmann McDowell:

I think you have unrealistic expectations of yourself.

First of all, no one's going to code a red black tree from memory.

The vast majority of interviewers would not expect you to know how a red black tree is implemented. If they ask you about that, then they're a shitty interviewer.

And as for the more challenging questions: the more challenging the questions the longer EVERYONE is taking to solve them. There is almost no question I ask where I would expect a candidate to immediately spit out the optimal solution.

Second, dynamic programming is not this big scary concept.

Can you implement Fibonacci recursively? Okay, great.

Now, write down the call stack. fib(n) calls fib(n-1) and fib(n-2). fib(n-1) calls fib(n-2) and fib(n-3). and so on.

Did you notice how you keep repeating calls to fib(i)? The computer doesn't magically know to only do it once.

You have to cache the results. Can you do that? Can you modify your recursive code to store each value in the array as you compute it (and check the array before you do it)?

Congratulations. You just did "dynamic programming." In under 2 minutes.

Third, focus on interview prep. Not CLRS.

CLRS is a fantastic book. You will learn a lot. But the algorithms in it are FAR beyond the complexity of an interview.

If it's interview questions you're worried about, then practice interview questions.

Fourth, if you really totally freeze up in an interview, there are startups that don't do whiteboard coding.

There are lots of them, in fact. Write code. Put projects up on Github. Look for startups that test coding through actual projects rather than whiteboard coding.

(Note: I'm not necessarily saying that whiteboard coding is a bad thing OR that it's a good thing if a startup doesn't do this. I have mixed feelings. However, it's worth noting that some startups do this, and some don't.)

If you are not good at top coder style technical interviews how else can you impress a startup?

 

Is it risky pitching business ideas during an interview?

Answer by James Ferdinand Lukanta:

Your move may help if you are applying to a startup, but will probably hurt if you are applying to Amazon. Your job in big companies will be very defined. It won't matter how much business acumen you have if you can't stand out in terms of software engineering skills. Plus, you may annoy the interviewers since you are potentially wasting their time by pitching, and they may have other things to ask.

P.S.: If you are an excellent software engineer, your competition doesn't matter. Most tech companies are in shortage of software engineers. They should have space for talented people. Just focus on one thing, which is being great at what they need.

Is it risky pitching business ideas during an interview?

 

What are some good interview questions / tasks to test for attention to detail?

Answer by Yishan Wong:

I've also never used this (although the company I now lead has a pretty good built-in filter since active community participation involves a lot of writing), but it's always struck me as a great idea:

Don't hire people who don't use good grammar.

First off, this doesn't work for people for whom English is a second language.*

But barring that, the justification is that people who mistake "there" and "their" or use the wrong its/it's are people who don't have the right value system to pay attention to details.  These were all rules we learned in high school, they are simple and easy to detect, and require no great intelligence to get correct, merely conscious application of attention.  I first came across this in a piece written by Kyle Wiens, the CEO of iFixit:

From I Won't Hire People Who Use Poor Grammar. Here's Why. (emphasis mine):

On the face of it, my zero tolerance approach to grammar errors might seem a little unfair. After all, grammar has nothing to do with job performance, or creativity, or intelligence, right?

Wrong. If it takes someone more than 20 years to notice how to properly use "it's," then that's not a learning curve I'm comfortable with. So, even in this hyper-competitive market, I will pass on a great programmer who cannot write.

Grammar signifies more than just a person's ability to remember high school English. I've found that people who make fewer mistakes on a grammar test also make fewer mistakes when they are doing something completely unrelated to writing—like stocking shelves or labeling parts.

And just like good writing and good grammar, when it comes to programming, the devil's in the details. In fact, when it comes to my whole business, details are everything.

I hire people who care about those details. Applicants who don't think writing is important are likely to think lots of other (important) things also aren't important. And I guarantee that even if other companies aren't issuing grammar tests, they pay attention to sloppy mistakes on résumés. After all, sloppy is as sloppy does.

That's why I grammar test people who walk in the door looking for a job. Grammar is my litmus test. All applicants say they're detail-oriented; I just make my employees prove it.

* Although often people who have learned English as a second language, even though they may speak with an accent, have paid fairly strict attention to the technical rules of the language and often outperform native speakers in tests of grammar and spelling.

For more amusement with regards to the discriminatory power of grammar, see John-Charles Hewitt's answer to I stopped dating a guy because he had bad grammar. Am I being unreasonable?

What are some good interview questions / tasks to test for attention to detail?