text:
Talk:Nature conservation

Improving article
Still the article doen't hit me. Anyone improve it? Taku 19:59 Jan 3, 2003 (UTC)

-It looks very POV to me. With so much advocacy on both sides, the wise use side largely unrepresented in this article, I'm not sure how best to get to a comprehensive and NPOV article. I'm determined to try in the coming week. BobCMU76 16:28 May 10, 2003 (UTC)

 * I would be delighted you do so :-) User:anthere

Some content in the article is not so relevant. It either overrepresents or underrepresents unneeded information. For instance, the introduction includes a statement that says, "The consumer conservation ethic is sometimes expressed by the four R's: Rethink, Reduce, Recycle, Repair." This statement is not so relevant to be at the very beginning of the article. Hence, statements like these can become mere distractions about conservation and should be erased.

In addition, some references come from reliable sources (journals, first-hand accounts, other original content), while others come from unverified science websites. References coming from these undependable sources should be reevaluated and changed.

Lastly, in the lead of the article, it states data from 2018. There should be updated data from 2021. There has been many updates on nature conservation and biodiversity. More up-to-date information would increase the accreditation of this page. Gaeun Choi (talk) 16:23, 22 April 2022 (UTC)

Thoughts on Disambiguation
The last edit moved a paragraph intended to redirect those interested in the physical science meaning of conservation to the appropriate target. That's well and good. But I think even better to have a short paragraph setting the scope of the article -- then disamb -- then the meat of the article. What I find worst is having to scroll to the bottom of a long article for disamb links. BobCMU76 21:26 18 May 2003 (UTC)

I have been wondering the whole week if I could not entirely move the whole (biological) conservation to another article, as it does not seen to belong to this article any more. I wonder if it could not be disamb, just as the physical conservation is. Your definition is very good and very interesting. However, it is entirely focused on the final consumer. The very second sentence is defining "consumer conservation ethic" not conservation.

About two scrolls down of most of the paragraphs you added, there is a sentence saying "In common usage, the term refers to the activity of systematically protecting natural resources...". Since it is planned to add more to introduce specific concerns like supporting populations, global warming, biodiversity, the value of wilderness, fish and timber harvest, the common definition will find itself even further down. I consider this is the common usage for most of the world. I like your definition, but believe it quite wrong that the common usage is at least two scrolls down, and in particular below a whole paragraph stating what conservation is in the United States, historical books and so on. I would hope conservation is not only an american issue, that an article on conservation does not only focus on american conservation history, and that definitions are properly given before focusing on America.

I would like to know what other people think there. Ant

 * Good thoughts, Ant. and I hope others will speak.  Part of my problem is seeking sources on conservation that aren't 19th and 20th century American.  I've been reading Leopold (and commentators on him) mostly in considering where to take this.  Putting a more concrete and normative scope to the discussion in the opening paragraph is something I agree is needed.  BobCMU76 22:37 18 May 2003 (UTC)

I agree that conservation is not mostly about an indevidual's consumption choises. It is mainly a plitical issue. David R. Ingham 17:47, 20 January 2006 (UTC)

Disambiguation joke
"I have always wanted to work for the phone company in Hamilton, Ontario, so I could conserve energy by commuting with a Hamiltonian operator." David R. Ingham 18:12, 20 January 2006 (UTC)

Headings
Pigsonthewing, please explain here what is wrong with the more specific headings I inserted in place of your nonsensical and overly general "introduction" heading. --Jiang 11:53, 19 Dec 2003 (UTC)

 * As already pointed out, see Conflicts between users. Andy Mabbett 12:31, 19 Dec 2003 (UTC)4

 * this link is not heading anywhere, and the discussion should take place here perhaps ? ant

guys, please would you stop reverting this page ? and discuss the matter quietly first ? PomPom 12:32, 19 Dec 2003 (UTC)

 * SeeConflicts between users, et al. Andy Mabbett 12:35, 19 Dec 2003 (UTC)

 * I'm trying to and failing to get answers. --Jiang

Your last edition to conflicts, "Consider an intorduction with, say, four sentences, each making a different point,. How would you sub-divide that?" does not answer my question here. What is wrong with my headings? --Jiang 12:34, 19 Dec 2003 (UTC)

ahhh, must do anything by myself...here is the working link Conflicts between users -ant

I suggested that Angela could protect the page. 'cause I am one of the authors of the page. So I can give my opinion. I agree adding a heading to differenciate the introduction (the first paragraph) from the article itself is a good idea. But the "introduction" heading is really not very informative in itself. Why would it be best over a detailed title ? ant

 * Do you find anyting wrong with the headings I inserted or can you suggest better headings? --Jiang

 * no. It is best with headings. Clearer than before. And both look ok to my opinion. More informative than just introduction. Just my opinion. Have to go. ant

international definitions
There is a problem with international linking of this subject, which is probably related to some cultural differences in definition.

In the German and Dutch wiki, there the subject "Nature protection" (resp. Umweltschutz and Natuurbescherming) and those cover the same subject. Both originate from the idea of protection of "natural monuments": a natural area which is for some reason worth protecting. The nature protection in Germany and the Netherlands (and I know at least also in many Central European countries) also has a strong educational character. The different philosophical movements that are mentioned in the article ( Romantic-Transcendental, Resource Conservation and Evolutionary-Ecological), don't play a role as such and sound quite academic to me. The practical differences of them are not really elaborated.

In stead in the Netherlands the 3 main philosophies are:
 * Classical Nature Conservation: conserve the parts of nature that are as they were in pre-industrial times, influenced by man, but untouched by industrialization, half-natural landscapes as for example unfertilized meadows (with many species of herbs and birds). It focuses on "natural monuments".
 * Functional View: adapt to modern times, interweave civilization with nature. For example make farmers also cultivate "nature", pay them for birds breeding on their land.
 * Nature Development View: Strict seperation of civilization and nature. Natural area should be left to itself, to produce really "wild" nature. In order to reach this in a small and crowded country like the Netherlands, it is required to create pre-conditions, like import large herbivores. Also this philosophy propagates the creation of "ecological infrastructure": connections between natural areas that will allow species to migrate from one area to another. This to prevent accidental extinction in natural areas that are in fact too small.

Those three views each have a large article in the Dutch wiki, and i just gave a very brief summary. It is probably good to realize that the Netherlands is a very densely populated area, without untouched nature. On a world-scale it is probably more like gardening that nature conservation.

The link to the Frnech wiki should probably be to "Conservation de la Nature". --Taka 15:48, 28 May 2004 (UTC)

Moved
I've moved from Conservation to Conservation ethic, since that's what this page claims to be about. We need a page about conservation, as practiced by ocnservationists, but this isn't it. Andy Mabbett 20:13, 13 Jun 2004 (UTC)

Irrelevant motto?
I've never heard of exactly "Reduce Recycle Reuse Rethink" before, I think a reference is needed because otherwise it just seems to be a corruption of the waste management paradigm "Reduce Recycle Reuse" Whatever the origin, I don't see that it's significant enough to be at the start of an article on conservation, when that phrase would be more appropriate in an introduction to something like sustainability. --?

The motto as widely publicized in the US is "Reduce, Reuse, Recycle." (I do not have a source - could be the Ad Council or a similar well-funded media producer.) The order is significant because the actions are prioritized. First, use fewer resources. Second, reuse available resources as much as possible. Third, recycle; recycling is commonly interpreted to mean the reduction of a product to its component parts or materials, and this is an energy-consuming process to be avoided if possible (though it is still often preferable to pure waste). I haven't heard "rethink" included before, but it should probably be the first priority. Sustainability and conservation are inextricably linked by the utilitarian aspects of conservation. -Jon

Wildlife conservation
Britannica and Encarta have articles giving an overview on this subject. If anyone thinks this is important, they can go ahead. Tfine80 00:23, 6 August 2005 (UTC)

Thoreau
"The posthumous publication of Henry David Thoreau's Maine Woods established the grandeur of unspoiled nature as a citadel to nourish the spirit of man" This doesn't seem right to me for several reasons. For one Maine was not "unspoiled". Also it seems more Muir then Thoreau. KAM 13:56, 31 March 2006 (UTC)

Added template
I added a template still being improve, about Progressivism -which included a strong conservation ethic through Theodore Roosevelt, Pinchot and others and extends to modern day environmental causes. --Northmeister 16:52, 16 April 2006 (UTC)

Please create more "Wildlife of ....." articles for all countries.
.... and kindly contribute to these new articles when you get time, and request others too.

See Wildlife of India for reference.

Thanks

Atulsnischal 18:13, 13 February 2007 (UTC)

Invitation for WikiProject Protected areas of India & Conservation
If you are interested in Environment, Wildlife, Conservation and Nature etc. please join in to contribute, even starting off with making new stub class articles will be a great contribution.

Sincerely

Atulsnischal 16:36, 5 February 2007 (UTC)

 * We need senior administrators or people who are long in Wikipedia to help us with the templates and for other further helps. Details can be seen in its talk page. IT's urgent. We want this wkiproject to be added to the exsisting WP:IND banner. Amartyabag   TALK2ME  05:02, 8 February 2007 (UTC)

this is very bad i want info of conservation —Preceding unsigned comment added by 115.248.10.138 (talk) 07:13, 13 May 2010 (UTC)

External links modified
Hello fellow Wikipedians,

I have just modified 2 external links on Conservation (ethic). Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
 * Added archive https://web.archive.org/web/20060909070826/http://etext.lib.virginia.edu/cgi-local/DHI/dhi.cgi?id=dv1-59 to http://etext.lib.virginia.edu/cgi-local/DHI/dhi.cgi?id=dv1-59
 * Added archive https://web.archive.org/web/20100612201702/http://religion-online.org/listbycategory.asp?Cat=45 to http://www.religion-online.org/listbycategory.asp?Cat=45

