Force Return in Java

Lets say you’re in the debugging session and you would like to return some specific result from the method in your IDE. Usually I was using Variable window in order to achieve this. However there’s a way simpler approach available in IntelliJ and Eclipse named “Force Return”.

Screen Shot 2017-03-20 at 12.30.16

Screen Shot 2017-03-20 at 12.30.32

Posted in Development, Tips, Uncategorized | Tagged , , | Leave a comment

My First Public Presentation

It took me a while but here we are. Many thanks to the JProf community for providing an opportunity to present about MySQL to Cassandra migration at the meetup.

Slides can be found here.

It appears to be rather hard to prepare presentation. Raw estimates of the preparation time are the following:

  • 4 hours for the initial slides preparation
  • 6 hours for the initial text transcript
  • 10 hours for the internal review process and adjustments based on comments
  • 8 hours for the real meetup preparation
  • 2 hours for the meetup itself

So it took around 30 hours of work in order to have one hour presentation for the local meetup. Hopefully it’s all because I’m not an experienced speaker and next presentations will be at least 1.5 times quicker to prepare.

Key thing I’ve got from the presentation:

  • The more you learn about the topic of your presentation – the more gaps in your knowledge appear.
  • Questions is one of the most difficult parts of the presentation for me as a speaker. You don’t know answers to all of the possible questions and you have to start living with it. I just decided to stop at some point otherwise I would never present.
  • There are places available who welcome new speakers and provide reasonable feedback and friendly attitude towards newbies.
  • It would be way easier to start from the public 15-minute presentation rather than from the 45-minute one.
  • It won’t be really scary for you to present in front of 50 people – if you’re more or less prepared.
  • I’m not awful at doing presentations, just pretty bad.
  • It’s a sort of a pleasure to see people listening to you and understand that your presentation might unconsciously affect some of their choices in future.

I’m really glad I was given a chance to share our experience with the larger audience. It also helped to broaden my personal borders and reduce the fear of public presentations to a great extent.

Currently I’m considering topics for the presentations which are related to:

  1. Protobuf
  2. Kafka
  3. Migration from REST to Thrift
  4. Monitoring and alerting (StatsD + Graphite/Prometheus + Grafana + ELK)
  5. Developer life in the world of continuous delivery
  6. Streaming frameworks overview (more distant future)
  7. Heron streaming framework (more distant future)
Posted in Conference, Personal | Tagged , , | Leave a comment

Spring @Order in collections

It took me a while to understand why is the order not correct in the following code:

class A {
  @Autowired Collection<B> beans;
}
interface B {}
@Component @Order(1) class C implements B {}
@Component @Order(2) class D implements B {}

You’re welcome to guess why these are injected in the wrong order. No idea? What if I change it to List?

class A {
  @Autowired List<B> beans;
}

In this case ordered injection works properly. In general it makes some sense since Collection does not make any guarantees about the order. And I clearly understand framework designers here. Still this behavior is not clear from the first point of view.

Posted in Development, Uncategorized | Tagged , | Leave a comment

The Passionate Programmer

The Passionate Programmer

Just finished reading “The Passionate Programmer (2nd edition)” book by Chad Fowler. What can I say? I was looking for such a book for years. Sometimes I read books from Brian Tracy and similar guys. However these books are mostly aimed towards sales people not programmers. However IT industry is definitely unique in lots of senses.

And this book clearly helped me to understand my current position and where I’m heading to. It’s really easy to sink in the day to day activities. Each  brings you a bunch of chances to change yourself and things around you. Yeah, I still believe in it after 13 years of outsource programming. The most complex thing here is to change yourself.

Right now I have two stories to choose from. One will require some investigations, communication with other people and will probably be a sort of jamming. Another one does not require communication, is rather precise and can be done pretty mechanically. My mind immediately chosen the latter one. More story points was used as an excuse. My mind is definitely a cunning beast. Not this time, mind!

48 ToDos of various sizes are waiting for me after reading this book including month-length tasks like:

  1. JavaScript certification
  2. C# + .NET ecosystem
  3. Golang
  4. XMind open source contributions

Lots of thanks to the author! That’s how motivational books should look like.

Posted in Education, Personal, Uncategorized | Tagged , | Leave a comment

Certified Developer on Apache Cassandra

Glad to say that my really early mornings which start at around 4 AM brought some results. I became a certified developer on Apache Cassandra. Even though I have a mixed feeling about the certification exam it was still a good way to summarize my knowledge.

0736_panasuyk

Posted in Education, Uncategorized | Leave a comment

Devoxx Belgium 2016

General feeling

Finally got to Devoxx Belgium this year. I always considered it to be the top Java conference in the European part of the world. Thanks to my current employer it became possible.

