xxxxxxxxxx
What is a design pattern?
A re-usable solution to a type of problem.
xxxxxxxxxx
"Design Pattern" or DP is really the same as "Best Practices'
(best practices for solving problems)
In Software development, DP is the same as Software Engineering
there are about 23 different design patterns
One example is a Singleton Pattern that uses one and only one
instance of a class such as a server logger or a server DBconnectionManager.
Another example is a Factory pattern that uses a factory class that would
instantiate subclasses based on args or parms. E.g. a certain factory class
to generate, say a form given a model. The trick is knowing what the app
requires and what factories are already available [in the framework]
xxxxxxxxxx
Design patterns are the reusable solutions that solve common problems of software development.
These problems include repetitive code, redundant functions and logic etc. These help to save considerable effort and time required for the developers while developing software.
Design patterns are commonly used in object-oriented software products by incorporating best practices and promoting reusability for developing robust code.
xxxxxxxxxx
What is a Software design pattern?
Recurring solutions to typical design issues.
Design patterns are the reusable solutions that solve common problems of soware
development. These problems include repetitive code, redundant functions and logic
etc. These help to save considerable effort and time required for the developers while
developing soware. Design patterns are commonly used in object-oriented soware
products by incorporating best practices and promoting reusability for developing
robust code.
xxxxxxxxxx
public class Demo {
private static Dialog dialog;
public static void main(String[] args) {
configure();
runBusinessLogic();
}
/**
* The concrete factory is usually chosen depending on configuration or
* environment options.
*/
static void configure() {
if (System.getProperty("os.name").equals("Windows 10")) {
dialog = new WindowsDialog();
} else {
dialog = new HtmlDialog();
}
}
/**
* All of the client code should work with factories and products through
* abstract interfaces. This way it does not care which factory it works
* with and what kind of product it returns.
*/
static void runBusinessLogic() {
dialog.renderWindow();
}
}