Thursday 28 March 2019

Did you ever do this?

So I was working on a class which was too big. Time to pull it apart into helper classes (in the same package). Then I noticed a number of methods were protected.

Now protected means it can be both accessible from subclasses as well as classes in the same package. (That last part is often forgotten by me.)

Which means when pulling things apart into classes, I can simply call these protected methods. Yay!

Unfortunately, these protected methods were defined in a superclass and the superclass was declared in... you guessed it... a different package.

The ugly hack that solved this is the following:

Of course, I deleted this, because to my mind overriding a method, just to increase the visibility is a huge code-smell. (Or isn't it?)

But I was wondering if anyone else ever did this? (due to time pressures and not being able to change the super class, etc.)

And what would be a more pretty work around, if you have one?

Thursday 21 March 2019

Angular

The blog about Angular JS (http://blog.angularjs.org/) has moved (last year already) and is now, as it should be The Angular Blog.

It can be found at https://blog.angular.io/.

Thursday 14 March 2019

On Rewriting Software

I came across the reference1 below on "rewriting" software, and it struck a cord with me.

Turns out that, as is so often the case, the fact where "you should never ever do that"2 has its successful exceptions.

References

[1] Lessons from 6 software rewrite stories
https://medium.com/@herbcaudill/lessons-from-6-software-rewrite-stories-635e4c8f7c22
[2] Joel Spolsky - Things You Should Never Do, Part I
https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/

Thursday 7 March 2019

Adventures in Shell Scripts

A very simple and short blogpost today, sorries.

A colleague decided to automated some simple task by means of a shell script.

This script caused the following error:

rm: cannot remove 'tmp/*': No such file or directory

I quite quickly (after adding -f to defeat the are-you-sure-prompt) found out that double quotes indicated that it should take stuff literally. In this case the script was trying to actually delete the file tmp/*, and not finding it.

The shell did not expand the * properly when encased in double quotes.

A simple example for you to try if this is the case in your environment would be:

echo *

Instead of

echo "*"