Blogs:JaroslavTulach:Practical Design

From APIDesign

Jump to: navigation, search

Contents

Practical Design

Marketing Version

There is a difference between MarketingVersion and engineering approach to versioning. Hear why: read more...

--JaroslavTulach 05:26, 11 June 2023 (UTC)

Do not Expose Deep Hierarchies!

Do not expose DeepHierarchy of classes when designing an API!

--JaroslavTulach 05:39, 24 September 2022 (UTC)

Using record on any JDK!

Do you like record or other modern Java language features? Would you like to use them on older JDKs? Then read about Frgaal - the retrofit compiler for Java.

--JaroslavTulach 07:10, 23 April 2022 (UTC)

2021: Code VSCode UI in Java

Seven years ago, in 2014 I wanted to unify UI of various IDEs around HTML (see below). However the motivation to do so was never compelling enough. Using Swing (or SWT) is more natural. Finally, in 2021 we found good enough reason: VSCode and its NetBeans based extension!

Image:Vscodehtmlui.png

Since December 10, 2021 it is real: one can code HTML UI in Java and display it in VSCode as well as NetBeans. See PR-3349.

--JaroslavTulach 07:43, 10 December 2021 (UTC)

Bck2Brwsr 0.50: Ready for 2021 Technologies

For a while I ignored my Bck2Brwsr project, which I used to love, but recent back and forth shifts attracted me again to the area of Java and JavaScript interop. Originally I was hoping for a superior transpiler being created, but when I realized the goal isn't to cooperate, but compete, I decided to bring Bck2Brwsr transpiler into the 2021 age: it is still very restriced JVM, but it does support latest Gradle, it does support lambdas and it supports even JDK-11 string concatentation.

Read more at Bck2Brwsr 0.50 release page...

--JaroslavTulach 19:48, 1 August 2021 (UTC)

Run on JDK8, use JDK11 APIs!

Do you want to run your application on JDK8, but use JDK11 APIs? That's traditionally done with a reflection. But there is a better way!

--JaroslavTulach 06:17, 16 February 2021 (UTC)

Helidon MP 2.0 supports GraalVM NativeImage

Helidon MP implements the MicroProfile specification based on various other standard JavaEE subspecifications including CDI. Getting Weld (the reference CDI specification) running on top of NativeImage is particularly tricky. Not only Weld dynamically scans for various annotations, but it also dynamically emits bytecode for its helper classes during runtime. Solving this required more insight into JavaEE than available among compiler engineers - not that I had it initially, but the close co-operation with Tomáš Langer (the Helidon lead engineer) helped us get started. Tomáš prepared various trivial CDI sample projects and I was then able to get them running on NativeImage by writing a dedicated WeldFeature. Once the initial road block was gone the Helidon team was able to move forward on their own and get their enhanced Weld running on top of NativeImage.

Helidon 2.0 was released on June 24, 2020. It's MicroProfile edition (including compatible CDI implementation) works with NativeImage.

--JaroslavTulach 19:17, 29 June 2020 (UTC)

Available on Safari Books Online

SafariOnline now hosts TheAPIBook. No more warez downloads!?

I had a presentation for my colleagues about GraalVM. GraalVM is about speed, but also about APIs. As a consequence some of my colleagues asked, why TheAPIBook isn't available for Oracle at https://my.safaribooksonline.com/ - I didn't know, but was curious to find out as well. I sent a note back in April to Apress. Why my Practical API Design is not being available on Safari? This week I've got an answer:

The reason it had not been available is because at the time the book published, we were not sending regular feeds to Safari. It was also at a time that pre-dates ePUBs being created as a part of our standard workflow (ePUBs are what SafariOnline requires). We had to create an ePUB from the existing PDF version of the eBook.

In short: TheAPIBook is now live on the https://my.safaribooksonline.com/

--JaroslavTulach 05:50, 25 May 2019 (UTC)

TenYears of the Practical API Design book

Ten years ago, on July 29, 2008, the Practical API Design book was published. Isn't that a date to remember and celebrate? Yeah, it certainly deserves at least a little note. Many things has changed over the last ten years...

The language that I used for most of the examples, Java, is no longer as popular as it used to be. It is no longer taught at basic university courses. It is no longer the choice of those who want to use good technology with all its three essential components (coolness, time to market and Cost of Ownership). Does that mean TheAPIBook content is no longer valid? Not that all! I always expected Java to evolve into something different - the language was just a tool - thus the core ideas still remain fresh and useful.

