Data Oriented Programming in Java

Key Takeaways

  • Project Amber has brought a number of new features to Java in recent years. While each of these features are self-contained, they are also designed to work together. Specifically, records, sealed classes, and pattern matching work together to enable easier data-oriented programming in Java.
  • OOP encourages us to model complex entities and processes using objects, which combine state and behavior. OOP is at its best when it is defining and defending boundaries. 
  • Java’s strong static typing and class-based modeling can still be tremendously useful for smaller programs, just in different ways.
  • Data-oriented programming encourages us to model data as (immutable) data, and keep the code that embodies the business logic of how we act on that data separately. Records, sealed classes, and pattern matching, make that easier.
  • When we’re modeling complex entities, OO techniques have a lot to offer us. But when we’re modeling simple services that process plain, ad-hoc data, the techniques of data-oriented programming may offer us a straighter path.
  • The techniques of OOP and data-oriented programming are not at odds; they are different tools for different granularities and situations. We can freely mix and match them as we see fit.

Project Amber has brought a number of new features to Java in recent years — local variable type inference, text blocks, records, sealed classes, pattern matching, and more. While each of these features are self-contained, they are also designed to work together. Specifically, records, sealed classes, and pattern matching work together to enable easier data-oriented programming in Java. In this article, we’ll cover what is meant by this term and how it might affect how we program in Java.

Object-oriented programming

The goal of any programming paradigm is to manage complexity. But complexity comes in many forms, and not all paradigms handle all forms of complexity equally well. Most programming paradigms have a one-sentence slogan of the form “Everything is a …”; for OOP, this is obviously “everything is an object.” Functional programming says “everything is a function”; actor-based systems say “everything is an actor”, etc. (Of course,

Read More... Read More

Data Doctors: Are extended warranties on computers worth it?

Practically anyone selling you a computer will likely try to get you to pay a little extra for a “protection plan” that goes above and beyond the standard factory warranty. Should you go for it?

Q: Are computer extended warranties worth buying?

A: No matter what tech device you buy, practically any retailer will likely try to get you to pay a little extra for a “protection plan” that goes above and beyond the standard factory warranty.

In some cases, it seems like such a small amount of money that you may think, “Why not get the extra coverage?”

But the credit card you made the purchase with may already provide basic protection.

Many of the electronic devices you’ll buy today don’t have the moving parts that would commonly wear out in the past, making the “protection” even less likely to pay off.

In the vast majority of cases, you’re simply improving the profitability of the sale for the retailer — which is why you’re seeing it virtually everywhere.

It’s not covered

When it comes to computers, there are a variety of reasons that buying “extra protection” up front can be a waste of money.

First and foremost, these protection plans generally only cover hardware components, which is rarely what causes aggravating computer problems.

In our 30-plus years of servicing computers, the vast majority of issues that we see are software- or operating system-based, which isn’t covered by most extended warranties or protection plans.

Retailers know most consumers don’t realize this, and won’t take the time to read the fine print. Even when some form of coverage includes the operating system, it means they will return the computer to the factory settings.

That means the stuff you really care about — your programs, data files, browser settings, printer drivers and desktop icons — are all going to be wiped out.

When you get your computer back from this type of “warranty” service, the burden of reloading your programs, restoring your data files (hopefully you had them backed up), reinstalling printer drivers and getting the computer to work the way it

Read More... Read More