In State pattern a class behavior changes based on its state. This type of design pattern comes under behavior pattern. In State pattern, we create objects which represent various states and a context object whose behavior varies as its state object changes. State.java public interface State { public void doAction(Context context); } StartState.java public class …
Design Patterns – Strategy Pattern
In Strategy pattern, a class behavior or its algorithm can be changed at run time. This type of design pattern comes under behavior pattern. In Strategy pattern, we create objects which represent various strategies and a context object whose behavior varies as per its strategy object. The strategy object changes the executing algorithm of the …
Design Pattern – Abstract Factory Pattern
Abstract Factory patterns work around a super-factory which creates other factories. This factory is also called as factory of factories. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object. In Abstract Factory pattern an interface is responsible for creating a factory of …
Continue reading “Design Pattern – Abstract Factory Pattern”
Design Pattern – Factory Pattern
Factory pattern is one of the most used design patterns in Java. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object. In Factory pattern, we create object without exposing the creation logic to the client and refer to newly created object using …
Design Pattern – Singleton Pattern
Singleton pattern is one of the simplest design patterns in Java. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object. This pattern involves a single class which is responsible to create an object while making sure that only single object gets created. …
How to Using GCC with MinGW on Windows
Install Visual Studio Code. Install the C/C++ extension for VS Code. You can install the C/C++ extension by searching for ‘c++’ in the Extensions view (Ctrl+Shift+X). Get the latest version of Mingw-w64 via MSYS2, which provides up-to-date native builds of GCC, Mingw-w64, and other helpful C++ tools and libraries. You can download the latest installer from the MSYS2 …
Making a Git push from a detached head
If you are on a detached head and you want to push to your remote branch otherwise you can create a new branch and push to it ( it will be created automatically )
fatal: ‘XXX’ could be both a local file and a tracking branch. please use — (and optionally –no-guess) to disambiguate
This is definitely an edge case but easily solved. This action calls git checkout XXX, but because you have a branch, and a folder called XXX it ends up getting confused and asks you to clarify. In an attempt to solve this I’ve used git switch to specify that you want to switch to the branch specifically.
npm vs npx — What’s the Difference?
npm the package manager npm is a couple of things. First and foremost, it is an online repository for the publishing of open-source Node.js projects. Second, it is a CLI tool that aids you install those packages and manage their versions and dependencies. There are hundreds of thousands of Node.js libraries and applications on npm …
Git detached head
Most of the time, HEAD points to a branch name. When you add a new commit, your branch reference is updated to point to it, but HEAD remains the same. When you change branches, HEAD is updated to point to the branch you’ve switched to. All of that means that, in these scenarios, HEAD is …