Interestingly it took me a while to get into the conference. Tenth of developers were looking for the conference along with me. It’s a pretty hard thing to find a conference for the first time without much visual information. We looked for Devoxx in various parts of Kinepolis until we finally found it. Registration was very quick. However noone gave me at least a pen and a notebook. Having organizers booth that far away from the entrance is not the best idea. In general I would say that logistics was somewhat difficult. Sometimes the whole room was evacuating into another room following the speaker. You could spend up to 10 minutes standing and waiting for people to leave the room with a single entrance.

Food during the conference left a mixed feeling. Drinks/coffee were available all the time and it’s really good. Pastry and chocolate made coffee breaks a really pleasant thing. Lunches were a bit strange: soup + salad is fine, soup + sandwich is questionable. However it might be related to the way different nation use to lunch.

Having different formats of talks (BoFs, Ignite, Quickie) is really cool. I especially liked BoFs which were held in the evening. It was a great fun and you felt like you’re packed with the new information after the whole day. Having seven full-fledged talks a day is a really useful thing.

Technically it was rather good. In the ideal world it would be nice so that each presenter would use the same notebook, especially during keynote and ignite sessions. This would probably create a more flawless experience. WiFi was not too bad given 3.500 developers on the same area. However having a separate WiFi for the speakers would probably help. The long rows of tables with AC is a really nice thing.

Support from the sponsor side is nice. A bunch of booths where you can share experience, get some books for free, win some prizes. I really appreciate sponsors taking efforts to support such a conference

Yeah, it’s 3.500 developers. Queues, crowds, lots of moving people, eating in the stand position. Just be ready.

It looks like Belgium and Antwerp in particular is on permanent reconstruction. You definitely need to put some risks if you travel by tram or by foot.

Talks I’ve visited

Wednesday

Keynote

Unfortunately I was not able to get into the room where keynote was held alive.

Stephan Janssen was presenting the conference team and other conference-related events. It was pretty interesting to hear about Devoxx US. I’m quite curious to see how it would compete/be influenced by JavaOne and mentality of the US-based audience.
Guillaume Laforge is definitely a person to admire. His influence towards Groovy and Grails is hard to overestimate. However I didn’t think he made his best during the keynote.
Mark Reinhold and Brian Goetz did an amazing job of presenting Java 9 and possible future features.
Cliff Click is incredible. He can describe really important concepts in our programming world with simple words and analogies It’s definitely a unique skill.

Property-based testing (Romeo Moura)
It was the first talk I was heading to. Romeo Moura was talking about the shift of way in which we should write tests. It’s hard to disagree with him that the proposed property-based testing approach makes sense/ However I think you should consider it as an additional tool in your testing toolset rather than a primary tool. And still time of executing for parameterized tests is still a concern if you have many thousands of tests in the codebase like we do.
To-do list:

  • Check JUnit assumeThat/assertThat
  • Try to get an idea of mocks vs property-based testing
  • Play with JUnit QuickCheck
  • Check the Random.nextElement for enum.
  • Check the internal difference between nanoTime and currentTimeMillis
  • Check the origin of @SneakyThrows

Hot.orElse(Not) (Nick Vanderhoven/Jeroen Horemans)
Just a bit of fun related to Java.

15 Kubernetes features in 15 minutes (Marc Sluiter)
Good quick overview of Kubernetes principles and building blocks.

Containers, VMs, Processes (Quentin ADAM)
Didn’t get much new from this talk. Description was pretty basic for any of the developer who has at least some experience with the related topic. However the amount of animations was brutal. It’s okay to run animation once or twice but not though every slide
To-do list:

  • Understand how you can unjail from chroot

The JVM and Docker. A good idea? (Christopher Batey)
Amazing talk. It’s definitely one of my favorite during this Devoxx. It’s all about pain and hidden problems when integrating JVM and Docker. Pretty technical and very alive.
To-do list:

Clojure Web-Application 101 (Michael Vitz)
This talk can be considered a gentle introduction to Clojure with the attempt to write a small web application. Actually I liked it and even didn’t fall asleep like it happens sometimes on the language-centric talks.
To-do list:

Terracotta Ehcache: simpler, faster, distributed (Anthony Dahanne)
Somehow it just vanished from my memory and I can’t say a word about it. 🙂
To-do list:

  • Consider clustered caching for our own needs
  • Understand how does @CacheResult works for a list of parameters
  • Compare Terracota Server and Hazelcast conceptually
  • Finally learn IntelliJ shortcuts

The Java Pub Quiz
I was afraid I couldn’t get to the first BoF in my life due to the packed room. Fortunately it was not the case. Some team work and some beer is always amazing. Thanks to the organizers!

Thursday

Effective Service API Design (Elliotte Rusty Harold)
This one was really good. Different approaches to the API design were discussed. The main thing I took for it is to use optional in all of our Thrift definitions.

Microservices Evolution: How to break your monolithic database (Edson Yanaga)
This one was good to. The speaker was sharing experience related to the database migration. There was not much new since we already have a pretty stabilized procedure of data migration in MySQL and even some experience of MySQL -> Cassandra migration. However presenting debezium.io was an interesting part.
To-do list:

