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
/** | |
* Kotlin examples of following/violation Law of Demeter LoD (a.k.a. Principle of Least Knowledge PoLK) | |
* | |
* Law of Demeter for functions requires that a method m of an object O may only invoke the | |
* methods of the following kinds of objects: | |
* 1. O itself | |
* 2. m's parameters | |
* 3. Any objects created/instantiated within m | |
* 4. O's direct component objects | |
* 5. A global variable, accessible by O, in the scope of m |
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
@Test | |
public void when_take_view_register_event_bus() { | |
// given | |
profilePresenter.takeView(mockView); | |
// then | |
then(mockEventBus).should().register(profilePresenter); | |
} |
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
@Test | |
fun `when take view then register event bus`() { | |
// given | |
profilePresenter.takeView(mockView) | |
// then | |
then(mockEventBus).should().register(profilePresenter) | |
} |
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
fun sum(a:Int, b:Int): Int { | |
return a + b | |
} |
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
fun sum (a:Int, b:Int): Int { | |
log.info("Added $a + $b") | |
return a + b | |
} |
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
fun setProgressbarVisibility(visible:Boolean): Int { | |
progressBar.visible = visible; | |
} |
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
fun setPatient() { | |
return this.patient | |
} |
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
fun getCurrentTime(): Long { | |
return System.currentTimeMillis() | |
} | |
fun getBoolean(): Boolean { | |
return Random().nextBoolean() | |
} |
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
fun increatePatientAge(patient:Patient): Patient { | |
patient.age = patient.age++ | |
return patient | |
} |
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
fun sum (a:Int, b:Int): Int { | |
if(a > b) { | |
throw IllegalAccessException() | |
} | |
return a + b | |
} |
OlderNewer