Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I'm having some trouble understanding what a design pattern is and isn't, particularly with respect to version control systems like CVS and Git.

Is "push, pop, stack" a "design pattern"? If yes, is CVS the same design pattern?

...clients connect to the server in order to "check out" a complete copy of the project, work on this copy and then later "check in" their changes.

If yes to both, then are DVCSes like Git a different pattern? Which one?

If these aren't design patterns, why aren't they? What should they be called?

share|improve this question

closed as unclear what you're asking by ratchet freak, psr, GlenH7, MichaelT, gnat Sep 18 '14 at 3:46

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

Hi anon, I removed your new question: Stack Exchange is not a discussion board, so if you want to followup with a new problem based on the results of this one, please ask an entirely new question so as not to invalidate the answers on this one. –  user8 Oct 13 '11 at 0:44
@Mark Trapp, That's fine. I don't however agree with the reworking of the question. I concede the words "design pattern" have a very non-plastic meaning here at prog.SE which make them unsuitable in any use other than as explicitly intended or allowed by this community. Thus I will never ask the Prog.SE community ever again to interpret the term "pattern" in a philosophical or theoretical inquiry on the nature of computing, doorknobs, or anything to surprise user delnan. –  anon Oct 13 '11 at 2:59
@anon Programmers is collaboratively edited: your question has been revised to better align with the answers received and so that it can remain open and hopefully be of use to people in the future. We can disassociate your name from the question if you don't want to be associated with it anymore: just let me know. –  user8 Oct 13 '11 at 3:06

5 Answers 5

up vote 14 down vote accepted

Typically, when people mention design patterns they are referring to a set of re-useable and pre-defined problem/solution "templates" from the Gang of Four. These patterns have stood the test of time in that they repeatedly solve their problem set in a maintainable way.

A Factory Pattern is a common DP.

Push/Pop are terms used to describe operations of a Stack. Queues and Stacks are abstract data types, not design patterns. The core difference between the two is that a queue operates in a first in first out fashion while a stack is last in first out.

share|improve this answer
When I think of "data types" I think of integers and ASCII in MySQL or that PHP is "loosely typed language". Your link call this a "data structure". Is there some confusion here? –  xtian Oct 11 '11 at 22:24
@xtian: they are closely linked. Abstract Data Types are "what operations can I perform / what should they do", the data structure refers to an implementation of it. People tend to use both terms interchangeably as their are really close. I.e. List is an ADT, LinkedList and ArrayList are data structures. ...I believe ...Please correct me if I'm wrong. –  arnaud Oct 11 '11 at 22:41

To ansewer your questions: no, no and no.

  • A stack is a data structure
  • push and pop are operations on this data structure
  • CVS is not a design pattern
  • DRCS isn't either

Design patterns apply to code, not applications.


Moreover, reducing a VCS / DVCS to "push" and "pop" seems quite sad and inaccurate. It is more "merge", "diff" and "history tracking" ...but yeah, in some kind of weird abstract thinking, you could assimilate it to push an pop. DVCS are the same except that each one has its own stack instead of a central one in VCS.

share|improve this answer
Ok, Its not a design pattern. This type of version control uses the same language of "push" and "pull". Is this just coincidence? –  xtian Oct 11 '11 at 22:27
@xtian: A door also has "push" and "pull" written on it. Is a door a design pattern? –  arnaud Oct 11 '11 at 22:33
If a version control software actually 'popped' a revision off, it wouldn't be very successful. –  Fosco Oct 12 '11 at 3:01
@amaud: Yes, in many cases. Christopher Alexander's pattern #221 is "natural doors and windows" and he included several others relating to the placement, use, and design of doors if you're willing to accept patterns beyond just the door itself. But, despite the "push" and "pull" labels (an anti-pattern, really, to account for poor visual affordances), a door is most definitely not a stack. –  Dave Sherohman Oct 12 '11 at 10:49

In general, a "design pattern" is a description or template for how to solve a problem that can be used to solve a variety of problems. On this site, and by popular usage, most people relate that term to semantic constructs and templates used to solve a variety of programming challenges. As already pointed out by P.Brian.Mackey, the term was popularized by the Gang of Four to categorize the common programming strategy and patterns they have observed and recorded. However, the design pattern concept applies to strategies in architectural challenges in construction or manufacturing as well. Really, any type of domain problems can have design patterns applied to them as part of the process for creating widgets used, in part or in whole, to come to a final solution.

So, I can understand your confusion about the function of a stack and CVS as representing a design pattern, of storing and retrieving, state information. However those are not a pattern for solving a problem, they are widgets, or a finished product that helps solves some kind of problem domain.

A stack is a data structure, or abstractly speaking a tool or widget. It is not a design pattern. However, it is a representation of the OO design pattern, associating data and its function together providing a limited interface abstracting details from the things which use it. A stack could also be said to be a tool that implements the Last in First Out (LIFO) storage design pattern.

CVS and Git are not really the function of a design pattern, they are applications. What you are describing in relation to popping and pushing data, although inaccurate, is part of the workflow of those applications. In CVS and git you fetch data from a certain point of its lifetime, modify it, and then tell the CVS or Git to save those changes so you, or someone else, can fetch those changes. I just trivialized the basics of those systems, but their underlying differences are how they store information and how people access and work with the data. See http://stackoverflow.com/questions/802573/difference-between-git-and-cvs if you would like to get more detail on their differences.

share|improve this answer

As already said, a Stack is a very basic abstract datatype while CVS and DRCS are not. You could only abstract from the latter, by creating a list of their basic operations, such as checkout and commit. Such a model could also be seen as kind of an abstract datatype. However, your concrete examples CVS and DRCS are far too specific to compare them with datatypes. Maybe a better example is the comparision between a the tree data structure and a file system. Some file systems can be viewed as trees, but only if you omit a lot of implementation details.

share|improve this answer

To implement a version control you might need to use a number of design patterns. eg: - The memento pattern is used to restore an object to its previous state. This could be used for rollback feature. And Push,Pop and Stack has nothing to do with design pattern

share|improve this answer