When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.

Cheers.— InternetArchiveBot  (Report bug) 11:21, 29 December 2017 (UTC)

External links modified (January 2018)
Hello fellow Wikipedians,

I have just modified one external link on Conservation (ethic). Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
 * Added archive https://web.archive.org/web/20070703033240/http://www.adopt-a-ranger.org/ to http://www.adopt-a-ranger.org/

When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.

Cheers.— InternetArchiveBot  (Report bug) 19:45, 22 January 2018 (UTC)

Requested move 8 July 2020

 * The following is a closed discussion of a requested move. Please do not modify it. Subsequent comments should be made in a new section on the talk page. Editors desiring to contest the closing decision should consider a move review after discussing it on the closer's talk page. No further edits should be made to this discussion.

The result of the move request was: moved to Nature conservation – Fayenatic  L ondon 12:53, 28 July 2020 (UTC)

Conservation (ethic) → Biological conservation – The current article name is outdated, it is based on different content that meanwhile has been removed. In the sections further up this talk page it becomes clear that the article used to be focused more on consumer behaviour, but that is no longer the case. The proposed rename is supposed to reflect the article's current content. Marcocapelle (talk) 19:45, 8 July 2020 (UTC)
 * Oppose. The current proposed target is a redirect to Conservation biology. I'm concerned that moving this page to the proposed title will cause unnecessary confusion. Rreagan007 (talk) 22:10, 8 July 2020 (UTC)
 * what about Conservation (environment) or Environmental conservation or do you have any better alternative? At least I hope you agree that the current title does not make much sense anymore. Marcocapelle (talk) 07:44, 10 July 2020 (UTC)
 * I agree that the current title isn't great. "Environmental conservation" already redirects to Environmental protection so that probably won't work either. I'd suggest moving it to Nature conservation, which already redirects here. Rreagan007 (talk) 23:35, 10 July 2020 (UTC)
 * That is also perfectly fine. Marcocapelle (talk) 08:13, 11 July 2020 (UTC)
 * Okay, well just to make it official I support move to Nature conservation. Rreagan007 (talk) 16:53, 11 July 2020 (UTC)

 * The discussion above is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.

Conservation Community
I have added conservation community to the "See also" section.

Rosenbergwrite (talk) 20:02, 8 February 2021 (UTC)

Introduction
"In the United States of America, the year 1864 saw the publication of two books which laid the foundation for Romantic and Utilitarian conservation traditions in America." May need to cite this. B7lam916 (talk) 23:13, 24 April 2022 (UTC)

Biology
Conservation of nature 41.191.104.72 (talk) 15:08, 12 June 2022 (UTC)

what is conservation of Nature and it's important
yes 117.249.187.27 (talk) 14:37, 19 May 2023 (UTC)

title: Talk:Nature conservation


text:
User:Erosenfield

My name is Eric Rosenfield. I am a writer and web programmer. My web site is http://www.ericrosenfield.com and I'm also cofounder of the literary blogazine Wet Asphalt.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

title: User:Erosenfield


text:
Talk:Mu isamaa, mu õnn ja rõõm

Untitled
There exist controversy(?) in relation to the Finnish Anthem, that sometimes during its use in other countries on ceremonies (like sports awards) wrong melody is played.

There is delicate difference, as in Estonian version the melody is supposed to be repeated three times and the Finnish lasts only two times.

Untitled
Having spent time in Tallinn in the winter, small hut and crawl seems so much more apposite... :-) user:sjc
 * "Small hut and crawl" has nothing to do with patriotism. You should take all the accents out of the song and translate the unaccented lyrics into English. Scott Gall 02:29, 22 November 2005 (UTC)
 * Which will look a bit like this:

 * Mu isamaa, mu onn ja room,
 * kui kaunis oled sa!
 * Ei leia mina iial taal
 * see suure, laia ilma paal,
 * mis mul nii armas oleks ka,
 * kui sa, mu isamaa!

 * Sa oled mind ju sunnitand
 * ja ules kasvatand;
 * sind tanan mina alati
 * ja jaan sull' truuiks surmani,
 * mul koige armsam oled sa,
 * mu kallis isamaa!

 * Su ule Jumal valvaku,
 * mu armas isamaa!
 * Ta olgu sinu kaitseja
 * ja votku rohkest onnista,
 * mis iial ette votad sa,
 * mu kallis isamaa!

(I want to see what it means with all the accents taken out. It's too bad that only a million inhabitants of the world can understand either version.) Scott Gall 11:59, 27 November 2005 (UTC)

Untitled
Actually, "mu onn ja room" does not translate to "small hut and crawl". (To) crawl is "roomama" in Estonian, that's abit wrong. But well, we can leave it that way. To Scott Gall: When the accents are taken out the words don't mean anything. ;) Curgny 21:19, 30 June 2006 (UTC)

Onn= Õnn= Luck (what actually is meant with the word -õnn- in the hymn is joy, the word has 2 meanings in estonian), Room=Rõõm=Happiness

Untitled
this sentence: This also has the same melody of the counterpart of Estonia. is redundant in my oppinion. 80.235.71.160 18:21, 25 June 2007 (UTC)

Untitled
The word "adaption" is misleading in this article as it makes no difference between the melody and lyrics. The melody was yes adopted but lyrics are Estonian original. Vulc (talk) 07:56, 3 October 2016 (UTC)

— I fixed it now. Vulc (talk) 10:20, 3 October 2016 (UTC)

IPA transcription
can someone check if the IPA transcriptions for the Estonian lyrics are correct? because it doesn't seem so correct. written by 208.54.39.161 (talk) —Preceding undated comment added 22:51, 21 May 2018 (UTC)

Translations and citations needed
added citation needed tags for the literal English and the Võro translation.

The literal translation was added here by an IP. If it's their translation, it does not need a citation (a professional translation cited to a source would be preferable, though).

Same goes for the Võro translation added by, here. The additional question is, why is a Võro translation supposedly relevant here? – Finnusertop (talk ⋅ contribs) 16:35, 19 November 2019 (UTC)

 * This is also presumably what meant with the original research tag? – Finnusertop (talk ⋅ contribs) 16:38, 19 November 2019 (UTC)

 * Oh, yes indeed, . Many thanks to you for picking up on this. These types of national anthem articles have been on my 'to do' list for ages. Unfortunately, I've not been well and haven't had the strength to pursue the matter.Iryna Harpy (talk) 00:59, 22 December 2019 (UTC)
 * I've removed the Võro translation, the cn tag from the literal translation, and the OR tag. – Finnusertop (talk ⋅ contribs) 22:09, 1 January 2020 (UTC)

 * Thank you! I was getting pulled into edit wars over this issue in the not so distant past, and my health simply didn't permit me to focus on something that I would addressed without blinking an eye. Iryna Harpy (talk) 23:23, 1 January 2020 (UTC)

IPA transcription
I removed the IPA transcription because I see various issues with it. I'm not knowledgable enough to fix it myself. Here's the removed transcription for reference:

For example, in [ˈʋɑ̝l.ʋɑ̝.ku] and [ˈol.k̬u], the first has a long (grade 2) [k] while the second has short (grade 1). So "valvaku" should be something like [ˈʋɑ̝lʋɑ̝k:u], or perhaps ˈʋɑ̝l.ʋɑ̝k.ku in analogy with [ˈet.te̞], [ˈkɑ̝l.lis].

In general, Wikipedia / Wiktionary has many issues with IPA for Estonian, and unfortunately I don't know how to consistently resolve them. Mats84 (talk) 08:12, 31 March 2024 (UTC)

title: Talk:Mu isamaa, mu õnn ja rõõm


text:
Talk:Covariance

Miscellaneous
I question the phrase 'Random Variables' - surely if they were truly random variables, there could be no question of any meaningful correlation, and the whole concept would lose all utility - 12-July-2005 00:59 Sydney Earth :)

---

not sure about my edit what are ì and í ? — Preceding unsigned comment added by 61.88.219.66 (talk) 15:03, 11 July 2005 (UTC)

I agree that the phrase 'Random Variables' is a suboptimal naming construct. It tries to illude that Statistics is an exact science, when in fact it should be named 'Observations' to recognize its empirical heritage. The name should honor its real root: Analysis of data by means of rules made up for the practical purpose of getting useful information from the data :) 85.164.125.248 (talk) 17:55, 18 December 2011 (UTC)

 * Please don't be a total crackpot. If you want tutoring or instruction on these concepts, ask someone.  Don't use the word "would", as if you were talking about something hypothetical.  Admit your ignorance.  Simple example: Pick a married couple randomly from a large population.  The husband's height is a random variable, the randomness coming from the fact that the couple was chosen randomly.  The wife's height, for the same reason, is a random variable.  The two are correlated, in that the conditional probability that the wife is more than six feet tall, given that the husband is more than six-and-a-half feet tall, is different from the unconditional probability that the that the wife is more than six feet tall.  See the Wikipedia article on statistical independence of random variables; some pairs of random variables are independent; some are not.  Another example: the square of the husband's age is a random variable; the husband's age is another random variable.  And they are correlated.  As for utility, just look at all of the practical applications of these concepts in statistical analysis.  Michael Hardy 21:04, 11 July 2005 (UTC)

-- The converse however is not true ? Do you mean than Covariance could be 0 with dependant variables ?
 * Yes. example: y=x² ( where -1<=x<=1 ). Cov=0. Dependant? Yes, it's a function!

--- It is not clear what 'E' means in the equation E(XY).

