The Factory Method is a creational design pattern, in which an interface handles the creation of objects without specifying the class of an object that will be created. The subclasses will declare the type of object to be created. UML Diagram Example The Product interface is implemented by ProductA and ProductB. The Creator class holds …
Author Archives: chris mayol
Design Pattern: Observer
The observer pattern is a behavioral design pattern that allows an object (the observer) to notify other subscribed objects about any events that has occurred on the object they’re observing. When should I use this? When the change of a state in one object must be reflected in another object without keeping the objects tightly …
Design Pattern: Strategy
The Strategy design pattern is a behavioral pattern, where it defines a family of functionality, encapsulating each of them and making them interchangeable. This strategy pattern can be useful in a road navigator software, where you have an interface called routeStrategy and it has an abstract buildRoute() function. An all the possible route strategies like …
SQL Drop, Delete and Truncate
In SQL there are 3 commands that are used to remove data from a database. Although they remove data, they have major differences. Let’s assume we have a database call school and with in that school we have table call class, within this class we have a bunch of records of students that attend this …
Java Threads
Lets say we want our java program to run multiple tasks concurrently, how will we accomplish this ? Well, the answer is “threads“, threads run concurrently with other threads. In order to create threads we have to extend the “Thread” class or implement “Runnable” interface. Well what’s the difference? Remember that in java we can’t …
SQL JOINS
What are SQL joins? Well, there are several different types of joins and they are used to retrieve data between two different tables. INNER JOIN: Retrieves the records between the tables, that satisfy the join condition. LEFT JOIN: Retrieves the records of table ‘A’ and only records of table ‘b’ that satisfy the join condition. …
SQL Interview Questions
Q1: What is SQL? The Structure Query Language is the standard language for relational data bases. SQL uses tables to allow for setting or retrieving data from a database. Q2: Define DDL, DML and DCL DDL (Data Definition Language) – It allows you to perform sql commands that define the database scheme. Some of these commands …
Java File IO Part 1
In order to work with files in java we need to first learn about the file class. The file class allows us to represent a file in our file system. Let’s Import java.io.* for all the necessary classes. In the code above we create two file objects representing dummy.txt, one in the current directory and …
Java Interview Questions
Q1: Is Java Platform dependent ? A: No, Java is a platform independent language. A platform independent language doesn’t depend on the operating system or hardware. Unlike programming languages like C++ or C which are platform dependent and won’t run on every platform. Q2: What makes Java a platform independent language? A: Java uses the …
My First Blog Post
Be yourself; Everyone else is already taken. — Oscar Wilde. This is the first post on my new blog. I’m just getting this new blog going, so stay tuned for more. Subscribe below to get notified when I post new updates.