Docker for developers and ops: what’s new and what’s next (Patrick Chanezon)
This one I consider on of the the most controversial talks I’ve visited. Unfortunately Patrick was not able to get into hardcore Docker details even though the slides he skipped in the end seemed pretty interesting. It was definitely fun but not that useful as it could be if the speaker spent more time for the slides in the end. It’s especially pity since Patrick is definitely a good speaker and can hold his audience.
To-do list:

Machine Learning for Developers (Danilo Poccia, Sebastien Stormacq)
This was definitely a top-level presentation with the real-time demos of speech recognition and model processing. Really want to have my own Alexa now which is definitely a major privacy concern.
To-do list:

Rust as a support language (Geoffroy Couprie)
Having a look at Rust was pretty much at the top of my to-do list so I couldn’t miss this talk. But it was really dull. After a pretty short introduction into language features we saw how to make Java code 1.5 times as big, less readable. Not impressed really.
To-do list:

  • Look for other Rust talks and play with it

What’s NOT new in modular Java (Milen Dyankov)
Amazing talk which compares OSGI and Java 9 modularity. I already had bit and pieces in the mind. However this talk connected all of these pieces. Definitely worth spending time.
To-do list:

Tensorflow and deep learning – without at PhD (Martin Görner)
I just couldn’t skip this talk. Along with Rust machine learning is a hot topic worth visiting. And I was not disappointed. Good examples, nice demos and a feel of magic. Looks like the field is not fully formalized yet.
To-do list:

  • Pass several MOOCs on machine learning to get deeper understanding of the field

10 SQL Tricks that You Didn’t Think Were Possible (Lukas Eder)
This one is definitely in the top three for me. Lots of humor, a ton of useful information and explanations. I wish anyone could see it live.
To-do list:

  • Check WITH clause

Riding the Jet Streams (Neil Stevenson)
Neil was trying to interest developers in the new Hazelcast product named Jet. Lots of questions are still open for me.

Functional programming: It sounds awful (Roy van Rijn)
Really cool comparison of the imperative vs functional in Java in voice. Definitely a thing to hear. Hopefully there’s some video of this talk available somewhere

Mood Driven Development (Katharine Beaumont)
Unexpectedly I liked this pretty abstract but very motivating talk. Just try to approach the direction which you like

Java Sutra (Nick Vanderhoven, Jeroen Horemans)
For some reason I didn’t like this one much. May be the humor just suites some specific taste.

Bicycle Touring Traveling for Vacation and Business by Bicycle (Karl Brodowsky)
Some tips on biking. I’m actually doing biking, even did 120 km in 6 hours this summer. But still, somewhat a strange and unexpected talk.

Friday

Java Language and Platform Futures: A Sneak Peek (Brian Goetz)
How can’t you admire the guy who does architectural decisions for Java which influence thousands of developers all over the world. And yes, Brian has amazing presentation skills. Just more details on what might land in the future releases of Java. Talks like this make any conference a first-class conference. You can really see the direction of the platform.
To-do list:

Thinking In Parallel (Stuart Marks, Brian Goetz)
High level talk which shows what can be parallelized and when would you use parallel streams. Definitely worth looking. One of the important ideas: “Don’t do parallel stream unless you have figures to support it.”
To-do list:

  • THINK when you write a stream. Am I blindly copying iterative approaches or do I follow the declarative approach?

Netty – One Framework to rule them all (Norman Maurer)
It’s a very technical talk. Too technical sometimes. However if you’re using Netty – it’s definitely a thing to look: lots of the tech porn.
To-do list:

  • Read “Netty in Action” book
  • Read about jemalloc
  • Check SO_REUSE_PORT/TCP_FASTOPEN/TCP_INFO Linux kernel capabilities
  • Refresh knowledge on false sharing

Talks to have a look

Overall

The conference is amazing. Antwerp is amazing too. Hopefully I’ll have a chance to visit Devoxx 2017 in Belgium next year.

Posted in Conference, Education, Uncategorized | Leave a comment

Default enum field value in protobuf

Enums in protobuf seem pretty obvious. However some of the behaviors are not that simple.

Lets say we have proto:

enum Type {
 ADMIN = 0;
 REGULAR = 1;
}

message User {
 optional Type type = 1;
}

And simple Java code:

User user = User.newBuilder().build();
System.out.println("Has Type: " + user.hasType());
System.out.println("Type: " + user.getType());

Well, field value is optional. So as a Java developer I would expect hasType to return false and getType to return null. However the real output is:

Has Type: false
Type: ADMIN

Why?

public Message.Type getType() {
 Message.Type result = Message.Type.forNumber(type_);
 return result == null ? Message.Type.ADMIN : result;
}

Conclusion: know your libraries and check auto-generated code

Posted in Development, Uncategorized | Tagged , | Leave a comment