-
Live Templates for Annotators
An annotation is a form of syntactic metadata which can be added into Java source code. Using it, you can add some additional information for parameters, methods and classes. Personally, I use @NonNull and @Nullable annotations a lot. With them, I know a parameter requirement and a mismatched type easily. public Image(@NonNull String url, @NonNull String title); /** * A...
-
Descriptive Unit Testing with AssertJ
JUnit is the most popular framework for unit testing. To check or assert any variable, it provides these methods: public static void assertTrue(boolean condition) public static void assertFalse(boolean condition) public static void assertEquals(Object expected, Object actual) ... These methods are enough for unit testing. However, I’ve noticed that a assertion message is not descriptive. Here is an example. 1 2...
-
Check before Calling performClick()
In Android, View.performClick is defined as: /** * Call this view's OnClickListener, if it is defined. Performs all normal * actions associated with clicking: reporting accessibility event, playing * a sound, etc. * * @return True there was an assigned OnClickListener that was called, false * otherwise is returned. */ public boolean performClick() Using calling method, view’s OnClickListener can be...
-
Keep It Simple! Cyclomatic Complexity
Whenever you write code, writing simple code is important. It will improve the maintainability. So, you and other developers can easily test, understand and modify. Here is an important question. How do you know that your code is simple? You may say that it is short so that it is simple. Short code is always good. However, we need a...
-
Add Task to Wunderlist with Automator Service
Wunderlist is a handy task management application which supports a synchronization across all major devices. These days, I’m using it not only for my tasks but also for memos about ideas and references. I usually add a task inside the application. However, I often just copy a text and add a task by pasting. You might notice that it would...
-
Bash Pattern
Variable A variable is a symbolic name for information. In the bash, it can be declared with an equal sign =. Unlike other languages such as C and Java, a variable type is not needed. ❯ VAR=28 To use/expand the variable, you can simply type its name used in declaration with a prefix $ . If you use the variable...