E(XY) = (1/N)*sum((X_i*Y_i), i=1..N), perhaps there should be the sum definition explicitly stated in this article as well as the expectation value article? --dwee

 * That formula is correct only in the case in which the number of possible values of X and Y is some finite number N. More generally, the expectation could be an infinite series or an integral.  At any rate, E(X) is the expected value of the random variable X. Michael Hardy 01:59, 7 October 2004 (UTC)

 * Regardless of the usages of the expected value in higher level theoretical statistics, the finite sum version should be included since it is the formula that most people learn when they are first taught covariance. It's also in common practical useage, unlike the expected value formula, sample sizes aren't infinite (mostly).  Either put both formulas in or just the finite sum formula.  Every other source I can find on the internet has the finite sum definition, for example: http://mathworld.wolfram.com/Covariance.html.

-Trotsky — Preceding unsigned comment added by 165.214.14.22 (talk) 20:22, 8 June 2012 (UTC)

---

Just to note that the second equation is not rendered.

 * It is on the browser I am using. Michael Hardy 20:26, 6 January 2004 (UTC)

---

the covarioance definition for vector valued random variables looks very sophisticated...

 * That seems like a completely subjective statement. Michael Hardy 21:51, 3 January 2005 (UTC)

what is the actual reason for defining a thing like this ? Why not put the E(X_iY_j) entries into a table,

 * That's exactly what it says is done! Michael Hardy 21:51, 3 January 2005 (UTC)

why a matrix is needed ?

 * The only difference between a "table" and a matrix is that one has a definition of matrix multiplication. And one often has occasion to multiply these matrices. Michael Hardy 21:51, 3 January 2005 (UTC)

--- your "explanation" does not explain anything as any table can be treated as matrix and multiplied with other tables. This of course does not make much sense in general. So the actual question is : why the definition (and multiplication) of a matrix with entries E(X_iY_j) makes sense ?

 * Your original question was completely unclear, to say the least. Maybe I'll write something on motivation of this definition at some point. Michael Hardy 20:23, 4 January 2005 (UTC)

 * "For column-vector valued random variables X and Y with respective expected values μ and ν, and n and m scalar components respectively, the covariance is defined to be the n×m matrix"

 * I don't get it either; how do you get a matrix as the cov(X,Y) when normally it is a scalar? Probably I am not understanding how you are defining X and Y.  To me it sounds like the m or n components are just sample values of random variables X and Y?  --Chinasaur 02:00, 1 April 2005 (UTC)

___

I'm sorry but this page makes UTTERLY NO SENSE, could someone please add in a paragraph explaining things for those of us that aren't super mathmaticians? 203.112.19.195 16:24, 25 July 2005 (UTC)

___

The covariance of two column vectors is stated to generate a matrix. Is there an similar function to covariance which generates a single scalar instead of a matrix by instead multiplying the transpose of the first term against the unaltered column vector? Is there a reference where we could find the derivations of these terms? Ben hall 15:09, 16 September 2005 (UTC)

 * If X and Y are both n × 1 random vectors, so that cov(X,Y) is n × n, then the trace of the covariance may perhaps be what you're looking for. Michael Hardy 18:29, 16 September 2005 (UTC)

 * Sorry, but I think I may have expressed myself poorly. I was thinking in terms of a list of variables which could be described as a vector, or as a matrix. For example if I have the cartesian coordinates of particles in a box over a period of time, I see how I can find the covariance matrix based on each of the components for each of the particles but I cannot see how I might find a covariance matrix based solely on the motions of the particles with respect to one another (ie if they are moving in the same direction or opposing directions). For this would it be suitable to take the inner product of the differences between the cartesian coordinates and their averages? Also, how could I show that this is a valid approach? Thanks for your suggestions so far. Ben hall 20:02, 17 September 2005 (UTC)

___

In probability theory and statistics, the covariance between two real-valued random variables X and Y, with expected values E(X) = μ and E(Y) = ν is defined as: -- it is unclear that we speak about n sets of variables {X} and {Y}. I suggest starting with In probability theory and statistics, the covariance between two real-valued random variables X and Y in the given sets {X} and {Y}, with expected values E(X) = μ and E(Y) = ν is defined as:. This is unclear too, but more explanatory why do you ever speak about E(X) and E(Y) without noting they are sets of variables, not just 'variables'. Also the speech about mean values as well as expected values in th same meaning would be preferrable. I would also suggest adding a link to http://mathworld.wolfram.com/Covariance.html.

Please comment on my comments :) I will start reorganizing the article if there will be no comments within a month. --GrAndrew 13:07, 21 April 2006 (UTC)

 * Having a PhD in statistics somehow fails to enable me to understand what you're saying. What is this thing you're calling "n"??  Why do you speak of X and Y as being "in the given sets {X} and {Y}, and what in the world does that mean?  If you change the sentence to say that, I will certainly revert.  The first sentence looks fine to me, and your proposed change to it looks very bad in a number of ways, not only because it's completely cryptic.  The covariance is between random variables, not between sets of random variables.  And to refer to "n" without saying what it is would be stupid. Michael Hardy 18:20, 21 April 2006 (UTC)

I've just looked at that article on mathworld. It's quite confused. This article is clearer and more accurate. I'm still trying to guess what you mean by saying "they are sets of variables, not just 'variables'". In fact, they are just random variables, not sets of random variables. Michael Hardy 21:01, 21 April 2006 (UTC)

 * I would guess that he is coming at the problem from a time series analysis point of view and thinking of covariance in terms of a statistic calculated using a time series of sampled data. To someone from that background it can seem confusing to think of covariance calculated for a single variable when, in practice, you calculate it from a set of data.  This is not to say I think the article should be changed though perhaps if I found time to add something about calculating sample covariance on data it would clarify. --Richard Clegg 12:45, 24 April 2006 (UTC)

---

unbiased estimation
For variance, there is a biased estimation,and an unbiased estimation. Is there any unbiased estimation for covariance? Jackzhp 17:55, 2 February 2007 (UTC)
 * Yes. See sample covariance matrix. Prax54 (talk) 19:33, 10 August 2012 (UTC)

Add $$\sigma$$?
It is customary to use $$\sigma$$XY to represent covariance(x,y) and $$\sigma$$2 to represent variance. Contrary to the above author's opinion that use of symbols adds nothing to the article, I believe that adding customary symbol usage will help people coming to this page while viewing material containing those symbols.Tedtoal (talk) 22:38, 12 March 2011 (UTC)

In the current article the notation $$Cov(X,Y)$$ is used to define covariance and then the notation $$\sigma(X,Y)$$ is used later in the "Properties" section without explaining it. If the $$\sigma$$ notation is going to be used, then it should be defined before it is used. Tashiro~enwiki (talk) 01:41, 3 October 2016 (UTC)

I think the notation the notation $$\sigma(X,Y)$$ should be avoided since the symbol $$\sigma $$ can be interpreted as standard deviation, I've already changed some of the equations in the properties section using the notation $$Cov(X,Y)$$. However, I've not changed all of them, further replacements are needed. Cristtobal (talk) 18:11, 7 October 2017 (UTC)

A simpler definition exists
Hello, I don't think this page is all that great for the lay person; as a matter of fact, I think the Definition section over-complicates things. Wolfram MathWorld has us beat here: http://mathworld.wolfram.com/Covariance.html. Anyone object to me incorporating this information into this page? I'm particularly looking for feedback from folks who are significantly more stats-minded than myself. :) Thanks, dmnapolitano (talk) 18:17, 27 September 2011 (UTC)
 * Anyway: the present definition in math world many seem simpler, but is not correct. Nijdam (talk) 10:28, 9 June 2012 (UTC)

Better Formula?
The article states the last formula may cause catastrophic cancellation if used in computing, but the first formula clearly can't be computed directly in that form. So what equation should we use? 24.38.10.6 (talk) 14:34, 29 May 2013 (UTC)

IS this correct?
The following was in the section "Properties", is it correct? (if so - we can add it again)

For sequences x1, ..., xn and y1, ..., ym of random variables, we have

 * $$\sigma\left(\sum_{i=1}^n {x_i}, \sum_{j=1}^m{y_j}\right) =   \sum_{i=1}^n{\sum_{j=1}^m{\sigma\left(x_i, y_j\right)}}.\,$$

Tal Galili (talk) 06:39, 29 September 2013 (UTC)

Hoeffding Covariance Identity
I added the Hoeffding Covariance Identity to the article. I was not able to find a proof online though, how should I reference the result in this case? — Preceding unsigned comment added by 46.227.2.125 (talk) 16:47, 2 August 2016 (UTC)

Okay, done! Someone check the formatting ;-) — Preceding unsigned comment added by 46.227.2.125 (talk) 16:58, 2 August 2016 (UTC)

Values given in the Example
Hi all!! I think there is an error calculating de standard deviation for the first example, before calculating the value for the covariance between X and Y: For the X variable, which is taking values in {1,2}, N=2 and mean equal 3/2, I am getting, in fact, 1/2. However, for the variable Y taking values in {1,2,3}, applying the formula with N=3 and mean equal 2, the value I get for the standard deviation is the square root of 2/3, not the square root of 1/2, as it says in the article. Can anyone tell me where I am wrong? [posted 1 October 2017 by User:Mmatth] —Preceding undated comment added 21:29, 1 October 2017 (UTC)
 * Y takes on values 1 with probability 1/4, 2 with probability 1/2, and 3 with probability 1/4, giving a mean of 2. So
 * $$\sigma_Y^2=(1/4)(1-2)^2+(1/2)(2-2)^2+(1/4)(3-2)^2= 1/4+0+1/4=1/2.$$
 * Loraof (talk) 20:26, 4 October 2017 (UTC)
 * I came here exactly for that. I also got $$\sigma_Y=\frac{1}{\sqrt{2}}$$ whereas the article claims $$\sigma_Y=\sqrt{\frac{2}{3}}$$. Unless both mine and Loraof calculations are wrong, there still seem to be an error in the article, in $$\sigma_Y$$ part.
 * (Erithion (talk) 14:24, 8 January 2020 (UTC))
 * if it is not broken, then you may be able to clear this up? HelpUsStopSpam (talk) 22:56, 14 January 2020 (UTC)
 * The problem was that there was a pattern of people who kept changing from 1/2 to 2/3. I missed one, and then when someone else changed it back, I got confused and reverted them without realizing it had been changed without me noticing.  I have since put it back to the correct value, as per the notes above. –Deacon Vorbis (carbon • videos) 23:00, 14 January 2020 (UTC)

