Pages

Tuesday, April 11, 2017

Refactor switch to Enum

Do switch statements sound good to you? 
Trust me better switch to Enum before it destroys your ears ;)



Monday, April 10, 2017

Mocking static method calls

Very simple example on how we can use method delegation to enable unit testing where there is a dependency to an static method call.



Friday, April 7, 2017

I love my new keyboard :)

Hello World! Look at my new keyboard:
comfortable, noisy, smells of bambu, spacious, feels dry and fresh all the time, nice polished surface finish, not hypersensitive to touch, resistant, doesn't need batteries, only relevant keys, free included mouse...  Using it for a week already, it works great. I just love it! :)))))))


Refactoring "Feature Envy" Code Smell

In this video I explain the "Feature Envy" Code Smell and how it can be refactored. Sorry I made a mistake in the screen casts and I just selected the window rather than the area, you can't see the pop up menus and auto suggest when I press Ctrl + Space. Sorry about that :(( It takes me some time to make videos but if I get the chance soon I will repeat the demo and re-upload it.


Thursday, April 6, 2017

Dealing with Hardwired dependencies part 2 - Making a design decission

In this second video, I make a design decision and I remove the temporary refactor that I did earlier.
The Seam was not a bad idea, but it was a temporary solution only until I make a decision about the design of the class.


Dealing with Hardwired dependencies part 1 - An alternative to Dependency injection.

In this video, I show a little refactoring trick that can be used to unit test a method that has a hardwired dependency to an external system via an static method call. This is an alternative approach to dependency injection, which can be used when we are not sure about modifying the design of the class. In very large systems making design decisions such as adding another method to a constructor etc ... may have a big impact in design of both production and test harnesses. This trick can help you temporarily postpone your design decision and get you going with your unit testing.



Wednesday, April 5, 2017

Observer Design Pattern in Java

A very interesting, useful and popular design pattern that I like. Here a video with explanation and code example:


Share with your friends