Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7761725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:12:38+00:00 2026-06-01T14:12:38+00:00

Edit: I can use Actionscript 3.0 and/or Java I have a bit of a

  • 0

Edit: I can use Actionscript 3.0 and/or Java

I have a bit of a problem with the decorator class. I want to be able to decorate a subclass of a subclass of the abstract class.

To clarify; I have the abstract weapon class, which an abstract sword class extends. Then, finally a concrete long sword class extends it. I want to be able to decorate the long sword class.

                                   Weapon <-------------Enchant "Decorator
                                     /\                  /   \
                                    /  \        "+3 damage"|"Paralyze"
                                   /    \                  V
"Abstract Components":       Sword    |    Axe    "Concrete Decorators" 
                              / \         /    \
                             /   \       /      \
"Concrete Components": LongSword|Short RedAxe| WarAxe "Apply Decorators Here"

Currently all the books I’ve read about design patterns deals with “one layer” Decorations, e.g:

                                        Weapon <-------------Enchant "Decorator
                                         /\                  /   \
                                        /  \        "+3 damage"|"Paralyze"
                                       /    \                  V
  "Concrete components already":    Sword | Axe      "Concrete Decorators"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:12:40+00:00Added an answer on June 1, 2026 at 2:12 pm

    In static languages like Java, C++ and (I presume) C#, you can’t create a decorator for a class and use it to decorate subclasses of that class. Well you can, but the effect is to hide the functionality of the subclass.

    I guess what you want is to be able to mix-and-match decorators, where each decorator could be for the object’s class or one of its ancestors.

    In the dynamic languages e.g., perl and ruby, you can define or redefine an individual method of an individual object, and you could theoretically use this to peform decoration on subclasses.

    Assuming you’re constrained by a static language, my suggestion is this: For each kind of enchantment your want to have, create a Modifier base class or interface, and then create concrete classes for each enchantment. Then in each object, have a list of modifiers of each class/interface, and run through them as necessary to, say, calculate damage.

    The closest analogous patterns are Strategy or Template Method.

    I have translated your question in my mind to “How would one implement the item modifier system used in the Diablo games?”. There are many issues to consider – saving and restoring state, and interactions between modifiers, are just two that occur to me now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read posts about why you can't have a (Edit -- generic) (which use
If I use stored procedures, can I use an ORM? EDIT: If I can
Ok, i can use jeditable to edit-in-place some content on a page and the
How can I use the standard Edit menu in my Palm OS application, instead
Solution Edit: Turns out you can't use the PHP SDK to return the correct
I have run into a problem attempting to redispatch mouse events in ActionScript 3,
i'm using a main form and edit form, and i want to use the
I have an existing PDF and I can use FdFWriter to input to text
Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some
Edit: We can close. Isn't truly asynchronous, non-blocking javascript impossible? var PATH = require

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.