Difficult and Obscure Code

I thought about it a bit about what difficult and obscure code is. I suppose there are two trains of thought, one is the guy who writes the code purposely difficult and, or obscure. The other is the guy who writes code and seems difficult or obscure to other people. The former should be avoided at all costs. The latter I have some difficulty understanding the motivations around why someone’s code seems difficult or obscure.

I think I can write more on this or split the topics in their own posts, but I think this post gives some insight in to my thoughts on the topics. As it stands on its own, I think I’m happy with the post.

So if no one can read my code I can keep my job?

People write difficult and, or obscure code purposely may do so because the reasoning is that, if the project is too costly to rewrite, then the original coder will always have a job. I do not subscribe to this, partly because I’ve never worked on a project that went long enough that I couldn’t be replaced and partly, so that I can understand my own code.

I’m still a junior developer, but my comprehension of code has improved vastly, so that I rarely come across old code that I do not understand. That said, experience gives a lot of insight to better solutions and well, when you have failed so many times, finding the correct solution sort of comes naturally. For some problems, there are only so many solutions that can be attempted.

When you are dealing with code and database structures, it is difficult to get those out of hand. Well, at least in most DBMS, but at least one has improved a great deal from its initial offers that the developers using it haven’t fully grasp the “proper” way to utilize them (Well, I give the plural, but I really only seen one, in his defense, he most likely didn’t intend it to become the way it is now). Most likely, the project could be on the daily WTF, if more than one developer worked on the project.

Trust me, you would run screaming if you seen the horrors of the way the database is structured. Well, that is to say, that the tables are not normalized, but primarily that the application itself runs off of views. That is, many, many views. These views are connected in a jumbled mesh and some of the views aren’t actually used any longer.

The sad part, is that we joke about the above header question, but I do sometimes wonder. Well, the sad part, is the developer doesn’t come from a programming and DBA background, therefore most likely the mess is from ignorance rather than intent.

Everyone’s Code Sucks To Everyone else

Code smells aside, it is a general fact that most developers will have difficulty with another developer’s code. If only briefly. That is basically the point of class patterns is to offset the troubles other developers will have with the code. Well, given that the other developer also knows about the class patterns.

I believe there is a difference between “Your code is difficult,” and “I spent 30 minutes trying to wrap my head around your code and I don’t understand it.” The former suggests to me that you didn’t bother to understand the code and are blaming me for your lack of understanding. Furthermore, unless you lack the skill set required, then you should be able to grasp the code fairly easily and quickly.

It is easy to say to another, “Your code sucks.” However, this leaves too much to the imagination. Why does my code sucks? Is there code smells? Does it not follow the correct class patterns, violates OOP, etc? People who tell me that without any explanation are ignored.

Growing as a Developer

The issue I have is that I want to grow as a developer. I want to learn, by not telling me about the problems in my code, you limit my ability to take heat and learn by reason. I’m not always correct, however, no other programmer always correct either. I distrust the programmer that states that they don’t make ever mistakes.

The point of growth is to realize the mistakes and learn from them. Part of risk is screwing up and never doing the same mistakes twice. Part of experience is that you have already made those mistakes and learned from them. If you aren’t making mistakes then you’ve either made them all and can’t grow any longer or you stopped attempting to make mistakes.

I think this is partly why working in a professional environment is limiting. Sure you learn a great deal about deadlines and how to quickly accomplish them. The problem is that part of the environment is that you are encouraged to not screw up, therefore your only option is to always use what you know. The reason this is limiting is that it does not leave you question whether the solution you are using is the best one, just is the one you’ve used and proven to work in the instance that you used it in.

Experience vs Knowledge

The problem I have with experience is that it does not equate to knowledge. Knowledge does not equate to experience. The problem I have with someone saying that they have 10+ years of experience, is that it says nothing of what they learned during those 10 years. If they basically worked with the same failed solutions over and over again without learning shit about why different techniques work and why others don’t, then I don’t consider their time well spent.

The goal of a developer is to grow in both experience and knowledge. I believe the phrase is, “Sharpening your saw.” A developer might have 10 years, but only spent 1 or 2 years learning and then just applying the same tested techniques and algorithms. So you know, they can tell you everything about doing it their way, because they have been doing it the same way for all those years.

The problem is that while I have been spending the last 5 years improving and trying new things, the 10 year developer thinks that 10 years is greater than my 5 years. True, when you look at the raw numbers, the math, 10 is greater than 5. However, I’ve spent 5 years doing new things and testing the results verses the 1 or 2 years of the other person doing new things. When you look at it that way, I blow the other guy away.

When you do the same shit over and over again, that isn’t experience. You have to get your hands dirty and try new things, else you’re going to get left behind.

Of course, I haven’t spent four years in college under a computer science degree, but I’m planning on it. It is on my list of achievements that I want to complete before I turn 30. Took too long on the Networking A.A.S degree that unfortunately I’m never going to use. I can get an A.A.S in Web Site Development (or whatever the technical college is calling it) in about 18 months, if I go full time (which I’m not). If I started this year, I could get it by the time I was 25, but I’ll most likely be 26 or 27 by the time I receive the degree. I’ll be going to MSU sometime after that for the Bachelors in Computer Science. After that, I hope to go to a school for computer game development and learn how to do that.

Stages of Developers Level

I consider myself a mid-level developer, because really, with all that I currently know, I still know that I don’t know enough. Therefore, the way I assess people is based on what I know and my experience. If you match my level, plus more, then I consider you to be my senior. However, if you lack what I know or lack my experience, then I consider you to be my junior. Generally, I consider other developers my equal until proven otherwise.

The difference between knowledge and experience is the matter for which solutions are developed. Experience will tell you whether one solution is better in a given instance than another solution based on past failed attempts. Knowledge just gives you the tools for developing solutions to the best of your ability. That is to say that you might have the knowledge for which a given problem has two solutions, but it is experience which allows you to choose the correct solution.

I suppose the issue I have always had, is that as developers we are tasked to develop solutions. Doesn’t matter which one, just that it solves the problem and doesn’t create new ones. However the world of solutions has many factors to consider.

  1. How does this solution affect my ability to extend and fix problems in the future.
  2. How well is the solution developed based on my current knowledge set? Does it fall into the well-defined practices of OOP, procedural, etc?
  3. How well can someone else work off the code?
  4. How quickly can I develop the solution given the time frame?

The third question kind of is what trips me up, because there are two different trains of thought. Really, there are two questions. “How much difficulty and time spent will another person have trying to extend and fix problems?” and “How well can someone understand the given code to use it without too much documentation?”

A great reference can be found in the answers for this question.

Possibly Related Posts:


Comments are closed.