“Redesigned 4x6 typesafe” via u/tewtham on Reddit.
GitHub link.
seen from Italy
seen from Malaysia
seen from India
seen from Slovakia
seen from China
seen from United Kingdom
seen from China
seen from Italy
seen from United States
seen from Italy
seen from China
seen from China
seen from China
seen from China
seen from China

seen from Italy
seen from Thailand
seen from China

seen from Italy
seen from Singapore
“Redesigned 4x6 typesafe” via u/tewtham on Reddit.
GitHub link.
[Laravel] Uses clear types
The origin code
public function get_user_badge(array $user_ids, array $course_ids, Carbon $from, Carbon $end, $direction = 'desc'){}
Refactoring 1: clarify array type
Util Classes
use Illuminate\Support\Collection; class IntegerCollection extends Collection { public function __construct(int ...$values) { parent::__construct($values); } } class UserIds extends IntegerCollection {} class CourseIds extends IntegerCollection {}
The code will rewrite as bellow:
public function get_user_badge(UserIds $userIds, CourseIds $courseIds, Carbon $from, Carbon $end, $direction = 'desc'){} // Usage $userIds = new UserIds($user_ids); $courseIds = new CourseIds($course_ids); get_user_badge($userIds, $courseIds, ...)
Refactoring 2: Combine $from/$end to InclusiveRange class
Util Classes
abstract class BaseRange { public $begin; public $end; public function __construct(Carbon $begin, Carbon $end) { $this->begin = $begin; $this->end = $end; } //...some ultil functions in here } class InclusiveRange extends BaseRange{}
The code will rewrite as bellow:
public function get_user_badge(UserIds $userIds, CourseIds $courseIds, InclusiveRange $range, $direction = 'desc'){} // Usage $inclusiveRange = new InclusiveRange($from, $end) get_user_badge($userIds, $courseIds, $inclusiveRange...)
[Typesafe’s Config] include syntax: substitution (이미 설정된 config 재사용하기)
Typesafe’s config 에서는 다른 곳에서 설정해둔 값을 쉽게 재사용할 수 있다.
contact { me { name = ${my.name} # the value is evaluated to “ME” } you { name =“YOU!!” } } my { name = “ME” age = “secret” }
contact.me.name의 ${my.name}은 다른 곳에서 별도로 선언된 my.name의 값인 “ME”로 설정된다. 알고 나면 참 쉬운데, 모르면 알기 어렵다. @_@
- 참고 https://github.com/typesafehub/config/blob/master/HOCON.md#include-syntax http://blog.leocat.kr/post/153820414982/typesafes-config-config%EC%9D%98-default%EA%B0%92-%EC%84%A4%EC%A0%95
[Typesafe’s Config] config의 default값 설정
Typesafe’s Config는 Scala sbt처럼 라인단위로 실행이 되면서, 설정이 되는 형태의 config이다. (Maven처럼 선언적으로 설정하는 방식이 아니다.)
때문에, 하나의 key를 여러번 설정할 수도 있다. 아래 같이 설정하면, http.port의 값은 9090이 된다. (8080으로 설정된 다음, 다시 9090으로 덮어 써진다.)
http { port=8080 port=9090 }
이 방법과 변수설정을 이용해서 default값을 설정할 수 있다.
http { host=localhost host=${?HTTP_HOST} port=8080 port=${?HTTP_PORT} }
${VAR}와는 다르게 ${?VAR}는 변수에 설정된 값이 있는 경우에만 실행이 된다. java 명령 실행 시 -D 옵션으로 HTTP_PORT의 값을 주지 않는 경우 http.port는 8080이 되고, HTTP_PORT 값을 설정해 주면 다시 한번 덮어써져서 설정된 값으로 사용 가능하다. 시스템의 environment variables로 설정해 줘도 된다.
java -DHTTP_PORT=9090 MyClass java MyClass
- 참고 [Typesafe’s Config] 변수 사용하기 https://github.com/typesafehub/config http://blog.michaelhamrah.com/2014/02/leveraging-typesafes-config-library-across-environments/
[Typesafe’s Config] 변수 사용하기
Typesafe’s Config를 사용하는 프로젝트에서 시스템의 environment variable 이나 Java system properties를 사용할 수 있다. 아래처럼 ${VAR} 형식으로 써주면 된다.
http { base-url=${BASE_URL} port=8080 }
아래와 같이 java 명령의 -D옵션을 주거나, 시스템 환경변수를 넣어주면 된다.
java -DBASE_URL=myhost.com MyClass
${VAR}와 비슷하게 ${?VAR}를 사용할 수 있다. ${?VAR}는 해당 변수에 설정되어 있는 경우에만 실행이 된다. 아래처럼 설정되어 있을 때 -D옵션 등으로 HTTP_PORT 변수를 설정해 주지 않으면 http.port는 값이 없게 된다.
http { port=${?HTTP_PORT} }
조심할 점은 아래처럼 “”안에 들어 있으면 치환되지 않으니 조심하자.
http { base-url=“http://localhost:${HTTP_PORT}/some/path” }
- 참고 [Typesafe’s Config] config의 default값 설정 https://github.com/typesafehub/config http://blog.michaelhamrah.com/2014/02/leveraging-typesafes-config-library-across-environments/
THOUGHTS BEHIND REBRANDING - TYPESAFE IS NOW LIGHTBEND
In February 23, 2016 Mark Brewer, CEO of erstwhile Typesafe announced in his official blog that Typesafe Changes Name to Lightbend [https://www.lightbend.com/blog/typesafe-changes-name-to-lightbend]
Quoting Gartner he mentioned that the key industry challenge is “traditional application architectures and platforms are obsolete.” And this exposes their strategy to adopt Reactive Platform and to move away from the shadow of Scala, a name that had become synonymous with Typesafe and probably Scala is today becoming more popular and hence misleading for the company’s growth strategy.
While Scala still remains the core product, Lightbend would like to explore the development opportunities beyond the reputation of Scala and help business leaders in nearly every industry to modernize their applications and infrastructure in order to survive. This was quite necessary since the company identified that the majority of their customers were using Java and other JVM languages other than Scala.
Reactive Platform, based on Play, Akka and Spark, have published their new process in Reactive Manifesto and leading the Reactive Streams specification to be included in JDK 9.
Brewer also named the latest product Lagom (Swedish for "just right"), an open source Microservices framework designed to help developers adopt reactive architectures and thus inviting the Java community to collaborate.
The reaction to this change was quite reserved, especially for the Scala community who felt that the success of Scala was partially due to backing of Typesafe but now that the company is adopting Enterprise Java the biggest loser will be Scala in this entire process. However Brewer said they remain fully committed to the Scala language. He also mentioned Logam would publish its Java API first, since it’s been challenging to convert the expressive Scala APIs in their products to Java.
SpringPeople is the exclusive education delivery partner of Lightbend within the Indian Subcontinent. With Anjan Pathak & N. Bharadwaj as the certified experts learn Scala, Akka, Play and Advanced Scala, as they walk you through real life examples from their businesses and industry to make you pro.
We’re still basking in all the novelty and excitement of our Lightbend rebrand. Over the last week, the amount of congratulatory messages and compliments we’ve received on our new website design and project initiatives has been overwhelming and flattering––a huge and sincere thank you to all of our supporters. The announcement also surfaced some important questions about our commitment to the Scala ecosystem. We decided to address them through a short Q&A blog post. We hope you find the responses assuring and clear. Feel free to reach out to us directly with any other concerns or thoughts.