No reference to physics???
I wonder why there is no link (at the very least) to covariance in physics, e.g. general covariance in relativity. — Preceding unsigned comment added by 42.111.162.152 (talk) 02:47, 10 July 2019 (UTC)

 * This article is not about the same definition of covariance. The "about" template at the beginning states, The Covariance (disambiguation) page links to several articles which mention covariance in mathematics and physics.—Anita5192 (talk) 04:44, 10 July 2019 (UTC)

COV definition & example use are different (aren't they?)
Under the heading "Definition", COV(X,Y) = E[(X-E[X])(Y-E[Y])] = E[XY] - E[X]E[Y]

Under the heading "Discrete random variables", COV(X,Y) = SUM( i=1:n; P_i*(x_i-E[X])*(y_i*E[Y]) ); I'll refer to this definition below as COV1. For discrete r.v's, this is the same as the defn in terms of expected value. All good.

Under the heading "Example", COV(X,Y) = SigmaXY = SUM( (x,y) elementof S; f(x,y)*(x-MuX)*(y-MuY) ); I'll refer to this sum as COV2.

My understanding is that COV2 can be written as COV2(X,Y) = SUM( j=1:n; SUM( k=1:m; f(x_j, y_k)*(x_j-MuX)*(y_k-MuY) ) ); this is how the example calculates the COV from the table.

It would be helpful if the article could clear up how COV1 is equivalent to COV2 (I've not been able to nor can I see how to do so).

This ambiguity is widespread (and is not confined solely to this article); any number of stats books interchangeably use COV1 and COV2 to calculate the correlation coefficient, often using both within a breath of each other.

Dig a bit more and the defn of expected value is ambiguous. Is it (a) E[X] = SUM( j=1:n; x_j*f(x_j) ) OR is it (as given for joint distns) (b) E[XY] = SUM( j=1:n; SUM( k=1:m; f(x_j, y_k)*x_j*y_k ) )? Does E[XY] (a) equal E[XY] (b) ?

There's surely a gap in my stats knowledge but shouldn't these books and articles like this fill this gap ?

Thanks. DP3285 (talk) 04:28, 6 November 2022 (UTC)

I believe that the definition presents the covariance for the population (by dividing by N), whereas the discrete subsection gives the covariance of the sample (dividing by N-1). There should be a clarification on this, and maybe the addition of the sample covariance equation. I would do it myself, but my stats knowledge is not so good and I'm afraid of making a mistake. — Preceding unsigned comment added by Lacuerdaloca (talk • contribs) 12:43, 26 May 2023 (UTC)

title: Talk:Covariance


text:
User:Jayel

Like the name? My mom was considering to name me that, but she settled for Jennie instead.

Well, I'm 16 years old, and found this site while cramming info in for a project. Now I swear by this site, and just became a member.

I like to read, write, and am the co-editor in chief of my high school's newspaper. I love hockey too. The Spider-man movie was fantastic, and I am in love with Tobey Maguire (if any of you know him, put in a good word for me!). Not to mention that I'm also in love with Ewan McGregor, and with Star Wars (movies and books included).

Feel free to contact me at JeLyBro@aol.com for any reason (editing, Star Wars, hockey, just to chat because you're bored, etc).

Currently, I have done major updates to the Mara Jade page, and have made minor changes to Han Solo and Princess Leia pages. I have created new pages for Jacen Solo, Jaina Solo, and Anakin Solo. I will probably work on more Star Wars pages, the ones mostly concerned with the books. Hey, it's something I can truly feel good about spreading around - the ever-growing Star Wars universe. I have done the Pearl S. Buck page, since I have already written a bio on her for a school project. That page has a few more things to correct on it, mostly link issues. I also did East Wind: West Wind page, the first novel that Buck wrote.

I'm still fixing some of the links here and on some of the Star Wars pages. I apologize for any dead links. For those of you out there who think that I may have totally screwed something up, thanks ahead of time for fixing it.

title: User:Jayel


text:
File:Just Enough Education to Perform.jpg

Summary
Cover for "Just Enough Education to Perform" studio album by the rock band Stereophonics. Copyright V2 MUSIC UK.


text: Talk:Barney Gumble

title: Talk:Barney Gumble


text:
Saxtead Green Windmill

Saxtead Green Post Windmill is a Grade II* listed post mill at Saxtead Green, Woodbridge, Suffolk, England which is also a Scheduled monument and has been restored.

History
According to the Manorial Records there has been a windmill in Saxtead since 1287. The current Saxtead Green Mill dates back to at least 1796 when the miller was Amos Webber. In 1810, the Mill House was built for Robert Holmes. The mill was raised a total of three times during its working life. The mill was tailwinded c. 1853. Around this time, the sails were destroyed and remade but in 1854 Whitmore and Binyon, the Wickham Market millwrights fitted new cast iron machinery and windshaft, and the layout of the machinery changed from Head and Tail to Breast stones. It was in this year that the mill was raised for the third time. Collins, the Melton millwright worked on the mill in the 1870s and Whitmore and Binyon again worked on the mill in the 1890s. From 1926 millwright Jesse Wightman (who was initially apprenticed to A S Aldred the Miller) assisted the owner with repairs until the mill ceased working commercially on the death of the last miller in 1947.

The mill passed to Mr Steven Charles Sullivan,(1908–1997) the son-in-law of A S Aldred, who placed the mill in the guardianship of the Ministry of Works in 1951. The mill is currently owned by Stephen and Jonathan Sullivan (ensuring the Mill has been in the ownership of the same family since 1873) The mill was completely rebuilt between 1957 and 1960 under the supervision of Jesse Wightman. A replacement crowntree was obtained from a windmill at Wetheringsett which had been demolished. The mill has been in the care of English Heritage since 1984

The mill was repaired, with a new pair of sails made in 2008.

In 2017 the mill was closed by English Heritage who undertook a 250k restoration project of the mill. Local Millwright Tim Whiting was appointed to complete the works which involved building a new set of sails and replacing the fantail. The mill was due to reopen in April 2020 but due to the Coronavirus pandemic was delayed until 2021.

Description
Saxtead Green Mill is a post mill with a three-storey roundhouse. The mill has four Patent sails carried on a cast-iron windshaft and is winded by a fantail. The mill has two pairs of millstones in the breast. All the machinery is of cast iron except the Brake Wheel, which is of oak.

Millers
Reference for the above -
 * Amos Webber 1796
 * Robert Holmes 1810
 * George Holmes
 * George William Holmes
 * Mr Meadows
 * Mr Steggles
 * Mr Rouse
 * Frederick Eldred
 * Alfred Aldred
 * Alfred Stephenson Robert Aldred - 1947

Public access
The mill is open to the public on Friday, Saturday and Bank Holidays between 1 April and 30 September each year.

title: Saxtead Green Windmill


text:
Karada

Karada may refer to:
 * Karada, India, a settlement in Kodagu district, Karnataka
 * Bondage rope harness, a rope bondage technique
 * Cleistanthus collinus, a toxic tree whose bark contains leucodelphinidin
 * Karhade Brahmin, a Hindu tribe in India

title: Karada


text:
Builder pattern

The builder pattern is a design pattern that provides a flexible solution to various object creation problems in object-oriented programming. The builder pattern separates the construction of a complex object from its representation. It is one of the 23 classic design patterns described in the book Design Patterns (often referred to as the "Gang of Four" or simply "GoF") and is sub-categorized as a creational pattern.

Overview
The Builder design pattern solves problems like:
 * How can a class (the same construction process) create different representations of a complex object?
 * How can a class that includes creating a complex object be simplified?

Creating and assembling the parts of a complex object directly within a class is inflexible. It commits the class to creating a particular representation of the complex object and makes it impossible to change the representation later independently from (without having to change) the class.

The Builder design pattern describes how to solve such problems:
 * Encapsulate creating and assembling the parts of a complex object in a separate   object.
 * A class delegates object creation to a  object instead of creating the objects directly.

A class (the same construction process) can delegate to different  objects to create different representations of a complex object.

Definition
The intent of the Builder design pattern is to separate the construction of a complex object from its representation. By doing so, the same construction process can create different representations.

Advantages
Advantages of the Builder pattern include:
 * Allows you to vary a product's internal representation.
 * Encapsulates code for construction and representation.
 * Provides control over the steps of the construction process.

Disadvantages
Disadvantages of the Builder pattern include:
 * A distinct ConcreteBuilder must be created for each type of product.
 * Builder classes must be mutable.
 * May hamper/complicate dependency injection.
 * In many null-safe languages, the builder pattern defers compile-time errors for unset fields to runtime.

UML class and sequence diagram

In the above UML class diagram, the  class doesn't create and assemble the   and   objects directly. Instead, the  refers to the   interface for building (creating and assembling) the parts of a complex object, which makes the  independent of which concrete classes are instantiated (which representation is created). The  class implements the   interface by creating and assembling the   and   objects. The UML sequence diagram shows the run-time interactions: The  object calls   on the   object, which creates and assembles the   object. Thereafter, the  calls   on , which creates and assembles the   object.

Class diagram

 * Builder
 * Abstract interface for creating objects (product).

 * ConcreteBuilder
 * Provides implementation for Builder. It is an object able to construct other objects. Constructs and assembles parts to build the objects.

Examples
A C# example:

The Director assembles a bicycle instance in the example above, delegating the construction to a separate builder object that has been given to the Director by the Client.

title: Builder pattern


text:
Factory method pattern

In object oriented programming, the factory method pattern is a design pattern that uses factory methods to deal with the problem of creating objects without having to specify their exact class. Rather than by calling a constructor, this is done by calling a factory method to create an object. Factory methods can either be specified in an interface and implemented by child classes, or implemented in a base class and optionally overridden by derived classes. It is one of the 23 classic design patterns described in the book Design Patterns (often referred to as the "Gang of Four" or simply "GoF") and is sub-categorized as a creational pattern.

Overview
The Factory Method design pattern solves problems like:
 * How can an object be created so that subclasses can redefine its subsequent and distinct implementation?
 * How can an object's instantiation be deferred to a subclass?

The Factory Method design pattern describes how to solve such problems:
 * Define a factory method within the superclass that defers the object's creation to a subclass's factory method.
 * Create an object by calling a factory method instead of directly calling a constructor.

This enables the writing of subclasses that can change the way an object is created (e.g. by redefining which class to instantiate). See also the UML class diagram below.

Definition
"Define an interface for creating an object, but let subclasses decide which class to instantiate. The Factory method lets a class defer instantiation it uses to subclasses." (Gang Of Four)

Creating an object often requires complex processes not appropriate to include within a composing object. The object's creation may lead to a significant duplication of code, may require information not accessible to the composing object, may not provide a sufficient level of abstraction, or may otherwise not be part of the composing object's concerns. The factory method design pattern handles these problems by defining a separate method for creating the objects, which subclasses can then override to specify the derived type of product that will be created.

The factory method pattern relies on inheritance, as object creation is delegated to subclasses that implement the factory method to create objects. As shown in the C# example below, the factory method pattern can also rely on an Interface - in this case IPerson - to be implemented.

UML class diagram

In the above UML class diagram, the  class that requires a   object does not instantiate the   class directly. Instead, the  refers to a separate   to create a product object, which makes the  independent of which concrete class is instantiated. Subclasses of  can redefine which class to instantiate. In this example, the  subclass implements the abstract   by instantiating the   class.

Examples
This C++14 implementation is based on the pre C++98 implementation in the book.

The program output is like

A maze game may be played in two modes, one with regular rooms that are only connected with adjacent rooms, and one with magic rooms that allow players to be transported at random.

Structure

is the base class for a final product ( or  ). declares the abstract factory method to produce such a base product. and  are subclasses of the base product implementing the final product. and  are subclasses of   implementing the factory method producing the final products. Thus factory methods decouple callers from the implementation of the concrete classes. This makes the "new" Operator redundant, allows adherence to the Open/closed principle and makes the final product more flexible in the event of change.

C#
In the above code you can see the creation of one interface called  and two implementations called   and. Based on the type passed into the  object, we are returning the original concrete object as the interface.

A factory method is just an addition to  class. It creates the object of the class through interfaces but on the other hand, it also lets the subclass decide which class is instantiated.

You can see we have used  in concreteFactory. As a result, you can easily call  from it to get the. You might also write your custom logic after getting the object in the concrete Factory Method. The GetObject is made abstract in the Factory interface.

Java
This Java example is similar to one in the book Design Patterns.

The MazeGame uses Rooms but it puts the responsibility of creating Rooms to its subclasses which create the concrete classes. The regular game mode could use this template method:

In the above snippet, the  constructor is a template method that makes some common logic. It refers to the  factory method that encapsulates the creation of rooms such that other rooms can be used in a subclass. To implement the other game mode that has magic rooms, it suffices to override the  method:

PHP
Another example in PHP follows, this time using interface implementations as opposed to subclassing (however, the same can be achieved through subclassing). It is important to note that the factory method can also be defined as public and called directly by the client code (in contrast with the Java example above).

Python
Same as Java example.

Uses

 * In ADO.NET, IDbCommand.CreateParameter is an example of the use of factory method to connect parallel class hierarchies.
 * In Qt, QMainWindow::createPopupMenu is a factory method declared in a framework that can be overridden in application code.
 * In Java, several factories are used in the javax.xml.parsers package. e.g. javax.xml.parsers.DocumentBuilderFactory or javax.xml.parsers.SAXParserFactory.
 * In the HTML5 DOM API, the Document interface contains a createElement factory method for creating specific elements of the HTMLElement interface.

title: Factory method pattern


text:
Prototype pattern

The prototype pattern is a creational design pattern in software development. It is used when the types of objects to create is determined by a prototypical instance, which is cloned to produce new objects. This pattern is used to avoid subclasses of an object creator in the client application, like the factory method pattern does, and to avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.

To implement the pattern, the client declares an abstract base class that specifies a pure virtual clone method. Any class that needs a "polymorphic constructor" capability derives itself from the abstract base class, and implements the clone operation.

The client, instead of writing code that invokes the "new" operator on a hard-coded class name, calls the clone method on the prototype, calls a factory method with a parameter designating the particular concrete derived class desired, or invokes the clone method through some mechanism provided by another design pattern.

The mitotic division of a cell — resulting in two identical cells — is an example of a prototype that plays an active role in copying itself and thus, demonstrates the Prototype pattern. When a cell splits, two cells of identical genotype result. In other words, the cell clones itself.

Overview
The prototype design pattern is one of the 23 Gang of Four design patterns that describe how to solve recurring design problems to design flexible and reusable object-oriented software, that is, objects that are easier to implement, change, test, and reuse.

The prototype design pattern solves problems like:
 * How can objects be created so that which objects to create can be specified at run-time?
 * How can dynamically loaded classes be instantiated?

Creating objects directly within the class that requires (uses) the objects is inflexible because it commits the class to particular objects at compile-time and makes it impossible to specify which objects to create at run-time.

The prototype design pattern describes how to solve such problems:
 * Define a  object that returns a copy of itself.
 * Create new objects by copying a  object.

This enables configuration of a class with different  objects, which are copied to create new objects, and even more,   objects can be added and removed at run-time. See also the UML class and sequence diagram below.

UML class and sequence diagram

In the above UML class diagram, the  class refers to the   interface for cloning a. The  class implements the   interface by creating a copy of itself. The UML sequence diagram shows the run-time interactions: The  object calls   on a   object, which creates and returns a copy of itself (a   object).

Rules of thumb
Sometimes creational patterns overlap—there are cases when either prototype or abstract factory would be appropriate. At other times, they complement each other: abstract factory might store a set of prototypes from which to clone and return product objects. Abstract factory, builder, and prototype can use singleton in their implementations. Abstract factory classes are often implemented with factory methods (creation through inheritance), but they can be implemented using prototype (creation through delegation).

Often, designs start out using Factory Method (less complicated, more customizable, subclasses proliferate) and evolve toward abstract factory, prototype, or builder (more flexible, more complex) as the designer discovers where more flexibility is needed.

Prototype does not require subclassing, but it does require an "initialize" operation. Factory method requires subclassing, but does not require initialization.

Designs that make heavy use of the composite and decorator patterns often can benefit from Prototype as well.

A general guideline in programming suggests using the  method when creating a duplicate object during runtime to ensure it accurately reflects the original object. This process, known as object cloning, produces a new object with identical attributes to the one being cloned. Alternatively, instantiating a class using the  keyword generates an object with default attribute values.

For instance, in the context of designing a system for managing bank account transactions, it may be necessary to duplicate the object containing account information to conduct transactions while preserving the original data. In such scenarios, employing the  method is preferable over using   to instantiate a new object.

Example
This C++11 implementation is based on the pre C++98 implementation in the book.

The program output is:

C++ example
Discussion of the design pattern along with a complete illustrative example implementation using polymorphic class design are provided in the C++ Annotations.

title: Prototype pattern


text:
Talk:Prototype pattern

Sentence misunderstood
The sentence that compares the Prototype DP to the Abstract Factory DP can be understood in two ways and needs clarification. Thanks. — Preceding unsigned comment added by 132.68.50.212 (talk) 13:51, 21 February 2013 (UTC)

Initialization with an object
If I create an object with certain properties, then use this to create another object (by passing it to a constructor) which will be initialised with those properties, this would seem to be a Prototype, but this is a little different from the GoF pattern - any thoughts? --- DannyAyers

 * Looks like a CopyConstructor to me. --- LairdNelson

 * You would lose the advantage of polymorphism that the GoF formulation of the Prototype pattern gives you. -- NatPryce

 * Exactly..Prototyping is all about a replica of myself .I don't know what i'm.ie polymorphism..But i can duplicate myself when some body else needs a duplicate of me and he don't care about my type (Hierarchy in the inheritance tree). --Praveen

 * By using Copy Constructor, this design pattern can be applied. But in C++ copy constructor is default property means you not need to declare it explicitly.But in other language may be copy constructor had to declare to provide such facility. In this case if some derived class in tree doesn't declare it then this pattern will fail for that hierarchy tree. That may be happen since OO language has the facility of reusability.So to keep pattern language independent I suggest declare the 'Clone' kind function as a pure virtual. That will force each drive class to provide Prototype facility.      -Akash Gupta

Link Dead
The example link is dead ... Please use link http://wwwswt.informatik.uni-rostock.de/deutsch/Lehre/Uebung/Beispiele/PatternExamples/patexamples.htm

The example link is dead ... Please use link http://wwwswt.informatik.uni-rostock.de/deutsch/Lehre/Uebung/Beispiele/PatternExamples/patexamples.htm

62.39.121.226 13:31, 7 October 2005 (UTC)Rajiv

Prototype complexity
I wonder why the GoF authors say that Prototype is more complexe than Factory Method which relies on a hierarchy parallel to the Product hierarchy! I think there is a confusion between several problems that the pattern solves. First, Prototype solves the same problem as Factory Method, namely creating instances of classes without naming them. Second, it can be used to build objects faster or more easily by copying already built ones. There certainely are other uses for this pattern.

If the goal is to decouple clients from the classes to instantiate then I do not see why it would be more complex than Factory Method: on the contrary it is much simpler (no parallel hierarchy). The clone method is in fact a misnomer is this case: you do not need to clone a prototype p but simply want a new object of the same (dynamic) type as p. MikalZiane 13:05, 26 June 2006 (UTC)

Reasons to use clone
"This pattern is used for example when the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) is prohibitively expensive for a given application." - This sounds a bit misleading to me. The IMHO most common reason to use a clone method instead of new is that you do not know the concrete type of the object, i.e. it is impossible to use new.

The article lists a non-software example of the prototype pattern. Not to seem too picky here, but couldn't we list some actual *software* cases where the design pattern is useful? —Preceding unsigned comment added by 67.183.113.131 (talk) 05:27, 17 August 2010 (UTC)

Java example question
The introduction to the article says: "To implement the pattern, declare an abstract base class that specifies a pure virtual clone method."However, in the Java example the Cookie class is not declared abstract. Isn't this inconsistent with the introduction to the article?

210.23.150.138 (talk) 22:45, 4 November 2009 (UTC)

C# XPathNavigator
I think you have to go over the whole page again. It does not become clear when and why to use the clone method.

A good example is XPathNavigator in C#. Understand why they use the clone method here. If you understand this you understand the prototype pattern in a different way.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconXPathNavigatorOverDifferentStores.asp

Structure - Class Diagram
Sorry if I'm mistaken, but in the diagram, isn't the Client class implementing the Prototype superclass? (Due to the white triangle shape of the arrow).

Sorry also for the bad English.

Alpha (talk) 12:02, 16 February 2008 (UTC)

JavaScript
Wouldn't it make sense to give an example in JavaScript, which supports much of this natively? See http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html Jon (talk) 13:15, 13 February 2009 (UTC)

All non-Java examples now unavailable
Earlier the article was edited to remove all but the not very appropriate Java example, with the claim that other examples were available in the external links. Later, the external links were removed as being link spam. So as a result of two quality improvement efforts, the quality went way down. Either non-spam links need to be added, or former links restored (I looked briefly and there was useful information/example code to be had without having to buy anything), or multiple language examples need to be included. I prefer the latter, as different languages have different features which dramatically affect what patterns are needed, how useful they are, etc. Saying "Wikipedia is not a programming manual" is kind of missing the point - different human languages cover the same page, because different humans think in different languages. The same goes for programming languages - if you want everyone reading the article to understand it, you either need a universal and probably not "real" programming language, or you need multiple real languages. Jodawi (talk) 21:05, 16 July 2011 (UTC)

Self, Javascript
Javascript is today's most popular programming language, and that makes it the flagship of prototypal inheritance patterns. Javascript gleaned the pattern from Self. So I corroborate the above points regarding language citations and examples. To include a sample implementation in Java is nearly non-sensical... to provide that sample *alone* is just ridiculous. To wit: http://twitter.com/#!/emjayess/status/92640484299780096 emjayess (talk) 17:48, 17 July 2011 (UTC)

UML class and sequence diagram
I would like to share the following UML diagrams I have published on Design Patterns Open Online Learning. Your comments are welcomed!

In the above UML class diagram, the  class that requires a   object doesn't instantiate the   class directly. Instead, the  refers to the   interface for cloning an object. The  class implements the   interface by creating a copy of itself. The UML sequence diagram shows the run-time interactions: The  object calls   on a   object, which creates and returns a copy of itself (a   object). Vanderjoe (talk) 13:14, 10 August 2017 (UTC)

title: Talk:Prototype pattern


text:
Composite pattern

In software engineering, the composite pattern is a partitioning design pattern. The composite pattern describes a group of objects that are treated the same way as a single instance of the same type of object. The intent of a composite is to "compose" objects into tree structures to represent part-whole hierarchies. Implementing the composite pattern lets clients treat individual objects and compositions uniformly.

Overview
The Composite design pattern is one of the twenty-three well-known GoF design patterns that describe how to solve recurring design problems to design flexible and reusable object-oriented software, that is, objects that are easier to implement, change, test, and reuse.

What problems can the Composite design pattern solve?

 * A part-whole hierarchy should be represented so that clients can treat part and whole objects uniformly.
 * A part-whole hierarchy should be represented as tree structure.

When defining (1)  objects and (2)   objects that act as containers for   objects, clients must treat them separately, which complicates client code.

What solution does the Composite design pattern describe?

 * Define a unified  interface for both part  objects and whole  objects.
 * Individual  objects implement the   interface directly, and   objects forward requests to their child components.

This enables clients to work through the  interface to treat   and   objects uniformly: objects perform a request directly, and  objects forward the request to their child components recursively downwards the tree structure. This makes client classes easier to implement, change, test, and reuse.

See also the UML class and object diagram below.

Motivation
When dealing with Tree-structured data, programmers often have to discriminate between a leaf-node and a branch. This makes code more complex, and therefore, more error prone. The solution is an interface that allows treating complex and primitive objects uniformly. In object-oriented programming, a composite is an object designed as a composition of one-or-more similar objects, all exhibiting similar functionality. This is known as a "has-a" relationship between objects. The key concept is that you can manipulate a single instance of the object just as you would manipulate a group of them. The operations you can perform on all the composite objects often have a least common denominator relationship. For example, if defining a system to portray grouped shapes on a screen, it would be useful to define resizing a group of shapes to have the same effect (in some sense) as resizing a single shape.

When to use
Composite should be used when clients ignore the difference between compositions of objects and individual objects. If programmers find that they are using multiple objects in the same way, and often have nearly identical code to handle each of them, then composite is a good choice; it is less complex in this situation to treat primitives and composites as homogeneous.

UML class and object diagram

In the above UML class diagram, the  class doesn't refer to the   and   classes directly (separately). Instead, the  refers to the common   interface and can treat   and   uniformly. The  class has no children and implements the   interface directly. The  class maintains a container of child objects and forwards requests to these.

The object collaboration diagram shows the run-time interactions: In this example, the  object sends a request to the top-level   object (of type  ) in the tree structure. The request is forwarded to (performed on) all child  objects ( and   objects) downwards the tree structure.

 * Defining Child-Related Operations

There are two design variants for defining and implementing child-related operations like adding/removing a child component to/from the container and accessing a child component :
 * Design for uniformity: Child-related operations are defined in the  interface. This enables clients to treat   and   objects uniformly. But type safety is lost because clients can perform child-related operations on   objects.
 * Design for type safety: Child-related operations are defined only in the  class. Clients must treat   and   objects differently. But type safety is gained because clients cannot perform child-related operations on   objects.

The Composite design pattern emphasizes uniformity over type safety.

UML class diagram

 * Component
 * is the abstraction for all components, including composite ones
 * declares the interface for objects in the composition
 * (optional) defines an interface for accessing a component's parent in the recursive structure, and implements it if that's appropriate

 * Leaf
 * represents leaf objects in the composition
 * implements all Component methods

 * Composite
 * represents a composite Component (component having children)
 * implements methods to manipulate children
 * implements all Component methods, generally by delegating them to its children

Variation
As it is described in Design Patterns, the pattern also involves including the child-manipulation methods in the main Component interface, not just the Composite subclass. More recent descriptions sometimes omit these methods.

Example
This C++14 implementation is based on the pre C++98 implementation in the book.

The program output is

title: Composite pattern


text:
Decorator pattern

In object-oriented programming, the decorator pattern is a design pattern that allows behavior to be added to an individual object, dynamically, without affecting the behavior of other instances of the same class. The decorator pattern is often useful for adhering to the Single Responsibility Principle, as it allows functionality to be divided between classes with unique areas of concern as well as to the Open-Closed Principle, by allowing the functionality of a class to be extended without being modified. Decorator use can be more efficient than subclassing, because an object's behavior can be augmented without defining an entirely new object.

Overview
The decorator design pattern is one of the twenty-three well-known design patterns; these describe how to solve recurring design problems and design flexible and reusable object-oriented software—that is, objects which are easier to implement, change, test, and reuse.

What problems can it solve?

 * Responsibilities should be added to (and removed from) an object dynamically at run-time.
 * A flexible alternative to subclassing for extending functionality should be provided.

When using subclassing, different subclasses extend a class in different ways. But an extension is bound to the class at compile-time and can't be changed at run-time.

What solution does it describe?
Define  objects that
 * implement the interface of the extended (decorated) object transparently by forwarding all requests to it
 * perform additional functionality before/after forwarding a request.

This allows working with different  objects to extend the functionality of an object dynamically at run-time.

See also the UML class and sequence diagram below.

Intent
The decorator pattern can be used to extend (decorate) the functionality of a certain object statically, or in some cases at run-time, independently of other instances of the same class, provided some groundwork is done at design time. This is achieved by designing a new Decorator class that wraps the original class. This wrapping could be achieved by the following sequence of steps:
 * 1) Subclass the original Component class into a Decorator class (see UML diagram);
 * 2) In the Decorator class, add a Component pointer as a field;
 * 3) In the Decorator class, pass a Component to the Decorator constructor to initialize the Component pointer;
 * 4) In the Decorator class, forward all Component methods to the Component pointer; and
 * 5) In the ConcreteDecorator class, override any Component method(s) whose behavior needs to be modified.

