Tom's Blog

From tech to non-tech

Writing Testable Code

| Comments

Last week I watched 3 half an hour videos about how to write testable code. These videos re iterated a lot that I already knew but in a way still opened my eyes. I found them cool enough that I would like to share these with you and I think that if you watch these you will be able to write more testable code starting from today!

The Clean Code Talks - Unit Testing

  • Introduction to the series
  • It is not about writing tests it is about writing testable code
  • Explains and shows hard to test code
  • Goes over different levels of tests and argues about their importance
  • Explains how to write more testable code

The Clean Code Talks - Don’t Look For Things!

  • Globa state and how it will hurt your tests
  • Law of Demeter
  • Dependency Injection
    • Business logic
    • Wiring and creation logic

The Clean Code Talks - Global State and Singletons

  • Global state and insanity
  • Singletons and singletons
  • Deceptive APIs

Conclusions

Writing tests is easier than you think but for easy tests you need your code to be set up in a way that makes it easy to test!

Jenkins - Disable Reloading

| Comments

I’ve been doing some Jenkins plugin development. Just some tweaks here and there. One thing that bothers me a lot is the console reloading. So whenever you are on the console and by accident press the ENTER key (I sometimes do that to clear some screen to see when new Exceptions start) and a redeploy happens instead. Usually I run out of memory during the reload also.

When you run your mvn hpi:run it will say that some sort of reloading is enabled.

[INFO] Console reloading is ENABLED. Hit ENTER on the console to restart the context.

Of course no information on how to disable this. By googling around I finally found the solution!

-Djetty.consoleForceReload=false

So hopefully next time you google for the message you’ll find this flag quicker. You can consult this Jetty Issue for more information on the console reloading trigger.

AWS Pricing - a Link to Remember

| Comments

We use Amazon Web Services a lot at ZeroTurnaround. Every now and then we talk about the cloud and I need to check some prices, especially EC2 and RDS. AWS pricing page goes into so much detail that I get lost. Here is a document that me and Juri try to keep up to date. Feel free to ping me when it has changed again. I’ll also embed into a frame for quick access.

Skype Bot for Fun and Profit - Part II

| Comments

This is a post from the Skype Bot for Fun and Profit series. This is the second part in the series and if you want to get your bot running you will need to have some prerequisites filled out, see the first part.

Configuring and running

There is a skype-bot project at github. It is written in Java and has support for simple functionality. You can clone it via:

git clone https://github.com/toomasr/skype-bot.git

The project is maven based and once you import the project into your favourite IDE that has maven support it should compile out of the box. Before we can actually run the project we need to make couple of adjustments. First make a copy of the project.properties file and make it personal.properties. Then change the username, password and pemfile attributes in the file. Make sure that the folder that has the pem file also has a der file that has the same name (except the extension of course).

Skype Bot for Fun and Profit - Part I

| Comments

This is a post from the Skype Bot for Fun and Profit series. This is the first part in the series and will let you configure everything needed before we actually get to the code part.

Join the Skype Developer Program

A lot of necessary documentation and also software is behind a login screen at Skype Developer Program. You will need to join the program to continue and log in. This used to cost 10$ but I’m not sure if that is true anymore (if you sign up and find out, let me know!). I personally don’t like the monetary fee for documentation and a SDK but I’m happy this is not 100$.

Now the biggest challenge has been conquered and you can also open up Skype’s own Getting Started Guide. That guide will go into more details with some of the next steps, so if you get stuck here be sure to check their documentation also.

Skype Bot for Fun and Profit - Intro

| Comments

This is a repost from now already closed dow.ngra.de blog Couple of months ago I was travelling and found myself in a hotel room with many hours to kill. For no particular reason I started hacking on a Java based Skype bot. Couple of weeks later I took the time to polish it and enable it for company wide notification chatroom. Now couple of months later I’m on vacation and will write about how to write a Skype bot in Java.

The Plan

The Skype bot needs a bit more work than your average IRC bot because of the proprietary nature of Skype. There is much clicking and downloading of certificate stuff to get you started for example. Also I want to show you how to put the bot into action, so we will go beyond just the bot.