Loyalty Campaign Manager is an application to manage user loyalty, including points, rewards and coupons.
- MySQL database built for loyalty-mobilem8-components
- Tomcat running with
mobilem8-loyalty-admin
andloyalty-services
apps
package com.tillster.tools; | |
import java.util.UUID; | |
/** | |
* Add this to your ~/.bash_profile | |
* alias uuid="java -cp ~/Tools/out/production/Tools com.tillster.tools.UuidGen" | |
*/ | |
public final class UuidGen { | |
private UuidGen() { } |
package com.tillster.tools; | |
import java.io.File; | |
import java.util.*; | |
/** | |
* Add this to your ~/.bash_profile | |
* alias sysprops="java -cp ~/Tools/out/production/Tools com.tillster.tools.SysProps" | |
*/ | |
public final class SysProps { |
Loyalty Campaign Manager is an application to manage user loyalty, including points, rewards and coupons.
mobilem8-loyalty-admin
and loyalty-services
appsThis is a work-in-progress. There's a lot here that I plan to rewrite, but the opening section, including and ending with the five examples, is very close to its final form.
Many people, including me, were excited that an Optional class was introduced in Java 8. As soon as I saw it, I was disappointed by how verbose it was, and puzzled by the strange and long-winded approach. At the time, I misunderstood its purpose, as did a lot of other people. Many people began to use it extensively. It's now very widespread, and it has led to some amazingly bad code, written by people who don't understand what it's for. In certain limited situations it's actually very useful, although I rarely actually use myself. Here's my take on Java's Optional class. (Some of this is taken from a StackOverflow question that I answered. This expands on my answer.)
I was disappointed by the introduction of Optional to the Java language, because I've been using @Nullable and @NotNull annotations for years, and it's a much simpler solution. The big advantage of this approach is that it makes null pointers a compile-time error rather than a run-time bug. Now that I've worked with Optional and seen it in action in production code, I've only strengthened my earlier view. Here are some examples, all taken from production code, of bad usages of Optional, with notes on what it would look like with the NullnessChecker annotation processor instead.
01 private void someMethod(Widget widget, ... <other parameters>) {
02 Optional<Widget> widgetOpt = Optional.of(widget);
03 if (!widgetOpt.isPresent) {
04 throw new BusinessException("Missing Widget");
05 }
In my Java Optional, Java's Nullness Flaw, and the Kotlin Language blog post, I give lots of examples of the misuse of the Optional class. Here I'm going to discuss a case where it's clearly being used correctly, but still (and surprisingly) isn't quite necessary.
A useful blog post by Brian Goetz shows how Optional was intended to get used. Briefly, he says that it's because this:
return Arrays.asList(enclosingInfo.getEnclosingClass().getDeclaredMethods())
.stream()
.filter(m -> Objects.equals(m.getName(), enclosingInfo.getName())
.filter(m -> Arrays.equals(m.getParameterTypes(), parameterClasses))
#Note: Since this file exists, the .profile file will not execute. | |
#Note 2: This file executes at the beginning of each terminal window | |
#Note 3: The .bash_login file executes only on login. | |
#Save original path. This lets me rerun this file without adding the same thing to the PATH over and over again. | |
#This is especially useful if I need to modify the path and need to experiment a bit to get it right. | |
FIRST_TIME=false | |
if [ "x$ORIG_PATH" == "x" ] | |
then | |
ORIG_PATH=$PATH |
package com.mm.exp.clock; | |
import java.awt.*; | |
import java.awt.geom.AffineTransform; | |
import java.awt.geom.Arc2D; | |
import java.awt.geom.Line2D; | |
import java.awt.image.BufferedImage; | |
import java.text.DateFormat; | |
import java.util.Calendar; | |
import java.util.Date; |
package com.mm.exp; | |
import java.math.BigDecimal; | |
import java.util.*; | |
import java.util.stream.Collectors; | |
/** | |
* Expense Reports. | |
* max is maximum to spend | |
* source is list of expenses, exceeding maximum. |