Questions tagged [facade]

The Facade pattern is one of the Gang of Four's structural design patterns.

The facade pattern is a software engineering design pattern commonly used with Object-oriented programming. The name is by analogy to an architectural facade.

It is one of the Gang of Four's structural , first published in Gamma et al.'s book "Design Patterns: Elements of Reusable Object-Oriented Software".

From Wikipedia: The Facade pattern provides a unified interface to a set of interfaces in a subsystem. It defines a higher-level interface that makes the subsystem easier to use.


References

392 questions
9
votes
3 answers

Differences between Facade Pattern and other patterns

I have a question about patterns. I really have problems with design patterns. Can you tell me the differences between Facade Pattern and Builder, Factory and Abstract Factory patterns?
aslı
  • 199
  • 1
  • 2
  • 7
9
votes
1 answer

Cannot redeclare ::shouldReceive() when testing Facade

According to the Laravel docs, I should be able to mock a facade via Object::shouldReceive(), but when I do it says I cannot redeclare the method. The view works correctly when I view it in my browser, I just need to figure out how to test this…
Ben
  • 60,438
  • 111
  • 314
  • 488
8
votes
4 answers

What are the advantages and disadvantages of the Session Façade Core J2EE Pattern?

What are the advantages and disadvantages of the Session Façade Core J2EE Pattern? What are the assumptions behind it? Are these assumptions valid in a particular environment?
hawkeye
  • 34,745
  • 30
  • 150
  • 304
8
votes
2 answers

Arr::get() vs data_get() in Laravel 5.7

With data_get() helper function, we can get value of a nested array using dot . notation as following: $my_arr = [ 'a' => ['lower' => 'aa', 'upper' => 'AAA',], 'b' => ['lower' => 'bbb', 'upper' => 'BBBBB',], ]; Thus, I can get lower a by…
O Connor
  • 4,236
  • 15
  • 50
  • 91
8
votes
4 answers

Best approach to Architect the integration of two separate databases?

I've ran into the following questions at work, and I don't have the experience or knowledge in order to answer them, I'm hoping that some of you wiser folk may be able to point me in the right direction, any answers will be greatly…
8
votes
6 answers

Best design pattern to use: adapter or facade

I can't decide on which pattern is best suited to the following problem. I have a client system who will be interacting with a separate subsystem. The subsystem is quite complicated and so I need an interface between the two to simplify the client…
David
  • 81
  • 1
  • 2
8
votes
2 answers

Facade pattern vs. SRP

In the classic Facade pattern, a single object usually provides a simplified interface to something more complex. As the Gang-of-Four put it (as close to "official" as it gets...): Facade (185) Provide a unified interface to a set of interfaces in…
8
votes
4 answers

Does the Facade pattern violate SRP?

SRP principal say: a class or module should have one, and only one, reason to change I have some Facade class as my service layer classes. e.g SaleService, that it provide some methods e.g SaveOrder(), CancelOrder(), CreateOrder(), GetAllOrders(),…
6
votes
3 answers

Python create own dict view of subset of dictionary

As the many questions on the topic here on SO attest, taking a slice of a dictionary is a pretty common task, with a fairly nice solution: {k:v for k,v in dict.viewitems() if some_test(k,v)} But that creates a new dictionary, with its own mappings.…
Marcin
  • 48,559
  • 18
  • 128
  • 201
6
votes
3 answers

Are there any existing Java caching facades?

I'm getting ready to start working on performance in an application which will eventually be running distributed, but currently is in [greenfield] development. I'd like to be able to introduce caching without either selecting or committing to a…
Matt Mills
  • 8,692
  • 6
  • 40
  • 64
6
votes
1 answer

Laravel constants in class Facades

I have a class called Awesome and have used the ServiceProvider and the Facade to register it to the app. Now I can use it as Awesome::Things(). I want to add constants to this class, so I tried
Kousha
  • 32,871
  • 51
  • 172
  • 296
6
votes
2 answers

How to create custom Facade in Laravel 4

Looked up a few tutorials on facades and laravel 4... tried some... not liked the way they work. For instance, they don't all provide a way of defining where to store the facade files and service providers... and i tried to step away from that and…
ied3vil
  • 964
  • 1
  • 7
  • 18
6
votes
4 answers

How to Str::shouldReceive? (mocking Illuminate\Support\Str)

I have a class that uses Str::random() which I would like to test. But when I use Str::shouldReceive('random') in my test, I get a BadMethodCallException saying the method shouldReceive does not exist. I also tried to mock the class directly and…
toonevdb
  • 329
  • 1
  • 13
6
votes
1 answer

When to use Facades and when to inject dependencies

I am currently building a web app in php using Laravel-4, however, I suspect that this question is applicable to other languages and frameworks as well. I have read about dependency injection and Facades and understand the necessary coding in each…
Ben Thompson
  • 4,743
  • 7
  • 35
  • 52
6
votes
3 answers

Use of Facade Pattern

How can I know that I need a facade Pattern at a point in my application development? How can I draw the line between Facade Pattern and Template Pattern? For example: In [this] article, we see that, int placeOrder(int CustomerID, List
user366312
  • 16,949
  • 65
  • 235
  • 452
1 2
3
26 27