Factory method pattern enables us to create an object without exposing the creation logic to the client and refer to the newly-created object using a common interface. It is one of the most widely used creational patterns. This pattern is also known as the Virtual Constructor. The intent of this pattern, according to Design Patterns by Gamma et al, is to: Define an interface for creating an object, but let subclasses decide which class to instantiate. The Factory method allows a class to defer instantiation to subclasses. The Factory method is for creating objects. A superclass specifies all standard and generic behavior and then delegates the creation details to subclasses…
-
-
Functional Programming in Java 8
References: https://flyingbytes.github.io/programming/java8/functional/part1/2017/01/23/Java8-Part1.html https://dzone.com/articles/functional-programming-in-java-8-part-2-optionals?fromrel=true
-
All Java Built-In Annotation Examples
Java introduced annotations upon their Java 1.5 release. Since then, annotations have shaped the way we design our applications. In this article, we’ll talk about a set of predefined annotation types in the Java SE API. Some annotation types are used by the Java compiler and some apply to other annotations. What Is Annotation? Annotations are Java types that are preceded by an @ symbol. Java has had annotations ever since the 1.5 release. Since then, they’ve shaped the way we’ve designed our applications. Spring and Hibernate are great examples of frameworks that rely heavily on annotations to enable various design techniques. Basically, an annotation assigns extra metadata to the…
-
How do I optimize a WordPress site for SEO?
Well, if you have an up and running WordPress website, you’d know how important it is to optimize your website for search engines. It doesn’t matter how beautifully your website is crafted or how you create a website, without proper SEO it isn’t going to work in full pace. An SEO-friendly website has higher chances of appearing on the first page of the search results and drive constant traffic to your website especially if you combine that with traffic tools that can be at your disposal fairly quickly. SEO has always been the buzzword of the online world. After all, every business wants to have higher rankings and come up…
-
Different ways to traverse a Map in Java
In this quick article, we’ll have a look at the different ways of iterating through the entries of a Map in Java. Simply put, we can extract the contents of a Map using keySet(), valueSet() or entrySet(). Since those are all sets, similar iteration principles apply to all of them. The Map.entrySet API returns a collection-view of the map, whose elements are from the Map class. The only way to obtain a reference to a single map entry is from the iterator of this collection view. The entry.getKey() returns the key and entry.getValue() returns the corresponding value. Let’s have a look at a few of these. We will use following…
-
Convert a List to a Set in Java
Nam eu nisi non quam ultrices lacinia non sit amet urna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi pulvinar felis at massa auctor, ac bibendum dolor facilisis. Quisque tristique fringilla convallis. Quisque justo nunc, ornare et turpis et, mollis lobortis lectus. Vivamus blandit nulla et finibus hendrerit. Aliquam at dui id erat ullamcorper fringilla. Aliquam id tellus est. Praesent elementum in nisi quis volutpat. Vestibulum non augue vel dui consequat tempus ut vitae magna. Curabitur ligula orci, facilisis et urna a, rutrum auctor lorem. Proin lacinia sodales diam, vel congue purus feugiat in. Sed ut mattis sem, ac lacinia odio. Donec est leo, tincidunt sit amet tortor nec,…
-
Nullam fringilla mattis velit
Nullam fringilla mattis velit, quis fringilla velit feugiat quis. Phasellus consectetur, turpis vehicula eleifend volutpat, mauris mi semper nisi, in rhoncus nunc nibh sit amet leo. Mauris vestibulum risus eget augue varius pulvinar a et nunc. Nunc et eleifend sem, quis malesuada dui. Suspendisse ut lorem eget nibh blandit dapibus vitae ut dui. Ut ut lorem in magna accumsan sollicitudin vel eu mauris. Nunc mollis dui sit amet magna bibendum, non vestibulum justo egestas. Donec consectetur odio nec leo efficitur congue. Curabitur pretium elit vitae enim pellentesque, id gravida arcu consequat. Cras nec tincidunt metus. Phasellus fermentum nunc velit, eget tempor ipsum dapibus in. Sed molestie luctus massa eget sagittis.…
-
Proin auctor lacus ac consectetur
Donec dui arcu, vulputate in dolor pretium, tempus accumsan erat. Pellentesque tempor erat ligula, ut porttitor erat iaculis sit amet. Proin auctor lacus ac consectetur convallis. Sed rutrum arcu at tellus rutrum commodo. Ut nec suscipit eros, quis luctus odio. Suspendisse in tortor nisl. Fusce tempus tellus magna, et tristique quam semper non. Integer elementum magna sed tincidunt commodo. Nam eu velit nec augue dictum facilisis ac sit amet velit. Mauris a finibus dui.
-
Suspendisse vel interdum neque
Suspendisse vel interdum neque, in aliquam augue. Donec vel elementum augue. Nulla cursus enim ut leo feugiat posuere ut et sapien. Vestibulum cursus elementum leo, at finibus dolor. Cras condimentum magna at elementum posuere. In sit amet sagittis tortor. Curabitur nec eleifend est. Morbi elementum, tellus varius accumsan lacinia, magna ipsum condimentum turpis, ac aliquam neque lacus quis est. Donec tincidunt ex vel tellus maximus commodo. Phasellus volutpat ac libero vel dapibus.
-
Mauris egestas risus vel dapibus
Mauris egestas risus vel dapibus pellentesque. Maecenas facilisis, ipsum a dapibus mattis, risus sapien finibus velit, sed pharetra tellus sem ac ligula. Morbi dapibus, metus non lacinia suscipit, sapien augue semper nisl, euismod ullamcorper odio tellus vitae orci. Aenean facilisis purus non mollis tincidunt. Ut eget volutpat mi, in auctor urna. Aliquam lacus dolor, auctor eget placerat id, commodo vel erat. Vestibulum suscipit facilisis sagittis. Suspendisse dignissim consequat lectus non congue. Etiam eu facilisis dolor. Praesent orci massa, ultrices vel quam non, fermentum convallis dolor. Vivamus eleifend eleifend porttitor. Quisque sodales vulputate auctor. Ut id velit id felis congue pharetra vel non risus. Praesent porta magna a iaculis dictum. Etiam…