├── .gitignore
├── DesignPatterns
├── Adaptor Pattern
│ ├── Readme.md
│ ├── code
│ │ ├── driver.cpp
│ │ ├── electricAdapter.h
│ │ ├── threePin.h
│ │ └── twoPinSocket.h
│ └── diagram
│ │ ├── adaptor.png
│ │ └── socket.png
├── Decorator Pattern
│ ├── Readme.md
│ ├── code
│ │ ├── coffee.h
│ │ ├── coffeeCalculator.cpp
│ │ ├── coffeeCalculator.exe
│ │ ├── decorator.exe
│ │ └── decorator.h
│ └── diagrams
│ │ ├── Inherit.png
│ │ ├── decorator.png
│ │ ├── extended.png
│ │ └── loosely.png
├── Singleton
│ ├── Readme.md
│ ├── code
│ │ └── Singleton.js
│ └── diagram
│ │ └── Fridge.png
└── StrategyPattern
│ ├── README.md
│ ├── code
│ ├── Duck.h
│ ├── Interface
│ │ ├── FlyBehavior.h
│ │ └── QuackBehavior.h
│ └── driver.cpp
│ └── diagrams
│ ├── duck-class.png
│ └── strategy.png
├── LICENSE
├── README.md
├── code-of-conduct.md
└── contributing.md
/.gitignore:
--------------------------------------------------------------------------------
1 | **node_modules/
2 | **.vscode/
3 |
--------------------------------------------------------------------------------
/DesignPatterns/Adaptor Pattern/Readme.md:
--------------------------------------------------------------------------------
1 | ## Adaptor Pattern
2 | Adaptor pattern is act as a Mediatory between two interfaces. It makes the interface of one class compatible with another interface.
3 |
4 | ### Explanation ⚡
5 | To simplify above mention detail let's consider we have a [2 pin socket](https://clipsal.com.pk/image/cache/catalog/N_Products/E8415U-500x515-500x515.jpg) and we want to put a [3 pin plug](https://www.helptechco.com/files/3-Pin-Plug.jpg) in it, can we do that? OfCourse we can't, but we can use a 2 pin [electric adaptor](https://static-01.daraz.pk/p/8f4d517efff9f9879d361ff2399480b5.jpg) to make it work as shown in diagram.
6 |
7 |
8 |
9 |
10 | The adaptor act as a middle man to make two different mediums feasible for for each other. If we talk about this in terms of softwares. The adapter pattern has following specifications:
11 |
12 | - __Target Interface:__ This is the desired interface class which will be used by the clients.
13 |
14 | - __Adapter class:__ This class is a wrapper class which implements the desired target interface and modifies the specific request
15 | available from the Adaptee class.
16 |
17 | - __Adaptee class:__ This is the class which is used by the Adapter class to reuse the existing functionality and modify them for desired use.
18 |
19 | - __Client:__ This program that will interact with the target interface.
20 |
21 | The above example in UML format:
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/DesignPatterns/Adaptor Pattern/code/driver.cpp:
--------------------------------------------------------------------------------
1 | #include "electricAdapter.h"
2 |
3 | int main()
4 | {
5 | ThreePin *threePin = new electricAdaptor();
6 | threePin->plugIn();
7 | return 0;
8 | }
--------------------------------------------------------------------------------
/DesignPatterns/Adaptor Pattern/code/electricAdapter.h:
--------------------------------------------------------------------------------
1 | #include "threePin.h"
2 | #include "twoPinSocket.h"
3 |
4 | class electricAdaptor : public ThreePin
5 | {
6 | TwoPinSocket twoPinSocket;
7 |
8 | public:
9 | void plugIn()
10 | {
11 | twoPinSocket.switchPlugIn();
12 | }
13 | };
--------------------------------------------------------------------------------
/DesignPatterns/Adaptor Pattern/code/threePin.h:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | class ThreePin
5 | {
6 | public:
7 | virtual void plugIn() = 0;
8 | };
--------------------------------------------------------------------------------
/DesignPatterns/Adaptor Pattern/code/twoPinSocket.h:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | class TwoPinSocket
5 | {
6 | public:
7 | void switchPlugIn()
8 | {
9 | cout << "\nI can plug in a 3 pin plug with the help of an adaptor :)\n\n";
10 | }
11 | };
12 |
--------------------------------------------------------------------------------
/DesignPatterns/Adaptor Pattern/diagram/adaptor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meerhamzadev/Patterns/fd62753c40a1e3a8be7a82fea5b7ad227479a24e/DesignPatterns/Adaptor Pattern/diagram/adaptor.png
--------------------------------------------------------------------------------
/DesignPatterns/Adaptor Pattern/diagram/socket.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meerhamzadev/Patterns/fd62753c40a1e3a8be7a82fea5b7ad227479a24e/DesignPatterns/Adaptor Pattern/diagram/socket.png
--------------------------------------------------------------------------------
/DesignPatterns/Decorator Pattern/Readme.md:
--------------------------------------------------------------------------------
1 | ## Decorator Pattern
2 | Decorator patterns are a design pattern that allows to dynamically add a behavior or a functionality to an object without impacting the behavior of the existing objects.
3 |
4 | ### Explanation ⚡
5 |
6 | To understand the decorator pattern let's suppose we are designing a coffee order system and a user can order 4 type of coffees _House Blend_, _Cappuccino_, _Espresso_ and _Latte_ and we can add different condiments like _Soy_, _Milk_, _Whip_, _Mocha_ with each of this type of coffee. As it's an order system it will calculate the total price of the order with the condiments added.
7 |
8 | #### Why inheritance is not a good option?
9 | It seems the inheritance might be a good way to implement this design there would be a coffee base class and types are derived from it, but it's not. The problem is that the order system will be dependent on the coffee type and the condiments and there are number of possible ways to order a coffee e.g someone order a house blend with soy and milk added or may be with double soy and mocha. So inheritance make it quite hard to deal with such number of combinations, The design would become a mess. If we take a visual look, this design might look like this(keeping in count only one possibility).
10 |
11 |
12 |
13 |
14 |
15 | As we can see inheritance is not a good option as it would be a mess to deal with all the possible combinations. We need something more flexible and easy to extendable design. Loosely talking something like the diagram below, if you notice its very flexible and we can easily add multiple condiments.
16 |
17 |
18 |
19 |
20 |
21 | As from the definition of the decorator pattern it is used to dynamically add functionalities or behavior to an object without affecting the previous objects. In our case, condiments would be the functionality(decorators) which we want to add dynamically to calculated the final cost without affecting the previous calculated cost of the coffee. The diagram representation of this would be like this.
22 |
23 |
24 |
25 |
26 | Now we can add number of combinations with ease. The extended version of the above diagram would be like this
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/DesignPatterns/Decorator Pattern/code/coffee.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | class Coffee
6 | {
7 | public:
8 | string description;
9 |
10 | string getDescription()
11 | {
12 | return description;
13 | }
14 | virtual double cost() = 0;
15 | };
16 |
17 | class HouseBlend : public Coffee
18 | {
19 | public:
20 | HouseBlend()
21 | {
22 | description = "House Blend Coffee";
23 | }
24 | double cost()
25 | {
26 | return 1;
27 | }
28 | };
29 |
30 | class Latte : public Coffee
31 | {
32 | public:
33 | Latte()
34 | {
35 | description = "Latte Coffee";
36 | }
37 | double cost()
38 | {
39 | return 2.3;
40 | }
41 | };
42 |
--------------------------------------------------------------------------------
/DesignPatterns/Decorator Pattern/code/coffeeCalculator.cpp:
--------------------------------------------------------------------------------
1 | #include "decorator.h"
2 |
3 | int main()
4 | {
5 | Coffee *houseBlend = new HouseBlend();
6 | houseBlend = new Milk(houseBlend);
7 | houseBlend = new Whip(houseBlend);
8 | cout << "The cost of the coffee is" << houseBlend->cost() << endl;
9 | return 0;
10 | }
11 |
--------------------------------------------------------------------------------
/DesignPatterns/Decorator Pattern/code/coffeeCalculator.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meerhamzadev/Patterns/fd62753c40a1e3a8be7a82fea5b7ad227479a24e/DesignPatterns/Decorator Pattern/code/coffeeCalculator.exe
--------------------------------------------------------------------------------
/DesignPatterns/Decorator Pattern/code/decorator.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meerhamzadev/Patterns/fd62753c40a1e3a8be7a82fea5b7ad227479a24e/DesignPatterns/Decorator Pattern/code/decorator.exe
--------------------------------------------------------------------------------
/DesignPatterns/Decorator Pattern/code/decorator.h:
--------------------------------------------------------------------------------
1 | #include "coffee.h"
2 |
3 | class CondimentsDecorator : public Coffee
4 | {
5 | public:
6 | string getDescription();
7 | };
8 |
9 | class Whip : public CondimentsDecorator
10 | {
11 | Coffee *coffee;
12 |
13 | public:
14 | Whip(Coffee *coffee)
15 | {
16 | this->coffee = coffee;
17 | }
18 | string getDescription()
19 | {
20 | return coffee->getDescription() + ", Whip";
21 | }
22 | double cost()
23 | {
24 | return .10 + coffee->cost();
25 | }
26 | };
27 |
28 | class Milk : public CondimentsDecorator
29 | {
30 | Coffee *coffee;
31 |
32 | public:
33 | Milk(Coffee *coffee)
34 | {
35 | this->coffee = coffee;
36 | }
37 | string getDescription()
38 | {
39 |
40 | return coffee->getDescription() + ", Milk";
41 | }
42 | double cost()
43 | {
44 | return .5 + coffee->cost();
45 | }
46 | };
47 |
48 | class Soy : public CondimentsDecorator
49 | {
50 | Coffee *coffee;
51 |
52 | public:
53 | Soy(Coffee *coffee)
54 | {
55 | this->coffee = coffee;
56 | }
57 | string getDescription()
58 | {
59 | return coffee->getDescription() + ", Soy";
60 | }
61 | double cost()
62 | {
63 | return .15 + coffee->cost();
64 | }
65 | };
66 |
67 | class Mocha : public CondimentsDecorator
68 | {
69 | Coffee *coffee;
70 |
71 | public:
72 | Mocha(Coffee *coffee)
73 | {
74 | this->coffee = coffee;
75 | }
76 | string getDescription()
77 | {
78 | return coffee->getDescription() + ", Mocha";
79 | }
80 | double cost()
81 | {
82 | return .25 + coffee->cost();
83 | }
84 | };
--------------------------------------------------------------------------------
/DesignPatterns/Decorator Pattern/diagrams/Inherit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meerhamzadev/Patterns/fd62753c40a1e3a8be7a82fea5b7ad227479a24e/DesignPatterns/Decorator Pattern/diagrams/Inherit.png
--------------------------------------------------------------------------------
/DesignPatterns/Decorator Pattern/diagrams/decorator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meerhamzadev/Patterns/fd62753c40a1e3a8be7a82fea5b7ad227479a24e/DesignPatterns/Decorator Pattern/diagrams/decorator.png
--------------------------------------------------------------------------------
/DesignPatterns/Decorator Pattern/diagrams/extended.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meerhamzadev/Patterns/fd62753c40a1e3a8be7a82fea5b7ad227479a24e/DesignPatterns/Decorator Pattern/diagrams/extended.png
--------------------------------------------------------------------------------
/DesignPatterns/Decorator Pattern/diagrams/loosely.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meerhamzadev/Patterns/fd62753c40a1e3a8be7a82fea5b7ad227479a24e/DesignPatterns/Decorator Pattern/diagrams/loosely.png
--------------------------------------------------------------------------------
/DesignPatterns/Singleton/Readme.md:
--------------------------------------------------------------------------------
1 | ## Singleton Pattern
2 | Singleton is a design pattern that lets you ensure that a class has only one instance, while providing a global access point to this instance. This is useful when exactly one object is needed to coordinate actions across the system.
3 |
4 | ### Explanation ⚡
5 | To simplify this pattern let's consider an example of a fridge. In most cases, a house has only one fridge but that fridge is used by all the members of the house. According to current scenario the fridge is the single instance that is global to all the users/components. So anyone can access it.
6 |
7 |
8 |
9 |
10 |
11 | If you take a close look you might notice that all the users/components uses that single instance so, it may cause coupling and might lead to some problems. So, we always try to avoid overuse of singleton pattern and only use it in the cases where it is really necessary.
12 |
--------------------------------------------------------------------------------
/DesignPatterns/Singleton/code/Singleton.js:
--------------------------------------------------------------------------------
1 | // we are using js for this example cuz it is the easiest way to demonstrate the singleton pattern
2 |
3 | class Singleton {
4 | constructor() {
5 | if (Singleton.instance == null) {
6 | Singleton.instance = this;
7 | }
8 | return Singleton.instance;
9 | }
10 | logPersonMessage(personNumber) {
11 | console.log(`${personNumber} is using the fridge`);
12 | }
13 | }
14 |
15 | const singleton = new Singleton();
16 | Object.freeze(singleton);
17 |
18 | // first user
19 | function user1() {
20 | singleton.logPersonMessage("I'm the first person and I'm ");
21 | }
22 |
23 | // second user
24 | function user2() {
25 | singleton.logPersonMessage("I'm the second person and I'm ");
26 | }
27 |
28 | //main program
29 |
30 | user1();
31 | user2();
--------------------------------------------------------------------------------
/DesignPatterns/Singleton/diagram/Fridge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meerhamzadev/Patterns/fd62753c40a1e3a8be7a82fea5b7ad227479a24e/DesignPatterns/Singleton/diagram/Fridge.png
--------------------------------------------------------------------------------
/DesignPatterns/StrategyPattern/README.md:
--------------------------------------------------------------------------------
1 | ## Strategy Pattern
2 |
3 | The Strategy Pattern is a design pattern that defines a family of algorithms by encapsulating those components that varies time to time in separate classes that makes them interchangeable and extendible without modifying the client that uses it.
4 |
5 | ### Explanation
6 |
7 | To understand the Strategy Pattern in detail, let's look at an example:
8 |
9 | Consider we are designing a duck simulator where user can simulate different type of ducks. If we go on regular basis, we would create a parent class, Duck that has 4 methods quack(), fly(), swim() and, appearance() and then derives different types of duck classes from it, as the appearance is different for different ducks we will make appearance an abstract method, so it can be override in child classes, as shown in diagram.
10 |
11 |
12 |
13 |
14 |
15 | Everything seems perfect, our design seems reusable. But if we take a closer look we can see a rubber duck cannot fly and quack as well, but it squeak. So, to overcome this problem we will override both quack() and fly() method in rubber duck class. Ok great, but what if we want to add another type of duck like [decoy duck](https://en.wikipedia.org/wiki/Duck_decoy_(model)), which cannot quack(as it's a wooden duck) and fly? We have to override them. If you notice, this approach has 2 drawbacks:
16 | - It effects the reusability.
17 | - It is not flexible, and hard to maintain and extend.
18 |
19 | So, How we overcome this problem? here's comes the strategy pattern. According to strategy pattern we encapsulate the varying component in a separate interface and then derive the expected behavior from it in the form of different classes. It enforce has-a relationship now as instead of simple inheritance it would use composition. Our existing class diagram would be like this now.
20 |
21 |
22 |
23 |
24 | Now we can easily add new type of duck without modifying the existing classes. We can also extend fly or quack behaviors easily. It ensures reusability, flexibility and maintainability. For a implementation insight, look at the code directory.
25 |
--------------------------------------------------------------------------------
/DesignPatterns/StrategyPattern/code/Duck.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include "interface/FlyBehavior.h"
3 | #include "interface/QuackBehavior.h"
4 | using namespace std;
5 |
6 | class Duck
7 | {
8 | public:
9 | FlyBehavior *flyBehavior;
10 | QuackBehavior *quackBehavior;
11 |
12 | void swim()
13 | {
14 | cout << "Duck is swimming" << endl;
15 | }
16 | virtual void appearance() = 0;
17 | };
18 |
19 | // Derived classes
20 | class mallardDuck : public Duck
21 | {
22 | public:
23 | void appearance()
24 | {
25 | cout << "I'm a Mallard duck" << endl;
26 | }
27 | };
28 |
29 | class redFaceDuck : public Duck
30 | {
31 | public:
32 | void appearance()
33 | {
34 | cout << "I'm a Red Face duck" << endl;
35 | }
36 | };
37 |
38 | class rubberDuck : public Duck
39 | {
40 | public:
41 | void appearance()
42 | {
43 | cout << "I'm a Rubber duck" << endl;
44 | }
45 | };
46 |
47 | class decoyDuck : public Duck
48 | {
49 | public:
50 | void appearance()
51 | {
52 | cout << "I'm a Decoy duck" << endl;
53 | }
54 | };
55 |
--------------------------------------------------------------------------------
/DesignPatterns/StrategyPattern/code/Interface/FlyBehavior.h:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | class FlyBehavior
5 | {
6 | public:
7 | virtual void fly() = 0;
8 | };
9 |
10 | class flyWithWings : public FlyBehavior
11 | {
12 | public:
13 | void fly()
14 | {
15 | cout << "I'm flying with wings" << endl;
16 | }
17 | };
18 |
19 | class noFly : public FlyBehavior
20 | {
21 | public:
22 | void fly()
23 | {
24 | cout << "I cannot fly :(" << endl;
25 | }
26 | };
--------------------------------------------------------------------------------
/DesignPatterns/StrategyPattern/code/Interface/QuackBehavior.h:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | class QuackBehavior
5 | {
6 | public:
7 | virtual void quack() = 0;
8 | };
9 |
10 | class Quack : public QuackBehavior
11 | {
12 | public:
13 | void quack()
14 | {
15 | cout << "Quack Quack" << endl;
16 | }
17 | };
18 |
19 | class Squeak : public QuackBehavior
20 | {
21 | public:
22 | void quack()
23 | {
24 | cout << "Squeak Squeak" << endl;
25 | }
26 | };
27 |
28 | class Silent : public QuackBehavior
29 | {
30 | public:
31 | void quack()
32 | {
33 | cout << "I can't speak" << endl;
34 | }
35 | };
--------------------------------------------------------------------------------
/DesignPatterns/StrategyPattern/code/driver.cpp:
--------------------------------------------------------------------------------
1 | #include "Duck.h"
2 |
3 | int main()
4 | {
5 | Duck *duck = new mallardDuck();
6 | duck->appearance();
7 | duck->swim();
8 | duck->flyBehavior = new flyWithWings();
9 | duck->flyBehavior->fly();
10 | duck->quackBehavior = new Quack();
11 | duck->quackBehavior->quack();
12 | delete duck;
13 | cout << endl;
14 |
15 | duck = new redFaceDuck();
16 | duck->appearance();
17 | duck->swim();
18 | duck->flyBehavior = new flyWithWings();
19 | duck->flyBehavior->fly();
20 | duck->quackBehavior = new Quack();
21 | duck->quackBehavior->quack();
22 | delete duck;
23 | cout << endl;
24 |
25 | duck = new rubberDuck();
26 | duck->appearance();
27 | duck->swim();
28 | duck->flyBehavior = new noFly();
29 | duck->flyBehavior->fly();
30 | duck->quackBehavior = new Squeak();
31 | duck->quackBehavior->quack();
32 | delete duck;
33 | cout << endl;
34 |
35 | duck = new decoyDuck();
36 | duck->appearance();
37 | duck->swim();
38 | duck->flyBehavior = new noFly();
39 | duck->flyBehavior->fly();
40 | duck->quackBehavior = new Silent();
41 | duck->quackBehavior->quack();
42 | delete duck;
43 | cout << endl;
44 | return 0;
45 | }
--------------------------------------------------------------------------------
/DesignPatterns/StrategyPattern/diagrams/duck-class.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meerhamzadev/Patterns/fd62753c40a1e3a8be7a82fea5b7ad227479a24e/DesignPatterns/StrategyPattern/diagrams/duck-class.png
--------------------------------------------------------------------------------
/DesignPatterns/StrategyPattern/diagrams/strategy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meerhamzadev/Patterns/fd62753c40a1e3a8be7a82fea5b7ad227479a24e/DesignPatterns/StrategyPattern/diagrams/strategy.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Meer Hamza
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | A one stop repository to learn different computer science/programming patterns⚡
4 |
5 |
6 |
7 | ## ⚠ Disclaimer
8 | I'm starting a learning series where I regularly or after 2/3 days, upload a new pattern.
9 | The structure of the content would be some diagrams and explanation with a simple example to make everything
10 | super clear and straightforward. I will also provide an implementation of these patterns for a clear understanding.
11 |
12 | #### Why should you learn these patterns🤔?
13 | It helps you to improve your software design and analytical thinking and would help you to develop and design software more effectively.
14 |
15 |
16 | ## 👨🏻💻 Contributing
17 | Make sure you read the [contributing guidelines](https://github.com/meerhamzadev/Patterns/blob/main/contributing.md) before opening a PR.
18 |
19 | ## 🔑 License & Conduct
20 |
21 | - MIT © [Meer Hamza](https://github.com/meerhamzadev)
22 | - [Code of Conduct](https://github.com/meerhamzadev/Patterns/blob/main/code-of-conduct.md)
23 |
24 | ## ⚡ AUTHOR
25 |
26 | 🙋🏻♂️ Yo! It's Meer, a junior year CS undergrad. Let's get connected
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/code-of-conduct.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | hamzababar37@gmail.com.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/contributing.md:
--------------------------------------------------------------------------------
1 | ## Contributing Guidelines
2 |
3 | 1. Open the issue first.
4 |
5 | 2. Fork the repository.
6 |
7 | 3. Create and switch to the new branch. New branch name convention must be like this yourUsername/newPattern, for instance, meerhamzadev/singleton-pattern
8 |
9 | 4. Commit the changes in your forked repository.
10 |
11 | 5. Make sure you use [Emoji-log](https://github.com/ahmadawais/Emoji-Log) in your commit
12 | messages.
13 |
14 | 6. Open a pull request & mention the issue number in the pull request for reference.
15 |
--------------------------------------------------------------------------------