REST has grown way stronger in the last decade. When TheAPIBook was written, the term API was still reserved to all types of API (Protocols, FilesLayout, Dependencies, CLI, and of course signatures). The REST was just one of the types. I realized things has changed in 2014 when I received a question: How does the API economy impact the APIDesign? At that moment it was clear, the term API had been kidnapped by the REST guys. When regular people hear API they first and foremost envision web services! That is upside down, as network communication is just a part of the Art of Building Modern Software, but the expectations have shifted and one has to live with that.

Types went away and returned back. For a while it seemed that types were heading to unimportance with the decline of Java. It is true that the runtime characteristics of dynamic languages like JavaScript got on par over the years. Yet, it seems the types are striking back: TypeScript, Kotlin, etc. show that for certain tasks (like designing an API) having a type is an advantage. While I am able to design an API in a dynamic language, having types makes it all more convenient and alike to advises described in TheAPIBook.

I left the source of inspiration of TheAPIBook - I only contribute to the NetBeans Apache project in my spare time - as a result I had to find another organization to feed me with APIDesign mistakes. It is a strong suply, yet I believe the list of my achievements in the recent years allows one conclusion: It is possible to design an API as a service! I wish the impact of the Practical API Design book has been bigger: It is clear there is a lot of people struggling to design an API and it would really help them to avoid inventing the wheel. Many of the Practical API Design observations would help to avoid the mistakes I am seeing all around, but maybe it is not that easy to read, maybe it is the personalization that counts!

Don't you need a skilled API designer? Don't you want to improve your API Design skills with an entertaining game-like training? Talkback to me. Actively joining would be the best celebration of the 10th anniversary of the Practical API Design book!

--JaroslavTulach 06:36, 29 July 2018 (UTC)

Bck2Brwsr 0.23: Get Started via Gradle!

After few months the newest version of Bck2Brwsr VM is here. It contains:

It was quite a fun to write Gradle tasks together with Maven and build them by Maven.

Get started with README. Enjoy.

--JaroslavTulach 04:02, 1 June 2018 (UTC)

Singletonizer API Design Pattern

Recently I have successfully used the singletonizer API design pattern in Graal's Graph I/O API javadoc. The result ain't that bad, right?

--JaroslavTulach 06:51, 25 January 2018 (UTC)

Is Spring the Sole Reason why Java is Becoming the new COBOL?

Is there anything good on Spring that wouldn't be seen ridiculous by non-enterprise-Java users?

--JaroslavTulach 11:46, 18 December 2017 (UTC)

Bck2Brwsr 0.20 - the Radtouren 2017 Release

This version of Bck2Brwsr VM is called Radtouren 2017 version, as it has been prepared and released while our gang was bicycling in Korutany. Sleeping in a tent in camps, bicycling whole day, coding in a morning. What can be more fun?

Wanna transpile Java to JavaScript. Give Bck2Brwsr a try!

--JaroslavTulach 13:27, 9 July 2017 (UTC)

Codesnippet Doclet 0.20 Release

Enhance your Javadoc with Codesnippet4Javadoc version 0.20 which now supports special "coloring" for strings and comments.

--JaroslavTulach 10:40, 16 February 2017 (UTC)

Beware of DefaultMethods

DefaultMethods is a new feature of JDK8 that we many cried for. Yet, they carry certain drawbacks with themselves. For example one can write a valid Java program that compiles and works on JDK7, but is broken on JDK8!

--JaroslavTulach 10:42, 24 September 2016 (UTC)

Test your APIs Easily with Maven SigTest Plugin

The NetBeans API & Maven community (e.g. me and Miloš Kleint) is proud to announce the immediate availability of sigtest-maven-plugin. Signature testing has never been easier: just follow the tips on the SigTest main page and you'll never make an incompatible change since then!

Read TheAPIBook and let NetBeans SigTest Maven plugin look over you and make you great API designer! Enjoy!

--JaroslavTulach 17:52, 15 July 2016 (UTC)

Boost Your Career: Become an API Tester!

Motto: the easiest way to learn something about a code base is to fix bugs. The easiest way to learn something about design API is to join an APIUsabilityStudy!

There are many reasons why you should care about the Truffle framework (please check the changelog of just released version 0.14 to learn more), but the most important one is related to API Design and your career:

I need API testers! I need to organize a usability study of the Truffle API and I need developers to perform it. How can you help?

We have prepared five easy tasks: use Truffle to invoke a code in Ruby, JavaScript, R, exchange data between Java and one of those languages using Truffle interop, etc. In addition to that we ask you five questions: What did you like/dislike? What should we improve, etc.? Overall, the whole study should be easy and entertaining. You can learn something new (e.g. Truffle) and even earn some money.

