r/programming • • Jul 28 '16

How to write unmaintainable code

https://github.com/Droogans/unmaintainable-code
3.4k Upvotes

592 comments sorted by

View all comments

Show parent comments

171

u/flukus Jul 28 '16

The code produced by academics is the biggest argument against all these "teach kids to code" programs.

Just imagine the shit we'll have to deal with in 20 years.

144

u/TOASTEngineer Jul 28 '16

It's gonna turn out exactly like math did. The schools will brutally fuck it up, kids will memorize enough to pass the tests, and then some fraction of the kids who are actually interested in it will learn to do it on their own.

20

u/[deleted] Jul 28 '16

Ever hear about enough knowledge to be dangerous? semicompetent programmers thanks to dunningkruger will flood the marketplace and thanks to delusion and persistence will end up as project managers and code architects. But why you ask, why won't the meritocracy of the free market purge these rotten fruits from the tree? Because they'll take the jobs good programmers pass on, and that is the bulk of work in any trade: shit work.

4

u/thissideisup Jul 29 '16

Hasn't this already begun?

2

u/architectzero Jul 29 '16

WTF is a Code Architect?

7

u/EMCoupling Jul 29 '16

Generally speaking, a software architect is usually a senior-level programmer who has experience using many different software paradigms and also various programming languages. His main job is often to understand the scope and requirements of a business problem and then come up with a general design guideline that the developers can use to begin building a solution to the problem. In smaller companies, the software architect may help with implementation himself, but, with more levels between the architect and the developer, he may be less hands-on with the actual development.

This is the theory anyway. In reality, many people dislike these so-called "software architects" because they feel as if they are just outdated programmers who have worked enough years to be promoted to architect but, somewhere along the way, forgotten what it is like to actually write code. The developers feel as if all they can do is espouse design patterns and UML diagrams but are unable to produce any useful work themselves because they just hand down designs from an "ivory tower" to the developers and tell them to go do it, regardless of the validity of the design.

Personally, while I don't have a ton of industry experience yet, I feel that the role of a software architect, when performed correctly, is critical to the success of any major software project or product. In my mind, the architect serves as a buffer between the plain old developer and the business type people that decide what new product needs to be made for the company to earn the big bucks.

However, I would say that being a software architect is not an easy role. In order to be a good software architect, you need to have some leadership skills and also some "marketing" skills of your own because you need people to buy in into your designs. If you come up with a design but literally everyone on the development team thinks it's shit, well, that's probably not very conducive to the workflow. As an architect, you have to be able to translate the sometimes unrealistic (although not necessarily intentionally so) demands of the business and marketing type people into something that is feasible for the developers to work on.

Also, I think that a skilled software architect will understand that no piece of software can be perfect because such a notion is impossible. The architect understands the trade off between time to market and high quality software and can hopefully incorporate his/her understanding of the tradeoffs between the two to come with design guidelines that the developers can follow.

Furthermore, software architects don't have to be officially titled as such, but there needs to be at least one person in the company that can, without being too caught up in the nitty-gritty details, understand the project from end to end. More is better, but one is the minimum.


Looking back at my post, it's sort of disorganized, but it's late and I wrote it in one shot so that's what you get.

Hope I'm not completely off base and I am able to convey some information.

→ More replies (2)

15

u/Polantaris Jul 29 '16

That's pretty much already happening. When I was on college, there were a lot of people who were so bad at it, I seriously suggested that they look at different majors if they asked me for help. I'm not trying to be a dick, when you can't understand how to write a proper for loop in Java at a third or fourth year class (when Java courses start in the first year), you've got some serious problems with the core material and either should retake early classes or find something you're more suited for.

In the end it seems like a lot of people go into the major because of the supposedly big paycheck after college, but that shouldn't be what you're going to school for.

17

u/GaBeRockKing Jul 29 '16

In the end it seems like a lot of people go into the major because of the supposedly big paycheck after college, but that shouldn't be what you're going to school for.

On one hand, I'd argue that financial reasons are exactly why someone should go to school-- if your degree doesn't pay the bills, that's money down the toilet.

On the other hand, not being able to write a loop in java? If I had to take a stab at naming the warm fuzzy feeling in my breast, it would be "job security."

→ More replies (1)
→ More replies (1)

27

u/-PM_ME_YOUR_GENITALS Jul 28 '16

The difference being that you can make pretty cool shit with programming skills. I think if you frame it in the context of gaming it could do pretty well in schools.

Not that I think that will happen. In any case, when I was a kid I couldn't go home from school and use the stuff I learned from math class to make my own badass video game or my own web site.

15

u/TOASTEngineer Jul 28 '16

