Skip to content

Commit 8220212

Browse files
committed
Polishing.
1 parent 02497b1 commit 8220212

File tree

25 files changed

+1230
-1457
lines changed

25 files changed

+1230
-1457
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

.vscode/c_cpp_properties.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Mac",
5+
"includePath": [
6+
"${workspaceFolder}/**"
7+
],
8+
"defines": [],
9+
"macFrameworkPath": [
10+
"/System/Library/Frameworks",
11+
"/Library/Frameworks"
12+
],
13+
"compilerPath": "/usr/bin/g++",
14+
"cStandard": "c11",
15+
"intelliSenseMode": "clang-x64",
16+
"compilerArgs": [],
17+
"cppStandard": "c++11"
18+
}
19+
],
20+
"version": 4
21+
}

.vscode/launch.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "g++",
6+
"type": "cppdbg",
7+
"request": "launch",
8+
"program": "${workspaceFolder}/bin/${fileBasenameNoExtension}",
9+
"args": ["-std=c++11"],
10+
"stopAtEntry": false,
11+
"cwd": "${workspaceFolder}",
12+
"environment": [],
13+
"externalConsole": false,
14+
"MIMode": "lldb",
15+
"preLaunchTask": "g++ build active file"
16+
}
17+
]
18+
}

.vscode/tasks.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "shell",
6+
"label": "g++ build active file",
7+
"command": "/usr/bin/g++",
8+
"args": [
9+
"-g",
10+
"-std=c++11",
11+
"${file}",
12+
"-o",
13+
"${workspaceFolder}/bin/${fileBasenameNoExtension}"
14+
],
15+
"options": {
16+
"cwd": "/usr/bin"
17+
}
18+
}
19+
]
20+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ For code execution in VSCode you will need to set up your task first. An example
3333
]
3434
}
3535
```
36-
Then you just need to start the executable.In case you have some doubts here you have an useful [tutorial] using vscode.
36+
Then you just need to start the executable. In case you have some doubts here you have an useful [tutorial] using vscode.
3737

3838
## Contributor's Guide
3939

bin/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

src/AbstractFactory/Conceptual/main.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class AbstractProductA {
2424
public:
25-
virtual ~AbstractProductA() {};
25+
virtual ~AbstractProductA(){};
2626
virtual std::string UsefulFunctionA() const = 0;
2727
};
2828

@@ -60,7 +60,7 @@ class AbstractProductB {
6060
* RU: Продукт B способен работать самостоятельно...
6161
*/
6262
public:
63-
virtual ~AbstractProductB() {};
63+
virtual ~AbstractProductB(){};
6464
virtual std::string UsefulFunctionB() const = 0;
6565
/**
6666
* EN: ...but it also can collaborate with the ProductA.

src/Adapter/Conceptual/MultipleInheritance/main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
#include <algorithm>
12
#include <iostream>
23
#include <string>
3-
#include <algorithm>
44

55
/**
66
* EN: Adapter Design Pattern

src/Adapter/Conceptual/Normal/main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
#include <algorithm>
12
#include <iostream>
23
#include <string>
3-
#include <algorithm>
44

55
/**
66
* EN: Adapter Design Pattern

src/Bridge/Conceptual/main.cc

Lines changed: 52 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
* Aa1 Aa2 Ab1 Ab2
2727
*/
2828

29-
3029
/**
3130
* EN: The Implementation defines the interface for all implementation classes.
3231
* It doesn't have to match the Abstraction's interface. In fact, the two
@@ -41,36 +40,30 @@
4140
* определяет операции более высокого уровня, основанные на этих примитивах.
4241
*/
4342

44-
class Implementation
45-
{
46-
public:
47-
virtual ~Implementation(){}
48-
virtual std::string OperationImplementation() const =0 ;
43+
class Implementation {
44+
public:
45+
virtual ~Implementation() {}
46+
virtual std::string OperationImplementation() const = 0;
4947
};
5048

51-
5249
/**
5350
* EN: Each Concrete Implementation corresponds to a specific platform and
5451
* implements the Implementation interface using that platform's API.
5552
*
5653
* RU: Каждая Конкретная Реализация соответствует определённой платформе и
5754
* реализует интерфейс Реализации с использованием API этой платформы.
5855
*/
59-
class ConcreteImplementationA: public Implementation
60-
{
61-
public:
62-
std::string OperationImplementation()const override
63-
{
64-
return "ConcreteImplementationA: Here's the result on the platform A.\n";
65-
}
56+
class ConcreteImplementationA : public Implementation {
57+
public:
58+
std::string OperationImplementation() const override {
59+
return "ConcreteImplementationA: Here's the result on the platform A.\n";
60+
}
6661
};
67-
class ConcreteImplementationB: public Implementation
68-
{
69-
public:
70-
std::string OperationImplementation()const override
71-
{
72-
return "ConcreteImplementationB: Here's the result on the platform B.\n";
73-
}
62+
class ConcreteImplementationB : public Implementation {
63+
public:
64+
std::string OperationImplementation() const override {
65+
return "ConcreteImplementationB: Here's the result on the platform B.\n";
66+
}
7467
};
7568

7669
/**
@@ -83,48 +76,41 @@ class ConcreteImplementationB: public Implementation
8376
* ему всю настоящую работу.
8477
*/
8578

86-
class Abstraction{
87-
/**
79+
class Abstraction {
80+
/**
8881
* @var Implementation
8982
*/
90-
protected:
91-
Implementation* implementation_;
92-
93-
public:
83+
protected:
84+
Implementation* implementation_;
9485

95-
Abstraction(Implementation* implementation):implementation_(implementation){
96-
}
97-
98-
virtual ~Abstraction(){
86+
public:
87+
Abstraction(Implementation* implementation) : implementation_(implementation) {
88+
}
9989

100-
}
90+
virtual ~Abstraction() {
91+
}
10192

102-
virtual std::string Operation() const{
103-
return "Abstraction: Base operation with:\n" +
104-
this->implementation_->OperationImplementation();
105-
}
93+
virtual std::string Operation() const {
94+
return "Abstraction: Base operation with:\n" +
95+
this->implementation_->OperationImplementation();
96+
}
10697
};
10798
/**
10899
* EN: You can extend the Abstraction without changing the Implementation
109100
* classes.
110101
*
111102
* RU: Можно расширить Абстракцию без изменения классов Реализации.
112103
*/
113-
class ExtendedAbstraction : public Abstraction
114-
{
115-
public:
116-
117-
ExtendedAbstraction(Implementation* implementation): Abstraction(implementation){
118-
119-
}
120-
std::string Operation() const override
121-
{
122-
return "ExtendedAbstraction: Extended operation with:\n" +
123-
this->implementation_->OperationImplementation();
124-
}
104+
class ExtendedAbstraction : public Abstraction {
105+
public:
106+
ExtendedAbstraction(Implementation* implementation) : Abstraction(implementation) {
107+
}
108+
std::string Operation() const override {
109+
return "ExtendedAbstraction: Extended operation with:\n" +
110+
this->implementation_->OperationImplementation();
111+
}
125112
};
126113

127-
128114
/**
129115
* EN: Except for the initialization phase, where an Abstraction object gets
130116
* linked with a specific Implementation object, the client code should only
@@ -136,11 +122,10 @@ class ExtendedAbstraction : public Abstraction
136122
* класса Абстракции. Таким образом, клиентский код может поддерживать любую
137123
* комбинацию абстракции и реализации.
138124
*/
139-
void ClientCode(const Abstraction& abstraction)
140-
{
141-
// ...
142-
std::cout << abstraction.Operation();
143-
// ...
125+
void ClientCode(const Abstraction& abstraction) {
126+
// ...
127+
std::cout << abstraction.Operation();
128+
// ...
144129
}
145130
/**
146131
* EN: The client code should be able to work with any pre-configured
@@ -150,22 +135,20 @@ void ClientCode(const Abstraction& abstraction)
150135
* комбинацией абстракции и реализации.
151136
*/
152137

153-
int main(){
154-
155-
Implementation* implementation = new ConcreteImplementationA;
156-
Abstraction* abstraction = new Abstraction(implementation);
157-
ClientCode(*abstraction);
158-
std::cout << std::endl;
159-
delete implementation;
160-
delete abstraction;
138+
int main() {
139+
Implementation* implementation = new ConcreteImplementationA;
140+
Abstraction* abstraction = new Abstraction(implementation);
141+
ClientCode(*abstraction);
142+
std::cout << std::endl;
143+
delete implementation;
144+
delete abstraction;
161145

162-
implementation = new ConcreteImplementationB;
163-
abstraction = new ExtendedAbstraction(implementation);
164-
ClientCode(*abstraction);
146+
implementation = new ConcreteImplementationB;
147+
abstraction = new ExtendedAbstraction(implementation);
148+
ClientCode(*abstraction);
165149

166-
delete implementation;
167-
delete abstraction;
150+
delete implementation;
151+
delete abstraction;
168152

169-
return 0;
153+
return 0;
170154
}
171-

0 commit comments

Comments
 (0)