From the Trenches of the Enterprise Software

Yakov Fain

Subscribe to Yakov Fain: eMailAlertsEmail Alerts
Get Yakov Fain via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

Top Stories by Yakov Fain

Probably the most popular question during Java technical interviews is “What’s the difference between abstract classes and interfaces”.  In my own three year old book I’ve offered the following answer: “An abstract class may contain code in method bodies, which is not allowed in an interface.With abstract classes you have to inherit your class from the abstract one because Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class.” But starting from Java 8 this answer is wrong. This is how I’d answered it now: “Both abstract classes  and interfaces allow you to implement common static methods while leaving the implementation of some methods to other classes. Abstract classes can also have instance-specific methods and they enforce vertical inheritance hierarchy.  Interfaces can’t have instance methods, but they... (more)

Closures in Java with Lambdas

While working on the second edition for my Java 24-hour Trainer book I’m re-writing some of the code samples to use lambda expressions. Today I was re-writing an example for wait/notify for the chapter on multi-threading. Beside illustrating the wait/notify, I used a closure in this example. Since Java closures are not well presented in the blogosphere, I decided to write a quick blog on the subject. My goal was to write a program that starts a thread and waits for the notification from that thread until its execution is completed. When the main thread receives the notification ... (more)

Java Is Short For JavaScript. Not! By @YFain | @ThingsExpo [#IoT]

Here’s  is a quote from the About page of the Web site ehow.com: “eHow is your one-stop online resource for life’s challenges. Professionals in every field come together to offer expert advice, backed by the additional support of a can-do eHow community.“ Experts are also human beings and sometimes they make mistakes too. But when I’ve read the following article I was stunned: Guys and girls, I’m not an eHow-grade expert, but I’ve been doing both Java and JavaScript for while. Trust me, the above description is absolutely wrong! Please ignore. Also, if you know any of the 35 peop... (more)

Java Programmers-Terrorists

Java has a pretty powerful mechanism of error handling. But sometime programmers ignore it. Recently I’ve seen the following post in one of the production support chat rooms: Developers, please don’t do this: } catch (IOException e) { //do nothing, just ignore it } finally { this is better: } catch (IOException e) { logger.error(e,e); } finally { The poster of this message has demonstrated what being overly polite means. I’m not as polite as the guy who wrote this and want to say that Java developers who quietly ignore exceptions should be tracked down and fired. They can be consi... (more)

JavaFX Event Handling and Property Binding

Some time ago I blogged that Java Swing should be deprecated and replaced with JavaFX. In this blog I’ll show a piece of JavaFX namely event handlers and binding. I’ve created a simple Sign In window with a GridPane layout (it’s JavaFX equivalent of Swing’s GridBagLayout). I’m not going to spend much time on the GridPane itself, but will show you a basic event handling and a binding. In JavaFX an event object is represented by the instance of the class javafx.event.Event. There are different ways of handling events. Depending on how you structured your application you can handle... (more)