Originally I wanted to repeat the previous success of netbeans:Html4JavaUXStudy2014, but the then used service is no longer available due to small demand. Understandable, but a shame! I know the demand for API related courses is low (I do one once a few years), but it is always very valuable to seek an advice when it comes to API - the on-line API usability study was really great idea! Alas, we need to organize it ourselves.

Are you interested to help us? If your want to be an API tester for a few hours, please write to my email practical@apidesign.org and I share more details. Thanks in advance!

--JaroslavTulach 08:13, 6 June 2016 (UTC)


Improve Javadoc of Your API: Stop showing crappy code samples!

I've just finished integration of Codesnippet Javadoc Doclet into Truffle API and the result is great: we found out that one of the samples (actually the first one that I tried) was not compilable!

If you care about Javadoc of your API, consider using Codesnippet doclet too!

Btw. it surprises me I am the first one who created something like this! Showing snippets in documentation is so common. But maybe it is the same issue as with TheAPIBook - it was the first book that ensured all the code samples are compilable by extracting them from real source code (using similar infrastructure as Codesnippet doclet provides). And it worked - while Errata of every book is full of comments about incorrect code samples, there is none for TheAPIBook.

Do your API a favor: use Codesnippet Javadoc Doclet and make your code samples real!

--JaroslavTulach 15:59, 30 December 2015 (UTC)

Java Modularity in the Context of JavaScript

Obfuscation per library is quite common in JavaScript and it results in faster download times, sharing modules between different applications and easier processing of the obfuscated files. Shouldn't something similar be done in Java?

