Essays.club - Ensayos gratis, notas de cursos, notas de libros, tareas, monografías y trabajos de investigación
Buscar

Como se dan los Patrones de diseño de software

Enviado por   •  5 de Enero de 2019  •  16.792 Palabras (68 Páginas)  •  274 Visitas

Página 1 de 68

...

© JOURNALDEV.COM PAGE 2 OF 132

---------------------------------------------------------------

6. Command Pattern...................................................................................................... 99 A. Receiver Classes .................................................................................................. 99 B. Command Interface and Implementations ......................................................... 101 C. Invoker Class ...................................................................................................... 102 C. Class Diagram .................................................................................................... 104 D. Command Pattern JDK Example ....................................................................... 105 E. Important Points ................................................................................................. 105 7. State Pattern ............................................................................................................ 107 A. State Interface .................................................................................................... 108 B. Concrete State Implementations......................................................................... 108 C. Context Implementation ..................................................................................... 109 D. Test Program ...................................................................................................... 110 8. Visitor Pattern ......................................................................................................... 111 A. Visitor Pattern Class Diagram............................................................................ 114 9. Interpreter Pattern ................................................................................................... 116 A. Class Diagram .................................................................................................... 119 B. Important Points ................................................................................................. 119 10. Iterator Pattern ...................................................................................................... 120 A. Iterator Pattern in JDK ....................................................................................... 125 B. Important Points ................................................................................................. 125 11. Memento Pattern ................................................................................................... 126 A. Originator Class ................................................................................................. 126 B. Caretaker Class ................................................................................................... 127 C. Memento Test Class ........................................................................................... 128 Copyright Notice ......................................................................................................... 130 References ................................................................................................................... 131

© JOURNALDEV.COM PAGE 3 OF 132

---------------------------------------------------------------

Design Patterns Overview

Design Patterns are very popular among software developers. A design pattern is a well-described solution to a common software problem.

Some of the benefits of using design patterns are:

1. Design Patterns are already defined and provides industry standard approach to solve a recurring problem, so it saves time if we sensibly use the design pattern. 2. Using design patterns promotes reusability that leads to

more robust and highly maintainable code. It helps in reducing total cost of ownership (TCO) of the software product. 3. Since design patterns are already defined, it makes our code easy to understand and debug. It leads to faster development and new members of team understand it easily.

Java Design Patterns are divided into three categories –

creational, structural, and behavioral design patterns.

© JOURNALDEV.COM PAGE 4 OF 132

---------------------------------------------------------------

Creational Design Patterns

Creational design patterns provide solution to instantiate an object in the best possible way for specific situations.

The basic form of object creation could result in design problems or add unwanted complexity to the design. Creational design patterns solve this problem by controlling the object creation by different ways.

There are five creational design patterns that we will discuss in this eBook.

1. Singleton Pattern 2. Factory Pattern 3. Abstract Factory Pattern 4. Builder Pattern 5. Prototype Pattern

All these patterns solve specific problems with object creation, so you should understand and use them when needed.

© JOURNALDEV.COM PAGE 5 OF 132

---------------------------------------------------------------

1. Singleton Pattern

Singleton is one of the Gangs of Four Design patterns and comes in the Creational Design Pattern category. From the definition, it seems to be a very simple design pattern but when it comes to implementation, it comes with a lot of implementation concerns. The implementation of Singleton pattern has always been a controversial topic among developers. Here we will learn about Singleton design pattern principles, different ways to implement Singleton and some of the best practices for its usage.

Singleton pattern restricts the instantiation of a class and ensures that only one instance of the class exists in the java virtual machine. The singleton class must provide a global access point to get the instance of the class. Singleton pattern is used for logging, driver objects, caching and thread pool. Singleton design pattern is also used in other design patterns like Abstract Factory, Builder, Prototype, Facade etc. Singleton design pattern is used in core java classes also, for example

...

Descargar como  txt (151.5 Kb)   pdf (256.7 Kb)   docx (118.1 Kb)  
Leer 67 páginas más »
Disponible sólo en Essays.club