Skip to content

Instantly share code, notes, and snippets.

View MinCha's full-sized avatar

Min Cha MinCha

View GitHub Profile
@MinCha
MinCha / gist:8995040
Created February 14, 2014 02:57
Tell, Don`t Ask #1
public class ReadOnlyNotifier {
public List<String> getRelatedServices() {
return null;
}
public boolean notifyToRelatedServices(StopMessage stopMessage) {
return false;
}
@MinCha
MinCha / gist:8995058
Created February 14, 2014 02:58
Tell, Don`t Ask #2
public class ReadOnlyNotifier {
private List<String> getRelatedServices() {
//
}
public void notifyToRelatedServicesIfItNeeds(StopMessage stopMessage) {
if (getRelatedServices().size() > 0) {
if (notifyToRelatedServices(stopMessage) == false) {
throw new FailedReadOnlyNotificationException();
#!/bin/sh
if [ ! -f ./success ]; then
curl -g http://send --data-urlencode group=$1 --data-urlencode "msg=Failed $2 $3"
fi
// 2. Double Dispatch 방식 리팩토링
NewPrescription prescription = new NewPrescription();
assertEquals("two pill a day", prescription.getPrescription(new SeriousPatientStatus(), new AdultPatientType()));
assertEquals("one pill a day", prescription.getPrescription(new MildPatientStatus(), new AdultPatientType()));
assertEquals("one pill a day", prescription.getPrescription(new SeriousPatientStatus(), new ChildPatientType()));
assertEquals("half pill a day", prescription.getPrescription(new MildPatientStatus(), new ChildPatientType()));
public class NewPrescription {
public String getPrescription(PatientStatus status, PatientType type) {
@Test
public void testGetPrescription() throws Exception {
NewPrescription prescription = new NewPrescription();
assertEquals("two pill a day", prescription.getPrescription(new SeriousPatientStatus(), new AdultPatientType()));
assertEquals("one pill a day", prescription.getPrescription(new MildPatientStatus(), new AdultPatientType()));
assertEquals("one pill a day", prescription.getPrescription(new SeriousPatientStatus(), new ChildPatientType()));
assertEquals("half pill a day", prescription.getPrescription(new MildPatientStatus(), new ChildPatientType()));
}
public interface PatientStatus {
@MinCha
MinCha / gist:c40f214b78d67bd6cbca
Created November 18, 2014 02:45
Jenkins startup.sh
#!/bin/bash
java -jar jenkins.war --httpPort=8080
@MinCha
MinCha / gist:badc208ef01fd216b278
Created February 10, 2015 12:53
My Functional Class #1
case class AddressString(address: Address, newAddress: NewAddress) {
private def getNTh(n: Int, f: List[String] => Boolean): String = {
def getOnlyLastThree(string: String): List[String] = {
if (string.split(" ").length > 3)
string.split(" ").toList.tail
else
string.split(" ").toList
}
val a = if (f(getOnlyLastThree(address.region))) getOnlyLastThree(address.region)(n) else ""
@MinCha
MinCha / gist:59e001fbffb5e916e52c
Created February 10, 2015 12:54
My Function Class #2
@Component class InTransaction {
@Transactional def execute[T](f: => T): T = f
}
object InTransaction {
def apply[T](f: => T): T = Global.ctx.getBean(classOf[InTransaction]).execute(f)
}
def findListByUserMatching(): EssentialAction = UserAction { user =>
request =>
# Examples
git merge --strategy-option theirs master
package susu
import org.junit.Test
import org.scalatest.junit.JUnitSuite
import scala.annotation.tailrec
import scala.util.Random
class SusuPremium extends JUnitSuite {
@Test def elect() {