This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// global | |
var myApp = myApp || {}; | |
// namespaces | |
myApp.routers = myApp.routers || {}; | |
myApp.model = myApp.model || {}; | |
myApp.model.special = myApp.model.special || {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var testModule = (function () { | |
var myPrivateVar, myPrivateMethod; | |
// A private variable | |
myPrivateVar = 0; | |
// A private function | |
myPrivateMethod = function(foo) { | |
console.log(foo); | |
}; | |
return { | |
// A public variable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FakeBlogRepository implements BlogRepository { | |
private Map<String, List<Post>> data = new HashMap<>(); | |
private long lastPostId = 0L; | |
public long save(long userId, Post post) { | |
lastPostId++; | |
post.setId(lastPostId); | |
List<Post> posts = data.get(userId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthClientImpl implements AuthClient { | |
public long verifyToken(String token) { | |
String rawJson = decrpyt(token); | |
User user = deserialize(rawJson); | |
return user.getId(); | |
} | |
private String decrpyt(String token) { ... } | |
private User deserialize(String rawJson) { ... } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BlogService { | |
public BlogService(AuthClient authClient, BlogRepository repository) { | |
this.authClient = authClient; | |
this.repository = repository; | |
} | |
public AddPostResponse addPost(AddPostRequest request) { | |
// verifyToken 메소드 파라미터 추가 | |
// 리턴 값이 User 객체로 변경 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BlogServiceTest { | |
@Mock | |
private AuthClient authClient; // mock 객체생성 | |
@Mock | |
private BlogRepository blogRepository; // mock 객체생성 | |
@Test | |
public void addPost() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BlogServiceTest { | |
@Test | |
public void addPost() { | |
// given | |
AuthClient authClient = ... | |
BlogRepository blogRepository = ... | |
BlogService service = new BlogService(authClient, blogRepository); // 생성자로 협력 객체 주입 | |
AddPostRequest request = ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SmallClass1 { | |
private Collaborator collaborator1; | |
public void doSomething(){ | |
... | |
} | |
} | |
public class SmallClass2 { | |
private Collaborator collaborator2; | |
public void doSomething(){ | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BigClass { | |
private Collaborator collaborator1; | |
private Collaborator collaborator2; | |
private Collaborator collaborator3; | |
private Collaborator collaborator4; | |
private Collaborator collaborator5; | |
.... | |
public void doSomething(){ | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ClassA { | |
... | |
public void methodA() { // changed | |
... | |
} | |
} | |
public class ClassB { | |
... | |
public void methodB() { // Oh, not affected! | |
... |
NewerOlder