java – command-line demo app & design-pattern usage examples

I started learning from the book: head first design patterns. As I am trying out different programs in the book, I am compiling them in this one demo app. Below is the code for its driver function. Can anyone guide me with any improvements to the program (related to style, programming, formatting or anything else)? Entire repository can be found here: Any improvement in rest of those functions would be appreciated as well.

Demo Driver Code:

package com.aviralgarg;

import java.util.Scanner;

import static com.aviralgarg.strategy.Main.runDuckSimulator;

public class Main {
    public static void main(String() args) {

        try {
        } catch (Exception e) {
        } finally {
            System.err.println("Something went horribly wrong!");

    private static void demoLoop() {
        while (true) {

            Scanner scanner = new Scanner(;
            int option = scanner.nextInt();

            switch (option) {
                case 0 -> System.exit(0);
                case 1 -> showDesignPrinciples();
                case 2 -> runDuckSimulator();
                default -> System.err.println("Please select a valid option.");


    private static void showHorizontalLine() {

    private static void showOptions() {
        System.out.println("nPick one of the following options:" +
                "nt1. Show design principles" +
                "nt2. Strategy pattern - Run the Duck Simulator" +
                "nt0. Exit");

    private static void showDesignPrinciples() {
        System.out.println("Design Principles:" +
                "n1. Identify the aspects of your application that vary and separate them from what stays the same." +
                "n2. Program to an interface, not an implementation." +
                "n3. Favor composition over inheritance." +

What Are Some Great Examples Of Link Bait?


soft question – What are some examples of theorem requiring highly subtle hypothesis?

I would like you to expose and explain briefly some examples of theorems having some hypothesis that are (as far as we know) actually necessary in their proofs but whose uses in the arguments are extremely subtle and difficult to note at a first sight. I am looking for hypothesis or conditions that appear to be almost absent from the proof but which are actually hidden behind some really abstract or technical argument. It would be even more interesting if this unnoticed hypothesis was not noted at first but later it had to be added in another paper or publication not because the proof of the theorem were wrong but because the author did not notice that this or that condition was actually playing a role behind the scene and needed to be added. And, finally, an extra point if this hidden hypothesis led to some important development or advance in the area around the theorem in the sense that it opened new questions or new paths of research. This question might be related with this other but notice that it is not the same as I am speaking about subtleties in proof that were not exactly incorrect but incomplete in the sense of not mentioning that some object or result had to be use maybe in a highly tangential way.

In order to put some order in the possible answers and make this post useful for other people I would like you to give references and to at least explain the subtleties that helps the hypothesis to hide at a first sight, expose how they relate with the actual proof or method of proving, and tell the main steps that were made by the community until this hidden condition was found, i.e., you can write in fact a short history about the evolution of our understanding of the subtleties and nuances surrounding the result you want to mention.

A very well known and classic example of this phenomenon is the full theory of classical greek geometry that although correctly developed in the famous work of Euclides was later found to be incompletely axiomatized as there were some axioms that Euclides uses but he did not mention as such mainly because these manipulations are so highly intuitive that were not easy to recognize that they were being used in an argument. Happily, a better understanding of these axioms and their internal respective logical relations through a period of long study and research lasting for millennia led to the realization that these axioms were not explicitly mention but necessary and to the development of new kinds of geometry and different geometrical worlds.

Maybe this one is (because of being the most classic and expanded through so many centuries and pages of research) the most known, important and famous example of the phenomena I am looking for. However, I am also interested in other small and more humble examples of this phenomena appearing and happening in some more recent papers, theorems, lemmas and results in general.

Note: I vote for doing this community wiki as it seems that this is the best way of dealing with this kind of questions.

functional analysis – Please define $ℓ2$ space and give some examples of its subspaces

Thanks for contributing an answer to Mathematics Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.

ct.category theory – Examples of connection preserving maps in differential geometry

In synthetic differential geometry and tangent categories, linear connections on the tangent bundle are treated as a sort of algebraic gadgets that incorporate the tangent bundle. Like any other algebraic gadget, it seems natural to consider morphisms $f:M to N$ that preserve a chosen linear connection $(M, nabla), (N, nabla’)$. I’ve tried searching through the differential geometry literature, and connection-preserving morphisms doesn’t seem to be discussed very much (except the case where an isometry between Riemannian manifolds induces a connection-preserving morphism between their Levi-Civita connections).

Have connection-preserving maps been considered by differential geometers, and if so, can someone point me in that direction?