People and technology
RSS Feed


  • End of the world post mortem

    As we all know, on last Friday world was supposed to end.

    Luckily your friendly neighbor Java programmer found in the internet a piece of code responsible for running that, left by Evil Mayans, which looked like this:

    public class World {
    	private WorldDestroyer worldDestroyer;
    	public void end(){
    		Date endOfTheWorldDate = worldDestroyer.getApocalypseDate();
    		if(endOfTheWorldDate.equals(new Date())){;
    		}//no need for ending bracket as the world ends :D But Java compiler does not know that :( Feathered Snake damn you holy Sun!

    So what our hero could do?

    First of all he could delete the if check or even remove whole World class, however that would most likely fail some tests and would result in alarm raised by Evil Mayan CI server. They would know that something is wrong,  fix the code, hence the world would end!

    So he had to be smarter. Our hero sat and thought for some time, but not for so long, remember The End Of The World is coming! Using all his Java knowledge and team work experience he did the change!

    public void end(){
    		Date endOfTheWorldDate = worldDestroyer.getApocalypseDate();
    		if(endOfTheWorldDate.equals(new Date())){;

    So what he did? He used one of biggest flaws of java.util.Date MutabilityYes, you may change internal state of Date using one of it's method. No need for some sophisticated techniques.

    I'm doing all of Java interviews in DC, and it astonishes me how many people don't know that this class is Mutable. Yes, after instantiating it, you may change it internal value freely, which may lead to a lot of problems.

    It surprises me how many people does not know about it. During last interview, right before Christmas, Senior Java Dev (with >5yrs of experience) tried to convince me that the class is immutable and that may be one of it flaws.

    And what's the big deal?

    You should never trust in Date object, you've shared or received from external World (in OO terms -> outside your class).

    It is possible to build anything on top of java.util.Date. In most cases, no one will try to harm you, but I would not build large application / framework on top of that assumption. So while working with Date, you're going to learn everything about defense programming. Quick enough you'll understand that it's not enough to just copy input parameters, but you also have to return defense copies while returning values.

    But okay, let's stop bashing Date class for a moment. If you want to learn more about techniques that may be useful to work with it, please check the book that EVERY Java programmer should read: Effective Java by Joshua Bloch. It may not have anything about Date class, but it for sure shows how to achieve immutability and how to work with mutable code.

    Other good solution is to use 3rd party library, like e.g. JodaTime It will solve a lot of your problems. It's also quite popular, so most of the frameworks will provide support for it's classes.

    Ok, let's investigate second flaw of this code. It's not testable.

    You just can't test code that is dependent on time. It has to fail from time to time, raising false alarm. If you assert based on year, it may fail at midnight every 5-8 years. If you assert on month, it may fail before payday, etc. But don't worry, the battle is not lost yet. The solution is trivial: create an external class called Clock / TimeService / TimeManager / DateFactory or something along the line, consistent with you'r project naming convention, and just move instantiation of Date there. What we achieve this way? You can switch implementation of that class for test purpose and you won't get broken CI builds from time to time :)

    So how it should look like in the end? (at least this variant of code)

    public class World {
    	private WorldDestroyer worldDestroyer;
    	private Clock clock;
    	public void end(){
    		Date endOfTheWorldDate = worldDestroyer.getApocalypseDate();
    Now much better. Good that evil Mayans did not know about it :)

    Read More »

  • Blog resurrection

    Ok, so the world did not end. Everyone gets another chance to start a new, better, life. That deep spiritual experience has changed me, and showed me new path. So here we are, on my own, new site.
    I've done my part in the kitchen for Christmas Eve, and head to PC to clean up this place a bit.

    You can find now only two categories, all other meta informations will be in Tags. I'll also will try (again ;)) to try more frequently.
    Second change is that I'll be trying to write only in English here. Polish category is for older posts + I'll be linking to DC blog, were I intend to start blogging also.

    So let's see how it goes. :)

    Read More »

  • 33degree day3

    Session 1:

    Day 3 began with the same problem that I had during last talk on previous day. Venkat vs Nathaniel. I picked Venkat, as I expected that JVM languages integrate without any effort from developer, and abstract of his talk suggested something different.

    Venkat showed some edge cases when something may go wrong. And after all I'd do better if I went to Nat talk. However now I'm certain that I don't want to use in production any of the alternative JVM languages. Ok, maybe groovy for testing and tooling support.  But as the problems that I solve, are not complicated enough to raise  complexity bar of a project significantly, I choose to stay in pure Java world.

    I know, I wouldn't have to write semicolons or brackets anymore, but is it really worth it?

    Also we are currently recruting Java devs, and it gives us enough of problems to find them, so I don't even want to imagine how hard it could be to get experienced Scala devs.

    There are tools that allow for some coolness level. And as for ceremony in Java -> we got Intellij, and it solves a lot of problems related to that :) Also I like my brackets! Hands off of them. For some they raise readability.

    On the same page I feel that the time when Scala / Groovy / clojure or Kotlin (?) will be a must have skill, is near, so I have to reserve some time for learning them, soon.

     Session 2:

    Second talk for me, was by Ken Sipe. Pre that talk I didn't know much about noSQL DBs. I did some spiking, but I never even benchmarked it.

    Luckily, Ken thought about noobs like me, and started with high overview what noSQL is.Then he showed up project where he used MongoDB and some cases which gave his team a problem during implementation.

    As I don't know much about Mongo, I hope that this talk has been recorded and I'll be able to see it again later, when I'll learn more in the topic.

    Session 3:

    That was probably the hardest of choices. I had to choose from 3 great speakers and 3 different areas of my interest. To make it simple: I knew that I don't want to go about JAva 7 cloud talk, and Uncle Bob preaching about TDD. What I did not know, was do I want to learn more about Lucene, HTML 5 or Gradle.

    I picked Gradle.

    Szczepan had really hard time to decide whether he wants to show the basics (as most of the people never seen gradle before) or to go with the topic from title: building plugins in gradle. He tried two do both, and failed in my opinion.

    He'd do better by abandoning the plugin part and just doing introduction into the build system. More people would benefit and those of us that know that tool already maybe would see something new. Even if not, I guess that we would understood.

    As for me the most important part was after the talk itself as I had occasion to eat lunch with GradleWare team and ask couple of questions and make some requests regarding Intellij integration :)

    By the way. In June there will be my talk on Tricity JUG about Gradle.

    Ending Keynotes:

    After lunch there were 3 good talks. First one was by Nathaniel about Craft. As I heard it many o times by different speakers I skipped most part of it.
    Second one was by Jurgen Appelo, and I've also skipped it, but only because I've heard it recently as it's available on InfoQ. If you haven't seen it, go and watch it now! And I didn't skip it entirely, what you could see on my twitter stream.

    Last keynote was by Uncle Bob. One problem that I had with it was that it was a compilation of his other talks, and as I seen most (all?) of them, it was quite boring to hear all the punch lines again. Although it was good to see him live :)

    Some thoughts on conference itself:

    • It was great, like last year. I'll be there next year also :)
    • Number of must see talks  was too high. It was giving me headaches to pick where I want to be. Next year please invite some rubbish speakers ;) (e.g. me :>)
    • It was bit overcrowded (as many people noticed)
    • Grzegorz applied learning and fixed all the issues that I remember from last year.

    CU next year :)

    Read More »

  • 33degree day2

    Session 1:

    I started day 2 with some good old new desktop Java. Michael Heinrichs has been talking about Java FX usage in business. Topic reflected the presentation with small misstatement about business. It was very technical talk and for me it was bit boring (maybe because it was first talk of the day). I regret in the end that I haven't picked up one of other two talks that I wanted to attend. But at least I got some takeaways from it.

    As unofficial information Michael mentioned something about JavaFX applications working natively on iOS and Android. I don't know how that's possible, but it would be great :) Second thing is that I've learned that I don't want to go back to Swing ever again. JavaFX does not have the same threading issues as Swing.

    Session 2:

    After not so good start, it was time for Matthew McCullough brand new talk titled "Economic games in software projects".  He talked about various topics: from investing money into tools that we need in everyday work to showing simple tricks that make our products more attractive for our clients. Great talk, attend if possible.

    I graduated on University with specialization with economy and econometrics, so I often calculate cost bit different than most of my friends, as most people  doesn't count alternative cost. I do, and I'm glad that I'm not the only one in this industry ;)

    And again I've missed one interesting talk. But it was worth it :)

    Session 3:

    From all talks during this session, most interesting seemed to be Venkat with talk about concurrency in pure Java. I don't remember when I was solving threading issues for last time, however I remember that painful experience ;)

    Venkat showed us first different approaches to concurrency using alternative JVM languages, and followed that with traditional Java (using synchronization and locks). Then he presented a new way, using Clojure libraries. It looked dead simple and it's a useful  to know  about such tool. If needed then check Clojure ref and locks.

    And yet again I've missed two talks. But luckily this time it were Polish speakers and I hope that there will be occasion to catch up on theirs ideas (in fact Sławek Sobótka will be in Gdańsk this week :))

    Session 4:

    Time for some Spocking action with Luke Daley. I heard about Spock couple of times, and checked some examples, but I've never gave it a try. It  was a good overview of interesting tool and well invested time. What can I say more, just google for Spock and give it a go.

    Session 5:

    After 3 good sessions and not so bad day I went to Anton Arhipov talk about "Mastering Java bytecode with ASM". What I've learned is that there are better things to waste life than working with ASM :E As for talk itself, it had one very serious problem: it was too technical and focused on low level details.

    Do I really had to learn about all the code numbers and flags used by Java? It would be better, IMHO, if Anton abstracted more and talked bit more about other tools that use ASM. That talk is probably great for experts, but the rest of us was zombiefied in the end, so there were no questions and it was probably shortest talk of them all (as it went for about 30 minutes)

    Session 6:

    was a hard nut to crack. I really wanted to see Nathaniel Schutta but as Scala is a cool kid (and I had pleasure to attend to Łukasz Kuczera talks about it), I decided to check out language again (and from point of view of different speaker). That how I end up, on Venkat talk about Scala. As this post is getting long and I want to sum up this talk with another from Venkat, please check Day 3 for my thoughts on Scala.

    Session 7 (BOF session):

    That one was easy -> I knew that I want to hear about what went wrong in Touk and what they learned from it.

    They described couple of situations, how they approached the problem, what went wrong (in their opinion), and what is the proper solution (again: in their opinion).
    What was most interesting for me is how differently we've looked on the same problem, it's source and way to solve it. I won't give detailed description, as I don't remember examples good enough, but that reminded me, that I too often forget about such simple fact that people see different problems and have other ways of solving them.

    Day end up in discussions and socializing :)

    I also met Guys from JRebel and got one of their stickers. It went with me to UK, and through 3-4 major Polish cities + countless small ones. Should I invoice them for promoting JRebel? ;)

    Read More »

  • 33degree day1

    It took me a while to write down those relations, but right after conference I was coming back to Poland and that meant packing and other boring stuff, then climate change and small cold, catching on old projects and ... ok, I was just lazy :)

    Let's start from the very beginning. Like last year I've arrived two days earlier. One of side reasons why 33degree > any other conference is that it takes place in Kraków. You attend to great conference and got whole weekend in one of  most beautiful Polish cities. Also same like last year, Grzegorz thought even about booking nice weather for the weekend, it was warm and sunny for whole time :D Thanks for that! ;)

    Session 1:

    On Monday (day 1) weather was more friendly for attendees. First talk was by Raffi Krikorian from Twitter. He told us about migrating  Twitter from Rails towards JVM (read Scala). What I really liked is that he presented a lot of impressive numbers about Twitter. I've listened up to a moment when he showed the code. That was just too early in the morning for it and I was still before my first coffee.

    My takeaway from that talk is that rails are production ready and can support very large site. If you grow as large as Twitter did, then you can afford to migrate to some other platform. Or to ease future migration you can start working on JRuby from day 1 ;)

    I went for a coffee and while passing by, O'Reilly stand just sucked me in with 40% discount. I did as I always do when I see books: I've checked them all: touched, sniffed, took a peek inside everyone of them, to do what any reasonable and well educated man would do, a week before moving back from foreign country and while trying to reduce his baggage size: I bought one. Maybe it will learn me how to think and learn pragmatically.

    After that I had enough of time to I stop by Luxsoft stand. Well it was quite obvious choice as else their ninjas would just tear me into pieces! For tad of my time (and filling a short form) I was rewarded with a ninja t-shirt :) But had to evacuate right after that as they asked me to solve a problem (I still was before that first coffee. And what the hell!  Me and thinking!? Maybe that book gave them a wrong idea?)

    Session 2:

    By the time that I've dealt with first coffee and said hi to many familiar faces it was time for second session, by Ken Sipe. It was about complexity and how we, developers, tend to mix up two ideas: complexity and complicated. We also like to make simple things more complex than it's needed. Hard not to agree. Session was nice and it kick started my brain better than the coffee.

    Session 3:

    Next session was by Venkat Subramaniam. His talks are always fun to watch, and this time it was no different. Thanks to it I could relax before git workshop. Venkat showed 5 whys technique and explained where it come from. The talk had anything that is needed to pump up any g33k. There was Dilbert, rockets and horse butts. Awesome!!!

    Thing to remember: "Hand out with smart people" (probably he should say -> go to ;))

    Session 4:

    Lunch was great, as usual on 33degree. Kudos to Grzegorz for making sure that there will be real food. And after lunch it was time for git workshop with Matthew McCullough, the only reason why  I brought laptop with me to Poland. Session was fun, I always enjoy Matthew talks. I never seen him unprepared. He knows the subject and his presentation perfectly. Whats more he has no problem with answering questions. Seriously, if you want to see well prepared presenter go to any of his talks (or Neal Ford, who is also always well prepared speaker).

    As I knew and worked with git before, the session was more of a chance, to structure my  knowledge better  and get some tips from expert. It was good decision, although I would like to see Kotlin live. Well, maybe next year :)

    And that's how the day went by. Well almost, there still was beer party from JRebel guys and integration with people, which is the best part of any conference :) Discussion about differences between living in USA, Australia and Europe :D

    Read More »

Michal Gruca
Michal Gruca

Manager by title, developer at heart

Twitter Email