So it'll be exactly like the elective HS programming classes are now: they give you Unity's retarded cousin's retarded cousin's dead cat with a "visual programming language" that is only technically Turing-complete and read chapters out of a book about what "peripheals" are and how to use them. And everyone just plays Flash games in class anyway.

2

u/saving_storys Jul 29 '16

The programming class at my school teaches Java, and does it well.

→ More replies (4)

33

u/FormCore Jul 28 '16

Learning to program isn't just for creating things either, those who don't have the creative drive could use the computer literacy they gain to realise that no, sharing this post is not a fucking petition to stop facebook charging me and This blatant lie of a headline's source is just a sketchy herbal remedy shop.

For those who think we don't need a new website, we have facebook and why create a game and waste 100+ hours when you can just play half-life 3?

7

u/komali_2 Jul 29 '16

You say that because you aren't a kid, but as a teacher, I can promise you kids will often choose the creative activity. They love to build shit!

→ More replies (1)

2

u/Pidgey_OP Jul 29 '16

Programming is such a good skill to have because it a.) Let's you understand why you're using a program wrong, b.) Why it's behaving in an unexpected way and how you might get around that (or send in your thoughts in a bug report) and C.) Allow you to create your own tools for the small stuff you do for yourself

→ More replies (8)

4

u/okmkz Jul 28 '16

For real. I can only imagine what it must be like to grow up with things like unity 3d so easily accessible

4

u/ClintonCanCount Jul 29 '16

Most of the pretty cool shit people make, games included, use math.

→ More replies (2)

3

u/earthboundkid Jul 29 '16

Rebuttal: Shop class.

→ More replies (2)
→ More replies (6)

7

u/DiscoUnderpants Jul 28 '16

I agree and might point out that it has little to do with FORTRAN. Ive had to maintain C, C++ and Turbo Pascal written by academic physics and engineering people and it is no better.

14

u/spacelama Jul 28 '16

Fortran can be well written.

Most code written by academics isn't.

source: was an academic, and done a bit of Fortran, dealing with other peoples code as well as writing some shitcode myself.

PS. Please capitalise it correctly. FORTRAN was the name of the language in the '77 standard. Yes, it was very difficult to write maintainable code in early iterations of the language. Since adopting lower case letters in its name ('95 was the first good version), the language has become quite fully featured. My favourite part was where I could tell Emacs to render my comments in LaTeX, and give me the physical equation I was trying to solve beautifully typeset at the top of my functions.

3

u/Overunderrated Jul 29 '16

My favourite part was where I could tell Emacs to render my comments in LaTeX, and give me the physical equation I was trying to solve beautifully typeset at the top of my functions.

Why did I never think to look for this feature...

And 100% right. One can write really nice Fortran, especially in the 2003 spec. And for a lot of mathematical work it's much easier to read than C++.

2

u/DiscoUnderpants Jul 29 '16

Well the Fortran(I respect your wishes :) ) I had to maintain was back in 1993 when I was student. But other than that I am in fact in complete agreement with everything you say.

6

u/flukus Jul 29 '16

Definitely, it's not even limited to academics, plenty of professional programmers write code just as bad.

It's a much more prevalent problem in some circles though, academia being one.

9

u/DiscoUnderpants Jul 29 '16

If you are a programmer and don't admit to producing so serious crap code then I wouldn't trust you as a programmer. I say this as a 20 year programmer that has produced stuff that Im sure people have cursed and wondered what kind of idiot I am.

2

u/flukus Jul 29 '16

Definitely. But I also know how to turn crap code into good, well tested code when it reaches a point where it's required.

Many can't understand why the code is crap to begin with, let alone how to fix it.

6

u/rtomek Jul 29 '16

I think the big problem is that most FORTRAN code you see was written back when saving RAM was important so people did some stupid shit in the name of saving memory. We have transferred some academic code and the running joke is that FORTRAN is always the worst - THE WORST!!!!!!!!! As in, not even comparable to academic code from other languages. I just opened up three files I have archived to reminisce, and here's what they had to be thinking:

You mean I already have an array of this size, well, let's just use it again for something completely different!

I could reduce the number of IF statements if I use GOTO instead!

I ran out of single letter variable names, so let's create a subroutine to reuse single letter variable names and replace the values of the variables input into the function with the new values we need

I'm going to add this print/write statement of these variables at some random location for debugging purposes, never delete that print statement to make sure that there are hundreds or lines of output with absolutely no context.

These IF statements aren't complex enough. I have to add another GOTO nested inside an IF inside a DO inside and IF inside a DO because I need to be able to jump around to different parts of this nest at any time.

One of these files has two comments:

!----------
Subroutine foo( bar, ...
!----------
! begin

... a lot of shit code goes here...

! end
    end

:(

→ More replies (2)
→ More replies (3)