czwartek, 13 listopada 2014

JAVA OMG

  • Name: lets call this anti-pattern signification
  • Description: we can be sure that the original string will be converted to string
  • Why: to much free RAM and CPU
  • Example:
    new String(Integer.toString(deviceInfo.imageWidth))
    

środa, 12 listopada 2014

Quine

A quine is a program that prints itself:

Quine in JS

// browser
!function $(){console.log('!'+$+'()')}()

// node
(function quine() {
    console.log(quine.toString())
})()

Quine in Java

  // http://c2.com/cgi/wiki?QuineProgram
  public class Quine {
 public static void main(String[] args) {
 String[] str = {
  "public class Quine {",
  " public static void main(String[] args) {",
  "  String[] str = {",
  "  };",
  "  for(int i=0;i<3;i++)System.out.println(str[i]);",
  "  for(int i=0;i<9;i++)System.out.println((char)34+str[i]+(char)34+',');",
  "  for(int i=3;i<9;i++)System.out.println(str[i]);",
  " }",
  "}",
 };
 for(int i=0;i<3;i++)System.out.println(str[i]);
 for(int i=0;i<9;i++)System.out.println((char)34+str[i]+(char)34+',');
 for(int i=3;i<9;i++)System.out.println(str[i]);
 }
  }

Practical use

I used quines to print my programs as slides during Functional Programming workshop.