Newsletter sign-up
View all newsletters

Sign up for our Enterprise Java Newsletter

Enterprise Java
JavaWorld Daily Brew

Very Good


Back to:
www.javaworld.com/javaworld/javatips/jw-javatip68.html
.

HI This is very good topic and neatly explained. The Code cleared lot of doubts as to how it actually works. But please i cant load the class from the Command Manager even using the Thread.CurrentThread().getContextClassLoader() it says ClassNotFoundException please help.

Your rating: None Average: 3.5 (2 votes)

Not Very Good

I don't see that this article credits the book "Head First Design Patterns" The examples are nearly identical. They invented the switch to explain the command pattern.

Check the dates

This Java Tip was published in 1999; Head First Design Patterns came out in 2004.

Athen

political science

how to learn plz help me actully i never remember the thing nd topic.

excellent topic

very very informative and cleared all my doubts. Thank you very much for your effort

Addressing return values from Execute method

Thank you for the article.
It seems though, that with this pattern nobody addresses the values returned from the Execute() method. Just seems strange that someone calls "Add" method and expects no return.

Very good article

Nice article! It explains everything to make a beginner understand this design pattern.

Nice article, but violates basic principles of reknown OO expert

Accord to Holob, TestCommand.java should only know about the Fan and Light classes. This would be the case, regardless of whether the Command Pattern was being used or not. The Fan is the only thing that needs to know that it has a Switch. Likewise, with the Light. If TestCommand wants to turn on a Light, it sends a message (i.e. invokes a methd on) to the Light, asking it to do that. If the Light use a Switch to turn itself on and off, so be it. TestCommand shouldn't know or care about how the Light turns itself on and off, which means it shouldn't know or care if the Light has a Switch or not. Same with the Fan.

Absolutely fantastic!!

Have gone through so many articles on command pattern, each time I knew something was missing till I chanced upon this one. Absolutely brilliant!! Thank you so much!

to Know Java Pattens And Factory Methords

pls send pdf formate and examples

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <p> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br /> <br> <strike>
  • Lines and paragraphs break automatically.
  • Use <!--pagebreak--> to create page breaks.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
Just checking to see if you're an actual person rather than a spammer. Sorry for the inconvenience.