This pattern is designed so that multiple decorators can be stacked on top of each other, each time adding a new functionality to the overridden method(s).

Note that decorators and the original class object share a common set of features. In the previous diagram, the operation method was available in both the decorated and undecorated versions.

The decoration features (e.g., methods, properties, or other members) are usually defined by an interface, mixin (a.k.a. trait) or class inheritance which is shared by the decorators and the decorated object. In the previous example, the class Component is inherited by both the ConcreteComponent and the subclasses that descend from Decorator.

The decorator pattern is an alternative to subclassing. Subclassing adds behavior at compile time, and the change affects all instances of the original class; decorating can provide new behavior at run-time for selected objects.

This difference becomes most important when there are several independent ways of extending functionality. In some object-oriented programming languages, classes cannot be created at runtime, and it is typically not possible to predict, at design time, what combinations of extensions will be needed. This would mean that a new class would have to be made for every possible combination. By contrast, decorators are objects, created at runtime, and can be combined on a per-use basis. The I/O Streams implementations of both Java and the .NET Framework incorporate the decorator pattern.

Motivation
As an example, consider a window in a windowing system. To allow scrolling of the window's contents, one may wish to add horizontal or vertical scrollbars to it, as appropriate. Assume windows are represented by instances of the Window interface, and assume this class has no functionality for adding scrollbars. One could create a subclass ScrollingWindow that provides them, or create a ScrollingWindowDecorator that adds this functionality to existing Window objects. At this point, either solution would be fine.

Now, assume one also desires the ability to add borders to windows. Again, the original Window class has no support. The ScrollingWindow subclass now poses a problem, because it has effectively created a new kind of window. If one wishes to add border support to many but not all windows, one must create subclasses WindowWithBorder and ScrollingWindowWithBorder, etc. This problem gets worse with every new feature or window subtype to be added. For the decorator solution, a new BorderedWindowDecorator is created. Any combination of ScrollingWindowDecorator or BorderedWindowDecorator can decorate existing windows. If the functionality needs to be added to all Windows, the base class can be modified. On the other hand, sometimes (e.g., using external frameworks) it is not possible, legal, or convenient to modify the base class.

In the previous example, the SimpleWindow and WindowDecorator classes implement the Window interface, which defines the draw method and the getDescription method that are required in this scenario, in order to decorate a window control.

Applying decorators
Adding or removing decorators on command (like a button press) is a common UI pattern, often implemented along with the Command design pattern. For example, a text editing application might have a button to highlight text. On button press, the individual text glyphs currently selected will all be wrapped in decorators that modify their draw function, causing them to be drawn in a highlighted manner (a real implementation would probably also use a demarcation system to maximize efficiency).

Applying or removing decorators based on changes in state is another common use case. Depending on the scope of the state, decorators can be applied or removed in bulk. Similarly, the State design pattern can be implemented using decorators instead of subclassed objects encapsulating the changing functionality. The use of decorators in this manner makes the State object's internal state and functionality more compositional and capable of handling arbitrary complexity.