Yes, it should. And it has been done! Here is description of design and implementation of Obfuscation per JAR file for Java (in a [[Bck2Brwsr|browser).

--JaroslavTulach 04:10, 29 May 2015 (UTC)

ConfigurationObject Pattern in Java

ConfigurationObject pattern is quite common in many JavaScript libraries. Do you know what is the best way to express it in Java? Check my essay that compares four different ways and analyses their impact on API designer and especially API users.

--JaroslavTulach 12:44, 22 February 2015 (UTC)

Final interface. Finally Done Right!

Maybe there is nobody interested in final interface API Design Pattern anymore! Now when there is JDK8 with extender methods people may always mitigate bad design (e.g. using final interface at all) by adding methods with default bodies. Still I found it important to cover this pattern in my API Design Patterns Collection.

Let's me guide you through the short and incomplete history of final interface design pattern with small excursion to JDK's own itches and specifics of designing for OSGi to finally describe how to do final interface pattern right!

Let you find such description useful!

--JaroslavTulach 16:53, 4 February 2015 (UTC)

Impossible. Part II.

Everybody understands threading is complex. Yet almost everyone believes that with good methodology it is possible to do threading right. Well, it is not. There is no theory to eliminate deadlocks. Achieving proper threading is impossible. Still people keep asking for it. When you tell them it is impossible, you may get fired. Just like me few years ago! Here is my story.

--JaroslavTulach 19:23, 3 January 2015 (UTC)


Publish Bck2Brwsr Libraries as Maven Artifacts

Bck2BrwsrLibraries can now be published as Maven Artifacts which greatly reduces edit/compile/run time.

--JaroslavTulach 05:21, 7 December 2014 (UTC)

Bck2Brwsr and Images as Resources

Blob URL support has been implemented for forthcoming version of Bck2Brwsr 0.12. Now you can easily access images packaged as resources in your JAR files and obtain their browser valid URL.

--JaroslavTulach 01:19, 30 October 2014 (UTC)

Impossible. Part I.

Explaining that something is impossible is, well impossible! Here is a link to one viral video and one story from my computer science student years, which is so true, I would almost cry. In case you find my impossible story interesting, let me know. I have at least two more on the same impossible topic!

--JaroslavTulach 14:25, 20 October 2014 (UTC)

Lambdas Go Bck2Brwsr!

Bck2Brwsr 0.10 has just been released. The most important thing to note is that it handles JDK8's lambdas. See the illustrative video:

The JDK emulation library is still based on JDK7, so don't expect your streams & co. code to run. I'll update to JDK8 after JavaOne2014. Meanwhile enjoy lambdas in your own APIs!

--JaroslavTulach 17:48, 15 September 2014 (UTC)

Use NetBeans to Deploy Everywhere!

Client Java everywhere is now possible thanks to essential part of DukeScript - its capability to deploy to almost any device on the planet (that can render HTML). One can configure everything in an IDE independent way, but the best way to start is to get your instance of NetBeans 8.0 and follow few easy steps described in the official DukeScript getting started document.

--JaroslavTulach 11:09, 18 June 2014 (UTC)

MineSweeper on iOS

Thanks to IBrwsr I managed to run my favorite game on my iPad! Why don't you write applications that run on every device, yet?

Image:MineSweeper-iOS.png

--JaroslavTulach 14:13, 21 May 2014 (UTC)

TeaVM Can Execute DukeScript Applications!

Alexey just released his first version of TeaVM. Congratulation!

Well, everyone now writes virtual machines that run in a browser, but TeaVM is special - rather than separating and playing on its own sand field - Alexey decided to speak DukeScript. As a result, the same application can now be deployed to Bck2Brwsr and TeaVM and we can compare which virtual machine is better - or at least play minesweeper 1 and minesweeper 2.

Enjoy and give DukeScript (the JavaScript, the way it was meant to be) a try!

--JaroslavTulach 14:27, 20 March 2014 (UTC)

Avoid Synchronization Problems

Don't let your objects escape from your methods! As suggested on page 193.

--JaroslavTulach 16:24, 14 February 2014 (UTC)

Changes: HTML for Java, videos and hosting

I'd like to announce few changes related to apidesign.org site.

First of all, the Knockout4Java is now a NetBeans subproject and yesterday I managed to release its first bits as a stable version 0.7 - follow three simple steps to see how powerful Java/HTML user interface can be.

The other change is that I am migrating the whole website to new hosting infrastructure. Sources are up, mediawiki as well. However I still need to recover mailing lists, etc. If you find something that is not working and should, please Talkback. Thanks in advance.

One thing you don't have to complain is lack of videos - this is what one gets when using a cloud service! My uploaded screencasts had been found inappropriate and were deleted - after four years of being OK! Should I upload the backup copies (that I can find) elsewhere or rather host it myself?

--JaroslavTulach 08:24, 14 January 2014 (UTC)

Can Deserialization Change Value of a Final Field?

Deserialization can change value of a final field. See the code snippet to understand how. 1st lesson learned at JavaOne2013.

--JaroslavTulach 16:58, 23 September 2013 (UTC)

The Art of Writing Equals in Object Oriented Languages

Do you think you know how to write equals? Are you sure? Take your time. Still sure? Check this example to verify.

--JaroslavTulach 08:53, 6 September 2013 (UTC)

Bck2Brwsr Goes Server Side: Run the Same Code on Server and Client!

I'd like to introduce my small contribution to Jersey project. It provides (yet another, but this time very lightweight) converter from Java to JSON and back. Together with Bck2Brwsr or FXBrwsr you can now smoothly execute the same Java code on client as well as on your server.

--JaroslavTulach 12:45, 20 May 2013 (UTC)

Introducing Knockout4Java

Knockout4Java takes the best of two words: The type safety of Java and Knockout.js ability to alter any HTML page in any browser. Write your models in Java (using JSON4Brwsr library) and render them as HTML with the help of Knockout4Java!

--JaroslavTulach 21:32, 16 May 2013 (UTC)

Introducing FXBrwsr

FXBrwsr is an attempt to give people the rendering power of HTML (via Knockout.js) and the benefits of HotSpot Java VM. As the Twitter example shows, it is then easy to deploy the application to run Bck2Brwsr.

--JaroslavTulach 09:25, 30 April 2013 (UTC)


Javadoc for Coding for Your Browser Published!

I've just set a job up to generate Bck2BrwsrJavadoc. Anyone wants to design a library for the browser?

--JaroslavTulach 09:11, 1 March 2013 (UTC)

C++ May Not Be As Bad As Thought!

Do you remember my recent post about object oriented encapsulation and performance? It was written in a response to an article that claimed C is much better than C++. There in given example nicely illustrates that by giving up on encapsulation one can implement more effective linked list. In my recent post I managed to prove that by using traits, one can easily get the same performance while keeping encapsulation in modern object oriented language. Only one question remained: Can one do the same with C++ templates?

I am glad to report we have an answer with a sample code. There is a way to write generic template (well two of them) and orchestrate them in a way that keeps encapsulation and maintains the C linked list performance. C++ is not as bad as I thought.

Last note related to this incident (influenced by book I am currently reading). There are tons of comments attached to the original article yet most of them are really shallow. Usually along the line of that is a non-sense!, use STL! or C rules, I knew it!. I guess this has something to do with Thinking, Fast and Slow: people were provoked to react instantly by seeing a topic they had already have an opinion about. Without really giving the issue a though, they replied using fast thinking.

It took me a weekend to come up with the trait solution and we needed about a week to polish the C++ sample code. Looks like a little bit of slowness can worth tons of fast made opinions. But that is for another story - first of all I need to finish reading Thinking, Fast and Slow book.

--JaroslavTulach 07:40, 27 September 2012 (UTC)

Older Blog Posts

OlderBlogPosts...

--JaroslavTulach 07:00, 27 September 2012 (UTC)

Personal tools
buy