more of devoxx, more on interfaces

I gave my talk at devoxx and hopefully those who attended were not offended by my weird sense of humor :) Guys, we need to have more fun in IT…

Shortly after I gave the talk I had an interesting discussion about the coding style some folks call “coding to interfaces”. It started when I was asked if Mockito is able to mock concrete classes? The answer is yes, Mockito doesn’t care if you mock an interface or a class. Mockito can do it thanks to primordial voodoo magic only ancient shamans understand these days (you guessed right – it’s the cglib library).

Here starts the controversy. Should Mockito allow to mock only interfaces and hence promote “coding to interfaces”? Dan North, a respected IT guru and Mockito friend, said between the lines of one of his articles:

it allows me to mock concrete classes which I think is a retrograde step – remember kids, mock roles, not objects

What about the guy who approached me after the Mockito session told me a story about the codebase deeply proliferated with interfaces? Interfaces were introduced by developers not because they wanted to mock roles, not objects but because the mocking framework they used “promoted” coding to interfaces. This codebase was not very friendly.

To me, interface frenzy makes the codebase hard to browse, for example due to extra effort required to find implementation. Also, too many interfaces dilute the actual meaning of those interfaces that are really important. Therefore sometimes I mock classes, sometimes I mock interfaces and Mockito deals with it transparently. There are situations where I always use interfaces but let’s not bring it here.

I remember some old-school java book I read years ago. It read: “every java class should have an interface“. Don’t believe everything you read and the best example would be this blog, wouldn’t it?.

Use the coding style that works best for you. Drink mockitos only with interfaces if you like it this way.

6 Responses to more of devoxx, more on interfaces

  1. Totally agree on the “fun” part :). Your talk was one of the best that day: well prepared, structured, to the point.

  2. Laurent Bertrand says:

    Keep the jokes coming… It was a really good talk and I think Mockito will be quickly in my testin environment!

  3. szczepiq says:

    Thanks a lot for the feedback!

  4. […] hogy lehetséges ez? Nem tudom megállni, hogy ne idézzem a Mockito szerőjét Szczepan Faber-t: …I was asked if Mockito is able to mock concrete […]

  5. Saurav says:

    Regarding too blue: I’ll see if I can tie in some other color (orange) one way or another. No prieosms though.Regarding partnering: it is something we must do in order to continue growing. Seatgeek, for example, will provide us with a boatload of data regarding tours, concerts and events. Whether or not a user buys the tickets through us or another site, it’s great data to be able to display. UnitedWeTab allows us to list available guitar tabs and what not. Regarding looking official: I couldn’t care less about looking official or not. What I do care about though is to have a clean look that is easy to navigate. SM at it’s current state is a bit behind that curve and it’s an area we could greatly improve upon. At the end of the day, it all matters to the end-user: how they find their data, how comfortable they are sharing data and so forth. We’re trying to go for something that makes everything easier for the end user. Right now, in some areas, we’re failing. Heck, I even get frustrated in some areas.Flash back to 3 years ago when we launched the updated design, some liked it and some didn’t. And now here we are, debating about whether or not to keep this existing design or to move on.

  6. … I dont see what is wrong with the current format. It has been this way for as long as I can remember and this is the website I always check first whenever I want to look up lyrics. So you have to be doing something right with the way things are right now. Facebook and youtube keep changing their layouts and everyone hates it every time. I actually quit Facebook all together because it completely ruined what made it so great in the first place. Youtube I have to tolerate by default and isnt yet so bad as to bring me to the point of utter hatred of the format, but I wouldnt be surprised if after another 2-3 rounds of “improvements” I do quit youtube all together. Basically, I’m saying that if it aint broke dont fix it (even if I am one of the only voices saying I like the current format). If you would like to add a few extra features and stuff that would be cool, but dont change everything. I would add a small, but noticable, suggestions button at the top of the page so that people can easily suggest improvements and I would even take things a step further and allow people to vote on their favorite ideas so that we make sure people get what they want and not what the website controlers want (such as with Facebook). The ONE THING that you should offer in the event of updated formats and stuff is the option to have the “classic” layout. That the is the only reason I am still on yahoo as my mail and if they ever get rid of the classic option I will leave right away. A “classic” option is absolutely necessary if you are hoping to attract the most people because that way you potentially bring in new users, but you have no risk what-so-ever of annoying the long-time users. I know this has kind of been a long comment, so to sum up my message, update whatever you want to update but please give us a “classic view” button because if I do not like the new layout I will grudgingly find a new lyrics website to use consistently but I do not want to have to do that because I have been comming here for around 5 years now and have never had any problems with it in regards to the lay out. Thank you for hearing me out, have a nice day.

%d bloggers like this: