Design Patters, Java and the Factory Pattern

Have you ever looked at a piece of code, project or application and thought “what on earth is going on here”? I have many times and so have many other developers, so ages ago, Design Patterns were introduced to keep coding clean, and organised.

You probably organise your code already closely to a few design patterns without even realising. Today, I’ll introduce the Factory Pattern as a method of structuring your code.

The Factory Pattern allows objects of similar logic to be created to a common interface.

Tutorialspoint has a great example involving shapes.

Summarising the example, you can have a shape factory that creates triangles, squares, circles.

This may seem rather abstract, but for example, you may want to make different types of database connection for customers and want to get their details, which they would have a Customer interface, but a Customer Factory for all the individual details so that they are not exposed to the client.


Getting Started With Spring Boot?

What is Spring Boot?

Spring Boot is a Java framework. Spring Boot shouldn’t be confused with Spring Framework and more information can be found here.

How do I get started?

The Spring Boot webpage is a great place to start. You can install via Maven (or Gradle).

Great, why should I do this?

Spring Boot is great for setting up web services and other applications quickly and without too much complication, but allows the developer to configure parts to make diverse applications without spending too much time setting up the project.

Give it a try and see what you think 🙂