Simple Scala Classes

Declaring a simple, empty class in Scala is easy:

class HelloWorld

Scala will make this class public and doesn’t require empty braces to know there is no body to the class.

The Java equivalent:

public class HelloWorld { }

I like this style. In the average application that I write, visibility of classes – public, protected, whatever – is not a factor. Clear, simple designs and legible code are.
Scala encourages terse code. Having coded in Scala for a while now, Java can feel very verbose – especially when doing things in a non-functional way. But more of that later.

Advertisements

One thought on “Simple Scala Classes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s