This project serves as a practical example of strongly-typed functional approach to creating simple DB-backed asynchronous service. There are two implementations: one in Java and one in Scala. You can use them to compare functional features in both languages.
The project is a foundation for my talk about functional programming: "Pragmatist's Guide to Functional Geekery". Slides can be found on Speaker Deck.
The application simulates some of Twitter for a Star Wars based domain.
Every Citizen may have 0 or more followers.
Every Citizen is able to view Tweets on their Tweet Wall.
Depending on who rules the galaxy, the tweets may or may not need to be censored and manipulated.
There are two two types of applications: console apps and HTTP server apps. All applications are implemented in both Java and Scala with exactly the same set of functionalities.
sbt "run-main com.michalplachta.galactic.java.http.ServerApp"
[ServerApp.java] - HTTP server with/followers/{citizenName}
and/tweets/{citizenName}
endpoints (Java version)sbt "run-main com.michalplachta.galactic.java.console.GalacticTwitterApp"
[GalacticTwitterApp.java] - console-based Galactic Twitter (Java version)sbt "run-main com.michalplachta.galactic.java.console.GalacticFollowersApp"
[GalacticFollowersApp.java] - simplified console-based Galactic Twitter (displaying only followers) (Java version)sbt "run-main com.michalplachta.galactic.http.ServerApp"
[ServerApp.scala] - HTTP server with/followers/{citizenName}
and/tweets/{citizenName}
endpoints (Scala version)sbt "run-main com.michalplachta.galactic.console.GalacticTwitterApp"
[GalacticTwitterApp.scala] - console-based Galactic Twitter (Scala version)sbt "run-main com.michalplachta.galactic.console.GalacticFollowersApp"
[GalacticFollowersApp.scala] - simplified console-based Galactic Twitter (displaying only followers) (Scala version)
See comments in both FollowersService.java and FollowersService.scala files.
See comments in both FollowersService.java and FollowersServiceService.scala files.
See comments in both FollowersService.java and FollowersServiceService.scala files.
See comments in both Followers.java and Followers.scala files.
See comments in both TweetCensorship.java and TweetCensorship.scala files.
See comments in FollowersTest.java.
See the problem in RemoteData.java and potential solution using typeclasses in RemoteData.scala and RemoteDataJsonSupport.scala.