Usage in Flyweight objects
Decoration is also often used in the Flyweight design pattern. Flyweight objects are divided into two components: an invariant component that is shared between all flyweight objects; and a variant, decorated component that may be partially shared or completely unshared. This partitioning of the flyweight object is intended to reduce memory consumption. The decorators are typically cached and reused as well. The decorators will all contain a common reference to the shared, invariant object. If the decorated state is only partially variant, then the decorators can also be shared to some degree - though care must be taken not to alter their state while they're being used. iOS's UITableView implements the flyweight pattern in this manner - a tableview's reusable cells are decorators that contains a references to a common tableview row object, and the cells are cached / reused.

Obstacles of interfacing with decorators
Applying combinations of decorators in diverse ways to a collection of objects introduces some problems interfacing with the collection in a way that takes full advantage of the functionality added by the decorators. The use of an Adapter or Visitor patterns can be useful in such cases. Interfacing with multiple layers of decorators poses additional challenges and logic of Adapters and Visitors must be designed to account for that.

Architectural relevance
Decorators support a compositional rather than a top-down, hierarchical approach to extending functionality. A decorator makes it possible to add or alter behavior of an interface at run-time. They can be used to wrap objects in a multilayered, arbitrary combination of ways. Doing the same with subclasses means implementing complex networks of multiple inheritance, which is memory-inefficient and at a certain point just cannot scale. Likewise, attempting to implement the same functionality with properties bloats each instance of the object with unnecessary properties. For the above reasons decorators are often considered a memory-efficient alternative to subclassing.

Decorators can also be used to specialize objects which are not subclassable, whose characteristics need to be altered at runtime (as mentioned elsewhere), or generally objects that are lacking in some needed functionality.

Usage in enhancing APIs
The decorator pattern also can augment the Facade pattern. A facade is designed to simply interface with the complex system it encapsulates, but it does not add functionality to the system. However, the wrapping of a complex system provides a space that may be used to introduce new functionality based on the coordination of subcomponents in the system. For example, a facade pattern may unify many different languages dictionaries under one multi-language dictionary interface. The new interface may also provide new functions for translating words between languages. This is a hybrid pattern - the unified interface provides a space for augmentation. Think of decorators as not being limited to wrapping individual objects, but capable of wrapping clusters of objects in this hybrid approach as well.

Alternatives to Decorators
As an alternative to the decorator pattern, the adapter can be used when the wrapper must respect a particular interface and must support polymorphic behavior, and the Facade when an easier or simpler interface to an underlying object is desired.

UML class and sequence diagram

In the above UML class diagram, the abstract  class maintains a reference to the decorated object and forwards all requests to it. This makes  transparent (invisible) to clients of.

Subclasses implement additional behavior that should be added to the  (before/after forwarding a request to it).

The sequence diagram shows the run-time interactions: The  object works through  and   objects to extend the functionality of a   object.

The  calls on, which forwards the request to. performs  after forwarding the request to  and returns to, which performs and returns to the.

C++
This implementation is based on the pre C++98 implementation in the book.

The program output is like

Full example can be tested on a godbolt page.

C++
Two options are presented here: first, a dynamic, runtime-composable decorator (has issues with calling decorated functions unless proxied explicitly) and a decorator that uses mixin inheritance.

Static Decorator (Mixin Inheritance)
This example demonstrates a static Decorator implementation, which is possible due to C++ ability to inherit from the template argument.

First example (window/scrolling scenario)
The following Java example illustrates the use of decorators using the window/scrolling scenario.

The following classes contain the decorators for all  classes, including the decorator classes themselves.

Here's a test program that creates a  instance which is fully decorated (i.e., with vertical and horizontal scrollbars), and prints its description:

The output of this program is "simple window, including vertical scrollbars, including horizontal scrollbars". Notice how the  method of the two decorators first retrieve the decorated  's description and decorates it with a suffix.

Below is the JUnit test class for the Test Driven Development

Second example (coffee making scenario)
The next Java example illustrates the use of decorators using coffee making scenario. In this example, the scenario only includes cost and ingredients.

The following classes contain the decorators for all Coffee classes, including the decorator classes themselves.

Here's a test program that creates a Coffee instance which is fully decorated (with milk and sprinkles), and calculate cost of coffee and prints its ingredients:

The output of this program is given below: Cost: 1.0; Ingredients: Coffee Cost: 1.5; Ingredients: Coffee, Milk Cost: 1.7; Ingredients: Coffee, Milk, Sprinkles

Python
The following Python example, taken from Python Wiki - DecoratorPattern, shows us how to pipeline decorators to dynamically add many behaviors in an object:

Note:

The Decorator Pattern (or an implementation of this design pattern in Python - as the above example) should not be confused with Python Decorators, a language feature of Python. They are different things.

Second to the Python Wiki:

The Decorator Pattern is a pattern described in the Design Patterns Book. It is a way of apparently modifying an object's behavior, by enclosing it inside a decorating object with a similar interface. This is not to be confused with Python Decorators, which is a language feature for dynamically modifying a function or class.

Crystal
Output: Cost: 1.0; Ingredients: Coffee Cost: 1.5; Ingredients: Coffee, Milk Cost: 1.7; Ingredients: Coffee, Milk, Sprinkles

C#
Output: Bike: 'Aluminium Bike + Sport Package + Security Package' Cost: 111

Ruby
Output: Cost: 1.0; Ingredients: Coffee Cost: 1.5; Ingredients: Coffee, Milk Cost: 1.7; Ingredients: Coffee, Milk, Sprinkles

title: Decorator pattern


text:
Proxy pattern

In computer programming, the proxy pattern is a software design pattern. A proxy, in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in memory, a file, or some other resource that is expensive or impossible to duplicate. In short, a proxy is a wrapper or agent object that is being called by the client to access the real serving object behind the scenes. Use of the proxy can simply be forwarding to the real object, or can provide additional logic. In the proxy, extra functionality can be provided, for example caching when operations on the real object are resource intensive, or checking preconditions before operations on the real object are invoked. For the client, usage of a proxy object is similar to using the real object, because both implement the same interface.

Overview
The Proxy design pattern is one of the twenty-three well-known GoF design patterns that describe how to solve recurring design problems to design flexible and reusable object-oriented software, that is, objects that are easier to implement, change, test, and reuse.

===What problems can the Proxy design pattern solve? ===

 * The access to an object should be controlled.
 * Additional functionality should be provided when accessing an object.

When accessing sensitive objects, for example, it should be possible to check that clients have the needed access rights.

What solution does the Proxy design pattern describe?
Define a separate  object that
 * can be used as substitute for another object and
 * implements additional functionality to control the access to this subject.

This makes it possible to work through a  object to perform additional functionality when accessing a subject. For example, to check the access rights of clients accessing a sensitive object.

To act as substitute for a subject, a proxy must implement the  interface. Clients can't tell whether they work with a subject or its proxy. See also the UML class and sequence diagram below.

UML class and sequence diagram

