I realized there could be a lot of bad code in a system while writing Java.

I wonder why schools don't teach what programming practices are bad. For example, in Java, using a big try/catch block that catches Exception is bad, but no one told me. And we see the typical "String + String" concatenation appear in every corner of a program.

Isn't it the job of schools, assuming most programmers are taught at a school and not self-taught, to warn students away from the pitfalls in a programming?

  • 18
    There are an infinite number of bad things. Only a few good things. Why waste time on all the bad things that are possible?
    – S.Lott
    Commented Feb 24, 2012 at 12:33
  • 1
    Real all the posts from people who never went to school. Those people would never be covered. Schools have a hard enough time teaching good practices.
    – Paul
    Commented Feb 24, 2012 at 13:53
  • When I was at school in the 80s, we learned a bit of Basic, complete with goto - basically because it was goto or nothing IIRC (though I admit I don't remember for sure - we might have had a while loop or similar). I thought most schools didn't teach programming at all these days. You're at school. Your chemistry/physics/etc isn't what a real world chemist/physicist/etc would do. And your programming isn't what a real world programmer would do. You're not really specialising much yet. But no-one is stopping you from looking into things a bit deeper for yourself.
    – user8709
    Commented Feb 24, 2012 at 13:54
  • I disagree with your question because it's to specific to your school. I'm student (last year) and I really don't have this feeling. All my classes are about programming scalable and permformant application based on efficient architechtual model. The example you used refer to performance tuning, and this domain can easily be learn with alone, school is here to explain concepts not to be so much specific on every details... Btw I should mention I'm in an alternate cursus (2/3 weeks in enterprise) maybe that's why school classes consider those domain. Commented Feb 24, 2012 at 14:15
  • IMHO a big try/catch block that catches Exception is usually not the best solution, but I wouldn't call it categorically bad. And the typical "String + String" concatenation makes the code easy to read, so most of the time it is best practice. Except when called many many times in a tight loop, where it may indeed degrade performance. Similarly, all idioms / techniques have their benefits and drawbacks, and they are applicable for some problems but bad for others. These details can only reliably be learnt during practice, as and when you actually need them. Commented Feb 24, 2012 at 14:36

5 Answers 5


If you are talking about CS degree at a university the answer is simple: programming is just a means to an end. The degree is more about the science of computing and not programming. Now, it may be a valid question for a community college/technical college program whose sole purpose is to create programmers.

To build on what S.Lott said in the comments, that there are an infinite amount of bad things but only a small amount of good, so why focus on the infinite bad. That is just for one language. So the university would spend all this time teaching the students how not to do something (and if they had time they may teach them how to do it right) for language X. So lets say that is 2 classes (the intro and then the "how to do it right class"). That is a full year of studies learning that one language, language X. The next year you want to take an embedded systems class which uses Y. So now you have to burn another year block of classes to learn Y and learn it properly. It just isn't realistic nor is it desirable because often what is good or bad can change. It is just something that can easily be learned once in the real world.


Two fundamental reasons:

  1. Projects you develop at school are not to be maintained in the future, you just get a grade and move on to another course. Therefore, even if you actually attempt to "enforce" some rules, most students will not realize the true importance of it. When I was at university, some teachers actually did the effort and gave some extra points for "clean code", but it was only when I started working and reading many peoples code that I actually realized it. It comes with experience.
  2. Some of the teachers never left the academia world and never had the responsibility to actually maintaining a project for a big team. Therefore, your code could be beautifully designed or a mess, and you would get the same grade as long as the output was correct and the algorithm efficient.
  • 13
    I would replace "Some of the teachers" by "The majority ..."
    – Doc Brown
    Commented Feb 24, 2012 at 13:41
  • Why does everyone have to hate on the Professors? When I went to school I had really great Professors. The majority of my Professors had worked outside of academia and many had "part time" jobs in the "real world".
    – Paul
    Commented Feb 24, 2012 at 13:56
  • 6
    I don't think this is "hating on the professors". It is simply a statement of fact that the coding requirements of academia and the business world are quite different.
    – Jaydee
    Commented Feb 24, 2012 at 14:19
  • Paul: well you are a lucky guy. other thing: a lot of project you do in school often to come out in the real world.
    – jokoon
    Commented Feb 24, 2012 at 14:19
  • 1
    @jokoon: Not your average high school or introductory college homework problem. Even my penultimate college course in OOA&D, which I aced, was based around a project that I would blush to put in front of my boss now. That's the current state of U.S. undergraduate study; you do learn a lot that is useful to your employers, but your first year at your new job will teach you more about actually doing the job right than any amount of study could teach you.
    – KeithS
    Commented Feb 24, 2012 at 16:06

First, I think it is a mistake to assume that there aren't a lot of self-taught programmers.

Second, there is a lot of room for debate about what is good code and what isn't. Some people are focused on readability, some on maintainability, some on efficiency, some on testability - and so forth.

Third, there is a big problem with how programming is taught - in the secondary and post secondary schools I've attended, at least. There isn't a good, cohesive, multi-year curriculum that can build year over year. Just about every course has to assume that there may be novices and veterans in the same class, so the course content ends up dumbed down so as not to leave too many people behind.

I'm sure that there are many university CS programmes that do have cohesive mulit-year curriculums, but there are many, many professional programmers with science, math, business and even arts degrees, not CS degrees.

  • Why put an or between all theses caracteristics ?
    – deadalnix
    Commented Feb 24, 2012 at 12:45
  • Cannot upvote enough ! Computer science are really new even today, there is so much progress to be made, it's going to take ages for education to teach it in a good manner.
    – jokoon
    Commented Feb 24, 2012 at 14:23

There is a massive general perception that school knowledge (specifically about programming) is useless or weak. This is actually not true.

In fact, ask an average fresher from school to write about code -she/he will right a bad code. But it will at least compile and run. Ask an average fresh electronics engineer (i was one of them!) to build an FM radio - he won't even be halfway through the job.

The problem is the classic difference between - knowing and realizing. Usually, there is enough of theory of you know from the college but you don't quite develop a judgment of where and how to use that knowledge.

For example Schools do teach you that violating encapsulation is bad. But many people don't quite realize that their code had done it - till long things become a problem.

The reason why development of judgment doesn't come by the time you leave school because you have only spent few months on real problems to solve. When you spent another 10 years in industry you repeat the same thing you learn't in your first year.


If a school puts too much emphasis on avoiding bad code they could be guilty of "premature optimization". For many projects in school only a portion of the code is used to demonstrate the understanding of the new material. Because there is a need to cover a lot of material in a semester, asking the students to go back and improve the code to save a few seconds of run time, will mean that less material can be covered.

At work you can say take a couple of hours to find the parts of the code that are a bottleneck and fix them. In school asking them to do that extends the due date for the project by a few days or a week.

There is no need to focus on what is strictly bad style, because every company does it differently.

I agree with the comment about the mixture of students in a class, especially in high school. Some members of the class have never seen an If statement, others are on their third language.

Not the answer you're looking for? Browse other questions tagged or ask your own question.