Advertisement
Guest User

The Java Way (2006)

a guest
Mar 13th, 2015
4,680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. The Java Way (2006)
  2.  
  3. I'm currently trying to hack my way through Java's security API written in the finest traditions of Java Enterprise Development. After doing it for several hours (and after working with Java for several years) I'm beginning to think that all developers who worked on core Java APIs had some king of peculiar mental illness.
  4.  
  5. Let me illustrate. Imagine you have a cup of coffee represented as an object. You invoke some kind of method that returns that object. For example, getACupOfCoffee(). Problem is, you need a full cup, while the method returns you an empty one. If you are an inexperienced Java developer, you might expect to see coffeeCup.fill() method. Abandon such silly hopes. Having methods that solve problems in obvious ways just isn't The Java Way.
  6.  
  7. So what do you do? Here is a standard way the situation evolves:
  8.  
  9. 1. You go thought the API documentation of CoffeeCup class. It has 89 methods. 60 of them have nothing to do with either coffee or cups. Of course it is nearly impossible to guess which is which without reading their descriptions.
  10.  
  11. 2. In the process of doing just that (reading their descriptions) you discover a multitude insightful javadoc comments like "<i>setVolumetricQuadrance(Quadrance X) - This methods sets volumetric quadrance</i>". Really? I wouldn't have guessed in a lifetime!
  12.  
  13. 3. You locate a method called initiateFillingProcess() -- only to find out that it is a deprecated method inherited from FoodRelatedObject class 6 levels up the inheritance chain. And yes, it has nothing to do with coffee.
  14.  
  15. 4. You locate CoffeeCupFiller interface. There is no sign of classes that actually implement it.
  16.  
  17. 5. You search the Interned with a query like "java CoffeeCup fill". There are 7,923,236 results.
  18.  
  19. 6. The first link leads to an article about using X Enterprise Application Server to fill coffee cups. The code example spans 600 lines. It uses classes that depend on everything else in the server, which is 500 megabytes in size. (50 megabytes are XML configuration files you would need to rewrite if you wished to install it.) Best of all, after reading the sample code for an hour you find out that while the server does fill cups, it stores their filled instances inside itself without any way of getting them back.
  20.  
  21. 7. The second link on the search page leads you to a thread on java.sun.com where someone else asked how to fill a cup with coffee. The reply? "Stop pestering us with such nonsense. You can use a search engine to find the answer." This is posted by a 5-star Certified Java Professional who is Triple Platinum Community Member of The Year and has 3748 points of positive karma.
  22.  
  23. 8. The third link leads you to another thread on java.sun.com where the answer is "read the API reference". Yes, the same API reference you have read during step 1.
  24.  
  25. 9. The twenty seventh link in search results finally leads you to a working solution. Apparently you need to use FillingEntitiesFactory to instantiate a FillingEntity, then initialize it with BufferedFiller object, which operates on CoffeeCup stub classes you can generate by running JDK command line tool cbrtrfl.exe. It's *that* simple.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement