0% found this document useful (0 votes)
21 views5 pages

9th Oose RAJI

This document discusses several design patterns that can be used to improve the reusability and maintainability of a software system for credit card processing, including the Strategy, Factory Method, Decorator, Observer, Command, Facade, and Singleton patterns. For each pattern, the document provides a definition, examples of how it could be used for credit card processing, and descriptions of related elements and uses.

Uploaded by

rajaprasath560
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views5 pages

9th Oose RAJI

This document discusses several design patterns that can be used to improve the reusability and maintainability of a software system for credit card processing, including the Strategy, Factory Method, Decorator, Observer, Command, Facade, and Singleton patterns. For each pattern, the document provides a definition, examples of how it could be used for credit card processing, and descriptions of related elements and uses.

Uploaded by

rajaprasath560
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

RAJAPRASATH U REG NO : 622421104036

To improve the reusability and maintainability of your software system for credit card processing, you can
apply several design patterns.

 Strategy Pattern.
 Factory Method Pattern.
 Decorator Pattern.
 Observer Pattern.
 Command Pattern.
 Facade Pattern.
 Singleton Pattern.

Strategy Pattern:

 Use this pattern to define a family of algorithms, encapsulate each one, and make them
interchangeable. For credit card processing, you could have different strategies for different types of
cards or processing methods.
 The Strategy pattern lets you isolate the code, internal data, and dependencies of various algorithms
from the rest of the code. Various clients get a simple interface to execute the algorithms and switch
them at runtime.
 A strategy pattern is a behavioral design pattern that allows the behavior of an object to be selected at
runtime.

Elements of Strategy Pattern :

 Vision.
 Mission.
 SWOT analysis.
 core values.
 Goals.
 Objectives.
 action plans.

Levels of Strategy Pattern :

 Corporate level strategy is a level answers the foundational question of what you want to achieve.
 Business unit level strategy is a level focuses on how you're going to compete.
 Market level strategy is a strategy level focuses on how you're going to grow.

purpose of strategy pattern :

 the strategy pattern is a behavioral software design pattern that enables selecting an algorithm at
runtime.
 Strategy allows you to create a family of algorithms, encapsulate each one of them and make them
interchangeable, allowing the algorithm to vary independently of the clients that use it and making
your code easier to maintain.
 Clarity and structure: Patterns provide a clear and structured way of organizing information, making
it easier to understand and use.
RAJAPRASATH U REG NO : 622421104036

Factory Method Pattern :

 Use this pattern to define an interface for creating an object, but let subclasses decide which class to
instantiate. This can be useful for creating different types of credit card processors based on the
input.
 The Factory Method pattern defines an interface for creating objects, but it allows subclasses to
decide which class to instantiate.
 Factory Method Pattern allows the sub-classes to choose the type of objects to create. It promotes the
loose-coupling by eliminating the need to bind application-specific classes into the code.

Types of Factory Design Pattern :

 Simple factory.
 Factory method.
 Abstract factory

Uses of Factory Design Pattern :

 Factory Method Pattern allows the sub-classes to choose the type of objects to create.
 It are reusable in multiple projects.
 It provide the solutions that help to define the system architecture.
 It capture the software engineering experiences.
 It provide transparency to the design of an application

Decorator Pattern :

 Use this pattern to dynamically add responsibilities to objects. For example, you could use it to add
additional processing steps to the credit card processing flow.
 Decorators are design patterns or functions that define how Angular features work.
 A wrapper is an object that can be linked with some target object. The wrapper contains the same set
of methods as the target and delegates to it all requests it receives.
 decorators to add additional functionality to existing functions.
 a design pattern that is used to separate modification or decoration of a class without modifying the
original source code.

Types of Decoder Pattern :

 binary decoders.
 priority decoders.
 BCD (Binary-Coded Decimal) decoders.
 multiplexers acting as decoders.

Uses of Decoder Pattern :

 One of the most important functions of a decoder is to convert a digital signal into an analogue
signal.
 It allows kids to figure out most words they've heard but have never seen in print, as well as sound
out words they're not familiar.
 It allows us to select one output among the many based on the input code.
RAJAPRASATH U REG NO : 622421104036

Observer Pattern :

 Use this pattern to define a one-to-many dependency between objects so that when one object
changes state, all its dependents are notified and updated automatically. This could be useful for
updating the state of the system based on changes in the credit card processing flow.
 Observer is a behavioral design pattern. It specifies communication between objects: observable and
observers.
 the Observer pattern when changes to the state of one object may require changing other objects, and
the actual set of objects is unknown beforehand or changes dynamically.

Types of Observer Pattern:

 Shape Pattern.
 Letter Pattern.
 Number Pattern.

Elements of Observer Pattern :

There are Three Types of Elements in it they are ...


 observers : an array of observers that will get notified whenever a specific event occurs.
 subscribe() : a method in order to add observers to the observers list.
 unsubscribe() : a method in order to remove observers from the observers list.

Uses of Observer Pattern :

 It lets you define the boundaries between various modules, which improves the maintainability and
reusability of your software.
 This method will execute every time a change happens within the object we're observing.
 Use the Observer pattern when there is a one-to-many relationship between objects, and changes in
one object should notify multiple dependent objects.
 New observers can be added or existing ones removed without modifying the subject.

Command Pattern :

 Use this pattern to encapsulate a request as an object, thereby parameterizing clients with queues,
requests, and operations. This can be useful for implementing undo functionality or for queuing
credit card processing requests.
 Command is a behavioral design pattern that turns a request into a stand-alone object that contains
all information about the request.
 a behavioral design pattern in which the request is made to the commandInvoker, who then passes
the request to the encapsulated command object.

Elements of Command Pattern :

 command.
 Receiver.
 Invoker.
 client.
RAJAPRASATH U REG NO : 622421104036

Uses of Command Pattern :

 In many areas of the decorative arts, from ceramics and textiles to wallpaper.
 It usually made of paper, and are sometimes made of sturdier materials like paperboard or
cardboard.
 You can easily adjust your patterns when there is a mistake. So with pattern-drafting, mistakes are
mitigated.
 Because of 1 above, it serves your fabric from wastage.
 Patterns come with instructions.
 Patterns can be easily modified to other designs.
 Patterns can be tested before they are sewn.
 Patterns are durable.

Facade Pattern :

 Use this pattern to provide a unified interface to a set of interfaces in a subsystem. This can simplify
the use of complex subsystems, such as a credit card processing system, by providing a simpler
interface for clients.
 Facade is a structural design pattern that provides a simplified interface to a library, a framework,
or any other complex set of classes.
 The Facade design pattern simplifies the interface to a complex system because it is usually
composed of all the classes which make up the subsystems of the complex system.
 A Facade shields the user from the complex details of the system and provides them with a
simplified view of it which is easy to use .

Elements of Facade Pattern :

 the Facade.
 the Subsystem classes.

Uses of Facade Pattern :

 a complex Subsystem that consists of multiple classes or components.


 Facade systems have protective properties against both the building and the interior of the building
against the radiation and UV rays.
 Provides a clear and concise interface to a complex system, making it easier to understand and use.
 Decouples clients from the underlying system, making them less dependent on its internal structure.
 Encapsulates the complex interactions within a subsystem, protecting clients from changes in its
implementation.
 Easier to change or extend the underlying system without affecting clients, as long as the facade
interface remains consistent.

Singleton Pattern :

 Singleton Pattern is probably the most widely used design pattern. It is a simple pattern, easy to
understand and to use.
 Use this pattern to ensure a class has only one instance and provide a global point of access to it.
This can be useful for managing resources that need to be shared across the system, such as a
connection pool for processing credit card transactions.
RAJAPRASATH U REG NO : 622421104036

 The Singleton method or Singleton Design pattern is one of the simplest design patterns. It ensures a
class only has one instance, and provides a global point of access to it.

Types of Singleton Pattern :


 Early initialization.
 Lazy initialization.

Uses of SingletonPattern :
 a Singleton can be used to maintain a single database connection throughout the application .
 a Singleton configuration manager can provide a single point of access to these settings.
 Singleton can help manage the state and actions of the UI, providing a single point of control.
 a Singleton can be used to manage and control access to hardware devices to avoid conflicts .
 a Singleton printing service can coordinate and manage print jobs, ensuring efficient use of printing
resources.

Advantages of Singleton Pattern:

 the Singleton pattern ensures that there is only one instance with a unique name.
 The Singleton pattern supports both eager initialization and lazy initialization providing flexibility
based on the use case.
 Properly implemented Singleton patterns can provide thread safety, ensuring that the instance is
created atomically and that multiple threads do not inadvertently create duplicate instances .
 In applications where resource consumption is critical, the Singleton pattern can contribute to a
reduced memory footprint by ensuring that there is only one instance of the class.

Disadvantages of Singleton Pattern :

 a Singleton, as the state of the Singleton may affect the outcome of tests.
 the Singleton instance. If multiple threads attempt to create the Singleton simultaneously, it can
result in race conditions.
 The Singleton pattern can make code less extensible. If you later decide that you need multiple
instances of the class or want to change the instantiation logic, it may require significant refactoring .
 The Singleton pattern creates a global dependency, making it harder to replace the Singleton with an
alternative implementation or to use dependency injection for providing instances .
 a Singleton requires additional care and may not follow standard inheritance patterns.

You might also like