Wednesday, October 29, 2014

Around software developers problems

It's been a while since my last post. Today I want to tell you about problems affecting experienced programmer. As far as I know, it's not a problem to find tutorials on how to start out. There is also a lot of information about high-level problems like scaling architecture of your project and so on. While reading the next book about quality of code I was asking: "what about me?" - because I found myself between this two types: things that I already know and information on too high abstract level.

Image from: http://www.developerfeed.com

I decided to choose a few problems from the different kinds of developer workshop and place them in this article. They concern environment, psychology, lore and object oriented programming. Let's start:

1. Too little knowledge about your work environment.


You are a great developer, you have the skills, the knowledge how, you are perfect in design patterns and so on. You changed the job, because you want to improve yourself, you get better money and... have to learn your new environment. Other IDE, other tools and so forth. They look similar, but there are also a lot of differences. In that case, your tasks will take you a bit more time than they actually should. Changing the operating system is also a problem. You have to find i.e. a new tool to customize your system clipboard. As it's not possible to avoid this, you have to used to it. 

2. Blind faith in principles

Design patterns, quality of code rules, TDD and other methodologies. All of the rules were created to help us with some classic problems in the best, standard way. We can imagine them as a templates for our code. Experienced software developers use them every day. However they are not the mantras and "must have" things. In most of the situations design patterns resolve your problem, but sometimes it's just too complex or cost of refactoring is too high. Java is changing all the time. Old patterns are not as useful as they used to be. Look at visitor design pattern which decreases in importance because of DI (Dependency Injection). Singleton design pattern, once popular, now is an anti-pattern. Another great example is TDD methodology. It's a great technique, but I saw too many great programmers who stopped thinking because of it. They just follow the steps, writing horrible code for their tests (it works - and nothing more), and after that they were refactoring their code over and over again. In my opinion carving shit can be exciting, but it's not the best way to spend your time. Sometimes it's just better to think about what you want to do, use the white board and plan your code.  From my experience - it will set you up somewhere between xx+ TDD iteration and final version. So before you follow the rules, just be sure they suit your needs.

3. The routine


Many software developers (especially the best ones) are stuck in a rut. They always have a lot of work, the hardest tasks. After some time they start to use the same solutions everywhere, because they know them best. They stop looking for alternatives and start every (even new) project in the same way. It's the easiest way to kill self-development. Sometime ago I have seen a project, where technical decisions seemed to be strange for me. I asked why they used that technologies and I've heard: "Well, we always use this technology in all projects!". 

4. OOP code

Sometimes in the middle of the fight with the next release you can find something like this in the code:

public void casting(final Star star) {
  if(star instanceof Moviestar) {
   ((Moviestar) star).giveMoviestarEngagement();
  } else if (star instanceof Pornostar) {
   ((Pornostar) star).givePornostarEngagement();
  }
  // ...and so on.
 }

Instead of :

public void casting(final Star star) {
  star.giveEngagement();
 }

Of course it's the simplest example of misunderstanding the procedural and object-oriented way. But it happens all the time. Especially when deadline is coming. We always promise ourselves that we  will refactor it later, and often this "later" doesn't come.

5. Mixing the abstract levels

It's one of the hardest thing in Object Oriented Programming. Look at the code below:

public interface Pet {

 void feed();

 void cleanUp();

 void takeForWalk();

}

As you can see method takeForWalk() is on the wrong level of abstraction. It's possible to take a dog for a walk, but what with a parrot, cat or a hamster? That kind of function should be placed in the other interface (extended Pet or not), for example Walkable. Wrong abstract isolation problem is hard to resolve or improve in next releases/iterations or during the refactoring.

Conclusion

In our everyday work we are facing a various kinds of problems. Not all of them can be avoided, and not many of them are simple. It's why being a good developer is so difficult. I'm really interested what problems you have met before, and how do you managed them. I hope you enjoy that post, of course I encourage you to comment.

2 comments:

  1. Nice, but somehow I feel it's not enough. IMO each paragraph deserves for separate post, so... I'm waiting for more :)

    ReplyDelete
    Replies
    1. Thanks for your comment. That's right. It's the reason of the "Around" in the title. From the other hand there are a lot of problems and sub-problems in each category. All these problems make the programmer's job's difficult.

      Delete