Questions tagged [hierarchy]

50 questions
98
votes
12 answers

My client wants 25% of comments in my current project, how to react?

junior developer here. I am currently working alone on a web application for a big client of my company. I started last month. The client wants at least 25% of comments in each of its software projects. I checked the code of previous applications…
Robin_
  • 553
  • 1
  • 4
  • 9
16
votes
5 answers

How to make a datatype for something that represents either itself or two other things

Background Here's the actual problem I'm working on: I want a way to represent cards in the card game Magic: The Gathering. Most cards in the game are normal-looking cards, but some of them are divided into two parts, each with its own name. Each…
codebreaker
  • 1,694
  • 1
  • 18
  • 24
13
votes
3 answers

How can you tell whether to use Composite Pattern or a Tree Structure, or a third implementation?

I have two client types, an "Observer"-type and a "Subject"-type. They're both associated with a hierarchy of groups. The Observer will receive (calendar) data from the groups it is associated with throughout the different hierarchies. This data is…
Aske B.
  • 239
  • 3
  • 8
9
votes
1 answer

In MVC should a model contain subview models?

Some background: A colleague and myself have different interpretations of MVC which means, given the same problem, we are coming up with radically different solutions. He comes from a Java background where every component of MVC may traditionally…
kvanbere
  • 195
  • 1
  • 8
8
votes
3 answers

DDD: Is an aggregate root responsible for deleting its child entities from their repository?

I am developing a large software project using DDD (Domain-Driven Design). I have an entity that acts as an aggregate root, let's call it Root. This entity refers to a collection of child entities of the type Child. Because the use of this Child…
Subsurf
  • 231
  • 1
  • 3
  • 6
6
votes
3 answers

Handling retroactively adjusted data that is reported hierarchically

Several of our customers have come to us with an interesting problem that involves adjusting data that occurred in the past which is rolled up and reported based on an org hierarchy. For example: If you run a report by "Sales Team" in March it will…
Vyrotek
  • 161
  • 5
6
votes
3 answers

What would be a good approach to generate a tree of folders?

Say I have an array of strings, like this: var folders = new[] { "Foo", "Bar", "Foo\Bar" "Foo\Bar\Baz" }; And that I have an object that represents a folder - something like this: class Folder { private readonly string _name; …
6
votes
1 answer

Should I always throw the most specific or should I try to generalize exception types?

Say you normally have FooException. /** * @throw FooException If Foo is invalid for searching. */ public bool exists(Foo a) But at some point you need to have two more specific exceptions for Foo. /** * @throw FooSearchException (extends…
Wes
  • 832
  • 5
  • 12
6
votes
3 answers

Reducing dependency cycles and reducing coupling

I'm trying to learn how to produce quality object-oriented code and have been studying concepts like SOLID. I'm currently working on an entity-component-process system for a small game engine. Currently, I have it implemented as such: There is a…
6
votes
2 answers

Are there established algorithms for spacing out objects of unequal size?

I'm working on visualizing a hierarchy. There will be clusters of objects, each cluster containing rectangles of fixed width but variable height. I'd like to arrange these within a rectangular space so as to have equal visual spacing between them,…
user25946
6
votes
2 answers

Should exceptions of a subclass extend the superclass exceptions or my own namespace?

Our library extends another (third-party) library. When we create a child class in our library, and want to throw exceptions, should those exceptions extend the exceptions from the parent class or from our own namespace? For example: class…
cmbuckley
  • 163
  • 5
5
votes
1 answer

Contract / Project / Line-Item hierarchy design considerations

We currently have an application that allows users to create a Contract. A contract can have 1 or more Project. A project can have 0 or more sub-projects (which can have their own sub-projects, and so on) as well as 1 or more Line. Lines can have…
Thelonias
  • 153
  • 5
4
votes
3 answers

Is this OOP class hierarchy too deep?

So I am making a Super Mario Bros NES clone in pygame and for all enemies that are drawn to the window, I have a class hierarchy that is 5 classes deep. Going in the order of: Object (A base class for all things drawn on the screen) Character (A…
Robbie
  • 222
  • 2
  • 8
4
votes
2 answers

Should package structure closely resemble class hierarchy?

Pretty simple question. Should package structure closely resemble class hierarchy? If so, how closely? Why or why not? For instance, let's say you've got class A and class B, plus class AFactory and class BFactory. You put class A and class B in…
Panzercrisis
  • 3,145
  • 4
  • 19
  • 34
3
votes
1 answer

How can I provide a class diagram for a system that contains creation of an object that contains a combination of property?

I am designing a system that contains organizational hierarchy management. There are four roles in the system which are the user, admin, manager and head of procurement: I am trying to let the admin of each organization create his own hierarchy…
1
2 3 4