-6

Currently I am making a console application. Is that right that the Main method of a .net console application is a facade? Is any console application entry method is a facade?

3
  • What makes you think that? Commented Feb 24, 2017 at 14:38
  • It appears to me that most entry points are like facades :they call different methods from different classes. For me the entry point appears like a Facade class method. Or am I thinking wrong? Commented Feb 24, 2017 at 14:49
  • 1
    No a facade pattern involves something like a wrapper that covers up another class doing some work. You need more information in your question to explain why you think that. Commented Feb 24, 2017 at 14:54

1 Answer 1

1

No, the point of a facade is to offer a (simplified) interface to a set of classes. It is a kind of abstraction layer. Now a main method and a facade do have the similarity that they use other objects. However, the interface of a facade is consumed by other objects. The main method doesn't really offer an interesting interface and is consumed only by the runtime, not by other objects.

The main method may decode command line arguments and translate these into method calls. For example, the git program offers a command line interface with many subcommands like git pull, git fetch, git merge. Here, the pull offers a simplified view onto the fetch and merge subcommands. As such, the git program in general and git pull in particular can be interpreted as a kind of facade.

But can a command line program be a facade in the sense of Object-Oriented Design Patterns? No. Launching a program with command line parameters is more like invoking a procedure, less like sending messages to an independently existing object. Therefore, this would be a purely procedural design, and would have no semblance of object-orientation. That is not bad, it's just something different.

As a general point, don't try to see design patterns in everything. At the heart of a good design, there are good design decisions and compromises, not clear patterns. Even when patterns are used consciously can they take on many different forms. Also, design patterns exist in order to achieve some goal. For the “classic” design patterns, the overarching goal is increasing flexibility and reusability of object-oriented software. Not every system shares these goals, and not every system uses object-oriented techniques. Using these patterns in a system with different goals is therefore not necessarily a good idea.

1
  • So the facade always tries to provide a simplified interface, but the main method not. Thank you for the answer. Commented Feb 24, 2017 at 15:19

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.