code refactoring: fix memory leaks, code style, etc.

This commit is contained in:
Jakub Vojvoda
2019-01-31 19:57:40 +01:00
parent a8681552c4
commit a0b0ea4f8e
24 changed files with 960 additions and 566 deletions

View File

@@ -15,27 +15,33 @@
* implement more complex subsystem functionality
* and have no knowledge of the facade
*/
class SubsystemA {
class SubsystemA
{
public:
void suboperation() {
void suboperation()
{
std::cout << "Subsystem A method" << std::endl;
// ...
}
// ...
};
class SubsystemB {
class SubsystemB
{
public:
void suboperation() {
void suboperation()
{
std::cout << "Subsystem B method" << std::endl;
// ...
}
// ...
};
class SubsystemC {
class SubsystemC
{
public:
void suboperation() {
void suboperation()
{
std::cout << "Subsystem C method" << std::endl;
// ...
}
@@ -47,24 +53,25 @@ public:
* delegates client requests to appropriate subsystem object
* and unified interface that is easier to use
*/
class Facade {
class Facade
{
public:
Facade() :
subsystemA(), subsystemB(), subsystemC() {}
void operation1() {
Facade() : subsystemA(), subsystemB(), subsystemC() {}
void operation1()
{
subsystemA->suboperation();
subsystemB->suboperation();
// ...
}
void operation2() {
void operation2()
{
subsystemC->suboperation();
// ...
}
// ...
private:
SubsystemA *subsystemA;
SubsystemB *subsystemB;
@@ -76,8 +83,10 @@ private:
int main()
{
Facade *facade = new Facade();
facade->operation1();
facade->operation2();
delete facade;
return 0;
}