In the above UML class diagram, the  class implements the   interface so that it can act as substitute for   objects. It maintains a reference to the substituted object so that it can forward requests to it.

The sequence diagram shows the run-time interactions: The  object works through a  object that controls the access to a  object. In this example, the  forwards the request to the , which performs the request.

Class diagram

Remote proxy
In distributed object communication, a local object represents a remote object (one that belongs to a different address space). The local object is a proxy for the remote object, and method invocation on the local object results in remote method invocation on the remote object. An example would be an ATM implementation, where the ATM might hold proxy objects for bank information that exists in the remote server.

Virtual proxy
In place of a complex or heavy object, a skeleton representation may be advantageous in some cases. When an underlying image is huge in size, it may be represented using a virtual proxy object, loading the real object on demand.

Protection proxy
A protection proxy might be used to control access to a resource based on access rights.

title: Proxy pattern


text:
Command pattern

In object-oriented programming, the command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time. This information includes the method name, the object that owns the method and values for the method parameters.

Four terms always associated with the command pattern are command, receiver, invoker and client. A command object knows about receiver and invokes a method of the receiver. Values for parameters of the receiver method are stored in the command. The receiver object to execute these methods is also stored in the command object by aggregation. The receiver then does the work when the  method in command is called. An invoker object knows how to execute a command, and optionally does bookkeeping about the command execution. The invoker does not know anything about a concrete command, it knows only about the command interface. Invoker object(s), command objects and receiver objects are held by a client object, the client decides which receiver objects it assigns to the command objects, and which commands it assigns to the invoker. The client decides which commands to execute at which points. To execute a command, it passes the command object to the invoker object.

Using command objects makes it easier to construct general components that need to delegate, sequence or execute method calls at a time of their choosing without the need to know the class of the method or the method parameters. Using an invoker object allows bookkeeping about command executions to be conveniently performed, as well as implementing different modes for commands, which are managed by the invoker object, without the need for the client to be aware of the existence of bookkeeping or modes.

The central ideas of this design pattern closely mirror the semantics of first-class functions and higher-order functions in functional programming languages. Specifically, the invoker object is a higher-order function of which the command object is a first-class argument.

Overview
The command design pattern is one of the twenty-three well-known GoF design patterns that describe how to solve recurring design problems to design flexible and reusable object-oriented software, that is, objects that are easier to implement, change, test, and reuse.

Using the command design pattern can solve these problems:
 * Coupling the invoker of a request to a particular request should be avoided. That is, hard-wired requests should be avoided.
 * It should be possible to configure an object (that invokes a request) with a request.

Implementing (hard-wiring) a request directly into a class is inflexible because it couples the class to a particular request at compile-time, which makes it impossible to specify a request at run-time.

Using the command design pattern describes the following solution:

 * Define separate (command) objects that encapsulate a request.
 * A class delegates a request to a command object instead of implementing a particular request directly.

This enables one to configure a class with a command object that is used to perform a request. The class is no longer coupled to a particular request and has no knowledge (is independent) of how the request is carried out.

See also the UML class and sequence diagram below.

UML class and sequence diagram

In the above UML class diagram, the  class doesn't implement a request directly. Instead,  refers to the   interface to perform a request, which makes the   independent of how the request is performed. The  class implements the   interface by performing an action on a receiver. The UML sequence diagram shows the run-time interactions: The  object calls   on a   object. calls  on a   object, which performs the request.

Uses

 * GUI buttons and menu items: In Swing and Borland Delphi programming, an is a command object. In addition to the ability to perform the desired command, an Action may have an associated icon, keyboard shortcut, tooltip text, and so on. A toolbar button or menu item component may be completely initialized using only the Action object.
 * Macro recording: If all user actions are represented by command objects, a program can record a sequence of actions simply by keeping a list of the command objects as they are executed. It can then "play back" the same actions by executing the same command objects again in sequence. If the program embeds a scripting engine, each command object can implement a toScript method, and user actions can then be easily recorded as scripts.
 * Mobile code: Using languages such as Java where code can be streamed/slurped from one location to another via URLClassloaders and Codebases the commands can enable new behavior to be delivered to remote locations (EJB Command, Master Worker).
 * Multi-level undo: If all user actions in a program are implemented as command objects, the program can keep a stack of the most recently executed commands. When the user wants to undo a command, the program simply pops the most recent command object and executes its undo method.
 * Networking: It is possible to send whole command objects across the network to be executed on the other machines, for example player actions in computer games.
 * Parallel processing: Where the commands are written as tasks to a shared resource and executed by many threads in parallel (possibly on remote machines; this variant is often referred to as the Master/Worker pattern)
 * Progress bars: Suppose a program has a sequence of commands that it executes in order. If each command object has a getEstimatedDuration method, the program can easily estimate the total duration. It can show a progress bar that meaningfully reflects how close the program is to completing all the tasks.
 * Thread pools: A typical, general-purpose thread pool class might have a public addTask method that adds a work item to an internal queue of tasks waiting to be done. It maintains a pool of threads that execute commands from the queue. The items in the queue are command objects. Typically these objects implement a common interface such as java.lang.Runnable that allows the thread pool to execute the command even though the thread pool class itself was written without any knowledge of the specific tasks for which it would be used.
 * Transactional behavior: Similar to undo, a database engine or software installer may keep a list of operations that have been or will be performed. Should one of them fail, all others can be reversed or discarded (usually called rollback). For example, if two database tables that refer to each other must be updated, and the second update fails, the transaction can be rolled back, so that the first table does not now contain an invalid reference.
 * Wizards: Often a wizard presents several pages of configuration for a single action that happens only when the user clicks the "Finish" button on the last page. In these cases, a natural way to separate user interface code from application code is to implement the wizard using a command object. The command object is created when the wizard is first displayed. Each wizard page stores its GUI changes in the command object, so the object is populated as the user progresses. "Finish" simply triggers a call to execute. This way, the command class will work.

Terminology
The terminology used to describe command pattern implementations is not consistent and can therefore be confusing. This is the result of ambiguity, the use of synonyms, and implementations that may obscure the original pattern by going well beyond it.
 * 1) Ambiguity.
 * 2) The term command is ambiguous. For example, move up, move up may refer to a single (move up) command that should be executed twice, or it may refer to two commands, each of which happens to do the same thing (move up). If the former command is added twice to an undo stack, both items on the stack refer to the same command instance. This may be appropriate when a command can always be undone the same way (e.g. move down). Both the Gang of Four and the Java example below use this interpretation of the term command. On the other hand, if the latter commands are added to an undo stack, the stack refers to two separate objects. This may be appropriate when each object on the stack must contain information that allows the command to be undone. For example, to undo a delete selection command, the object may contain a copy of the deleted text so that it can be re-inserted, if the delete selection command must be undone. Note that using a separate object for each invocation of a command is also an example of the chain of responsibility pattern.
 * 3) The term execute is also ambiguous. It may refer to running the code identified by the command object's execute method. However, in Microsoft's Windows Presentation Foundation a command is considered to have been executed when the command's execute method has been invoked, but that does not necessarily mean that the application code has run. That occurs only after some further event processing.
 * 4) Synonyms and homonyms.
 * 5) Client, Source, Invoker: the button, toolbar button, or menu item clicked, the shortcut key pressed by the user.
 * 6) Command Object, Routed Command Object, Action Object: a singleton object (e.g. there is only one   object), which knows about shortcut keys, button images, command text, etc. related to the command. A source or invoker object calls the Command or Action object's execute or performAction method. The Command/Action object notifies the appropriate source/invoker objects when the availability of a command/action has changed. This allows buttons and menu items to become inactive (grayed out) when a command/action cannot be executed/performed.
 * 7) Receiver, Target Object: the object that is about to be copied, pasted, moved, etc. The receiver object owns the method that is called by the command's execute method. The receiver is typically also the target object. For example, if the receiver object is a cursor and the method is called , then one would expect that the cursor is the target of the   action. On the other hand, if the code is defined by the command object itself, the target object will be a different object entirely.
 * 8) Command Object, routed event arguments, event object: the object that is passed from the source to the Command/Action object, to the Target object to the code that does the work. Each button click or shortcut key results in a new command/event object. Some implementations add more information to the command/event object as it is being passed from one object (e.g.  ) to another (e.g. document section). Other implementations put command/event objects in other event objects (like a box inside a bigger box) as they move along the line, to avoid naming conflicts. (See also chain of responsibility pattern.)
 * 9) Handler, , method, function: the actual code that does the copying, pasting, moving, etc. In some implementations the handler code is part of the command/action object. In other implementations the code is part of the Receiver/Target Object, and in yet other implementations the handler code is kept separate from the other objects.
 * 10) Command Manager, Undo Manager, Scheduler, Queue, Dispatcher, Invoker: an object that puts command/event objects on an undo stack or redo stack, or that holds on to command/event objects until other objects are ready to act on them, or that routes the command/event objects to the appropriate receiver/target object or handler code.
 * 11) Implementations that go well beyond the original command pattern.
 * 12) Microsoft's Windows Presentation Foundation (WPF), introduces routed commands, which combine the command pattern with event processing. As a result, the command object no longer contains a reference to the target object nor a reference to the application code. Instead, invoking the command object's execute command results in a so-called Executed Routed Event that during the event's tunneling or bubbling may encounter a so-called binding object that identifies the target and the application code, which is executed at that point.

Example
This C++14 implementation is based on the pre C++98 implementation in the book.

The program output is

History
The first published mention of using a Command class to implement interactive systems seems to be a 1985 article by Henry Lieberman. The first published description of a (multiple-level) undo-redo mechanism, using a Command class with execute and undo methods, and a history list, appears to be the first (1988) edition of Bertrand Meyer's book Object-oriented Software Construction, section 12.2.

title: Command pattern