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 684547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:49:43+00:00 2026-05-14T01:49:43+00:00

I have a functional AdjacencyListGraph class that adheres to a defined interface GraphStructure. In

  • 0

I have a functional AdjacencyListGraph class that adheres to a defined interface GraphStructure. In order to layer limitations on this (eg. acyclic, non-null, unique vertex data etc.), I can see two possible routes, each making use of the GraphStructure interface:

  1. Create a single class (“ControlledGraph”) that has a set of bitflags specifying various possible limitations. Handle all limitations in this class. Update the class if new limitation requirements become apparent.

  2. Use the decorator pattern (DI, essentially) to create a separate class implementation for each individual limitation that a client class may wish to use. The benefit here is that we are adhering to the Single Responsibility Principle.

I would lean toward the latter, but by Jove!, I hate the decorator Pattern. It is the epitome of clutter, IMO. Truthfully it all depends on how many decorators might be applied in the worst case — in mine so far, the count is seven (the number of discrete limitations I’ve recognised at this stage). The other problem with decorator is that I’m going to have to do interface method wrapping in every… single… decorator class. Bah.

Which would you go for, if either? Or, if you can suggest some more elegant solution, that would be welcome.

EDIT: It occurs to me that using the proposed ControlledGraph class with the strategy pattern may help here… some sort of template method / functors setup, with individual bits applying separate controls in the various graph-canonical interface methods. Or am I losing the plot?

  • 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-05-14T01:49:44+00:00Added an answer on May 14, 2026 at 1:49 am

    Ah, I see it now. The strategy pattern in a ControlledGraph class is indeed the way to go.

    Each limitation is a discrete strategy class. Each of these implements the entire GraphStructure interface, although most methods will be left empty (eg. an acyclic limitation is only interested in using addEdge() to prevent cycle insertions, others methods will be left empty).

    Each time the ControlledGraph has one of its interface methods called, it will call the matching methods of each of the strategies/limitations it contains. It may hold only one of each type of strategy, obviously.

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

Sidebar

Related Questions

I have hierarchy of functional tests like this [TestClass] class BaseClass { // specific
I have a functional datagrid that responds to itemClick events. Everything works, except that
I have a functional JSP page that accepts URL parameters and updates a table
In Vaadin's website it says that only Eclipse and NetBeans have fully functional (which
I have created some functional categories that I use to show/hide markup elements. However,
I have some functional code that I'm trying to speed up by eliminating the
I have created a functional OOP program that uses a bunch of classes, and
So I have made this simple interface: package{ public interface GraphADT{ function addNode(newNode:Node):Boolean; }
I have two functional fields in OpenERP that are not stored in the db.
I have a fully-functional Java program that's fairly long, and I want to transfer

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.