Metu Jump – for aspiring programmers

Programming is the art of compromises. Programming is the art of good decisions. Programming is the art of breaking down a task into smaller tasks.

They say that programming is craftsmanship. This sounds better, because you don’t need to be a genius to be a craftsman. All you need to do is to practice. Practice what? How? Continue reading

Posted in programming | Tagged , , , , , | Leave a comment

But we do – breaking the coding guidelines

A colleague asked me to help him learn java and object-oriented programming. He has solid background in VisualBasic and SQL. This is cool because I don’t need to explain things like the while loop or recursion. We can focus on the syntax first, then double-check Clean Code and we’re done, aren’t we?

Object Oriented Programming

This might be a fast lane for aspiring java developers. However, I still cannot define what does good Object Oriented code look like. There were so many contradictions during my education and career. I’m not sure if I should spare him this journey. Continue reading

Posted in java, programming, Uncategorized | Tagged , , , | Leave a comment

Habits or constraints? A developers story.

There’s a story with the monkeys and the ladder and the shower. It’s easy to see how metaphoric it is. Continue reading

Posted in programming, soft skills | Tagged , | 4 Comments

The agile waterfall

Sounds like a BS post, doesn’t it? Agile processes are like XP, Scrum, Kanban, etc. Waterfall is not an agile process, period.

Well, actually… The agile manifesto values Individuals and interactions over processes and tools. Then, let’s take a look beyond processes! Continue reading

Posted in programming, soft skills | Tagged , , , | Leave a comment

Why you should lie on a job interview?

This is an old advice: don’t lie on a job interview. The reasoning goes like this: don’t lie on a job interview because you’ll get caught and id impairs your relationship with your employer. They might even fire you.

This is a really good advice, as long as you’re seeking a job. If you’re an employer, then this doesn’t apply to you. You should lie instead. Here is why:

Continue reading

Posted in soft skills | Tagged , | Leave a comment

The ultimate java Tuple

The idea came to me via this SO question. The is a question about generics. Probably it’s too much foreshadowing in a technical blog, but this post is about generics too.

Tuples

First thing first: what’s a tuple? It’s a mathematical buzzword for ‘one-thing-and-another’. We call it a pair, right? Mathematicians like to have their definitions generalized. No wonder, the Tuple is a little more than a simple pair. Continue reading

Posted in java, programming | Tagged , , , | Leave a comment

Can anyone write clear specification?

I’m a skeptical engineer who thinks, specification / documentation is never ever obvious. I believe the unambiguous and comprehensive stuff is code, not documentation. When I say unambiguous, I mean the computer can interpret it in only one way, yet people can easily misunderstand it.

We can observe this problem in mathematics too! Continue reading

Posted in java, programming | Tagged , , | Leave a comment

Testing a subclass-as-wrapper

The problem

I’m working with an oldie-but-goodie framework. This framework has some interesting naming conventions. Say for instance, they call subclasses wrappers. We can use subclasses and wrappers for the same thing. However, one of them is more testable than the other.

Let’s see the similarities first. Suppose you have a MessageProcessor class and that has a transformMessage method: Continue reading

Posted in java, programming | Tagged , , , , , , , | Leave a comment

Just a little scripting

Scripting on Windows

There’s this flame war between Linux and Windows. Like Linux is user-friendly, it’s just more selective with its friends. Another one is, that it’s easy if you don’t mind clicking. Windows 10 contains a bash shell, still, this won’t end just now.

So, there is this flame war, old and still funny. But this post is about something else. I’m trying to explain why I always install a cygwin / mingw on a corporate windows box.

Obviously, I install them because we’re not using Windows 10 yet. Also, I’m installing mingw because git-bash is based on that. Still, this isn’t the real reason.

Why is it useful?

The real reason is that I can solve complex problems quickly. Say for instance, the jd-gui had some problems. It couldn’t decompile some classes and it wouldn’t save all the decompiled sources either. I could’ve downloaded some other versions and played with them. However, I already had mingw and procyon on my machine so I started to write a for loop. In a couple of minutes I had this:

cp -r classes sources # this creates a paralel directory structure
find sources -name '*.class' | xargs rm # this removes the class files

# a for loop through the classes. I could've excluded the inner classes too..
for f in `find classes -name '*.class'`; do
  # creating the name of the destination java file
  j=`echo $f | sed -e 's/^classes/sources/g' -e 's/.class$/.java/g'`; 

  # invoking the decompiler
  java -jar /f/Programs/decompilers/procyon-decompiler-0.5.30.jar $f > $j;
done

The point here isn’t the code. Bash can do loops, branches, and other stuff in a weird way. The point is that I could substitute some gui functionality with some code in a couple of minutes. It took as much as starting up eclipse and creating a new project.

It’s not only useful. Writing code seeing it run instantly – it’s almost magical. Others might prefer the REPL for Lisp, python, powershell or ruby. Still, bash is the most ubiquitous from all above.

Enhancements

So, I wrote this one-time script. There are a few enhancements I could’ve made.

I.e. this is how you can filter out the inner classes from the decompiler loop:

for f in `find classes -name '*.class' | grep -v '\$'`; do
  #...
done

But deleting them isn’t much harder either:

find . -name '*.java' | grep '\$' | xargs rm

I can also mass-edit the decompiled classes:

# a loop for the java sources
for j in `find src/ -name '*.java'`; do
  # retrieving the java class name from the path
  f=`echo $j | sed -e 's/^.*\///g' -e 's/.java$//g'`;

  # creating the command - it will be useful for debugging
  cmd=`echo "sed -i 's/\b$f\.//g' $j"`;
  echo $cmd; # some feedback during the script run
  eval $cmd; # invoking the actual command
done

Other approaches

As you can see, I’m using sed and command substitution extensively. There might be other approaches that I’m unfamiliar with. Still, these tools help me a lot to solve complex problems quickly.

What now? We can follow @climagic. We can learn how to parametrize procyon to do what we want. I could learn awk.

What are your favorite command-line tools? How could you improve these scripts?

 

Posted in programming | Tagged , , , , | Leave a comment

How to deal with criticism

In the previous post we saw how we can help a low performer to work better. In this post we’ll see the flip side of that story. Sometimes you’re at the receiving end of this help. Which is, very bluntly, criticism. You need to be able to deal with that.

There are several types of feedback. I’ll show you here how to deal with them. Continue reading

Posted in programming, soft skills | Tagged | Leave a comment