Spring API Bingo

For the occasion of today’s date, I’ve just invented a fun game. The Spring API Bingo! How does it work? Let us write the following little piece of code:

public class SpringAPIBingo {
    public static void main(String[] args) {
        // Any similarities with actual API
        // (e.g. that of Spring) are completely 
        // accidental
        List<String> terms = Arrays.asList(
            "Abstract",
            "Adapter",
            "Adaptor",
            "Advisor",
            "Aware",
            "Bean",
            "Class",
            "Container",
            "Data",
            "Definition",
            "Delegate",
            "Delegating",
            "Destination",
            "Detecting",
            "Disposable",
            "Entity",
            "Exception",
            "Factory",
            "Handler",
            "Info",
            "Initializer",
            "Initializing",
            "Local",
            "Loader",
            "Manager",
            "Mapping",
            "Persistence",
            "Post",
            "Pre",
            "Resolver",
            "Source",
            "Target",
            "Translation",
            "Translator"
        );

        // [...]

So far so good. We could use more terms if we wanted to but for now, these will suffice. Now, let’s shuffle the above list and create names of length 2-5 terms. Easy as pie. We’re using Java 8 for this. So our programme above continues like so:

        // [...]

        System.out.println("<table>");
        System.out.println("<tr>");

        for (int i = 0; i < 25; i++) {
            if (i > 0 && i % 5 == 0)
                System.out.println("</tr><tr>");

            System.out.print("<td>");

            Collections.shuffle(terms);
            System.out.print(
                terms.stream()
                     .limit((long) (2 + 
                          Math.random() * 4))
                     .collect(Collectors.joining())
            );

            System.out.println("</td>");
        }

        System.out.println("</tr>");
        System.out.println("</table>");
    }
}

As you can see, the above generates a 5×5 HTML table of random names. As this blog is not wide enough for a 5×5 table, let’s break down the table for readability purposes:
Column 1
ClassContainerPost
FactoryAdvisorAdapterHandlerLoader
AdvisorMapping
ResolverAdaptorTranslatorEntity
LocalEntity
Column 2
AdaptorExceptionDefinitionPreMapping
TranslatorLoader
ContainerPreTranslatorInfoDisposable
TranslatorPostFactory
PreClassResolver
Column 3
DetectingDelegatingAdaptor
ContainerLocalTranslation
DetectingClass
DefinitionManagerDisposableAbstract
MappingDelegatingPersistenceAbstractHandler
Column 4
PreMappingDetectingClassAdapter
ManagerResolverExceptionBeanAware
BeanFactoryDestinationResolver
TranslationBean
LocalPersistenceManagerFactoryBean
Column 5
ExceptionLocal
InfoPreSourceBeanFactory
AbstractBeanDefinition
PersistencePre
DisposableBean
Now, let’s go visit the Spring Javadoc. We’ll take version 4.0’s allclasses page for optimal winning chances. Go back to your 5×5 table and mark all matches. Now let’s check if we have 5 matches in a row, bingo!
Column 1
ClassContainerPost
FactoryAdvisorAdapterHandlerLoader
AdvisorMapping
ResolverAdaptorTranslatorEntity
LocalEntity
Column 2
AdaptorExceptionDefinitionPreMapping
TranslatorLoader
ContainerPreTranslatorInfoDisposable
TranslatorPostFactory
PreClassResolver
Column 3
DetectingDelegatingAdaptor
ContainerLocalTranslation
DetectingClass
DefinitionManagerDisposableAbstract
MappingDelegatingPersistenceAbstractHandler
Column 4
PreMappingDetectingClassAdapter
ManagerResolverExceptionBeanAware
BeanFactoryDestinationResolver
TranslationBean
LocalPersistenceManagerFactoryBean
Column 5
ExceptionLocal
InfoPreSourceBeanFactory
AbstractBeanDefinition
PersistencePre
DisposableBean
Only four hits. Better luck next time.

Next week: Facebook Bingo

We’ll write down 25 tech companies in a 5×5 grid. Then wait until Facebook buys new companies. If you got 5 in a row – Bingo!

Leave a Reply