0
votes
0answers
34 views

Reporting Logic vs Domain Logic

Should the reporting logic to extract domain data in a certain format reside in domain objects or separate reporting objects? The reporting logic needs to: select entities/data which match selection ...
1
vote
2answers
106 views

System Communication: Avoiding Including a Large “HAS-A” Hierarchy Which Isn't Used

The situation: System A Huge, complicated system. Uses an important Message object with many other Message objects attached, many of which have further Message objects attached. In total, this is ...
0
votes
1answer
70 views

how to manage new private variables introduced into class?

Whenever I want to add a new functionality, I introduce a new private variable into the class. Declare it just above the first method definition. leave a small comment. Set it in a certain method. And ...
24
votes
10answers
6k views

Can we live without constructors?

Let's say in some reason all objects are created this way $obj = CLASS::getInstance(). Then we inject dependencies using setters and perform starting initialization using $obj->initInstance(); Are ...
13
votes
6answers
2k views

Should a class know about its subclasses?

Should a class know about its subclasses? Should a class do something that is specific for a given subclass for instance? My instincts tells me that is a bad design, it seems like an anti-pattern of ...
1
vote
0answers
356 views

JavaScript Class Module: How to avoid an antipattern

I've seen a number of different methodologies when it comes to applying class-based inheritance to JS/ECMA-based projects. Over the past several months, I've been applying IIFE Namespaces to my class ...
0
votes
1answer
221 views

Code design: is this specific case of monkeypatching in python acceptable?

I'm using python to do some research tasks. I have a class hierarchy for "tools", where each object is an instance of a particular tool. They all share some functionality and have many similarities in ...
0
votes
3answers
465 views

Have Superclass Contain List of Subclass?

For the GUI of a program, I want it to list several items, all of which are, from a programming side, just subclasses. They can add one of these items to a list. I don't want to hard-code which ...
2
votes
2answers
1k views

When to use inheritance or composition/aggregation?

In general, how do I decide whether to use make a class a super class, or to make it a private data member of another class? For example, given two classes, how does one decide whether to do this: ...
2
votes
2answers
219 views

Strategies for invoking subclass methods on generic objects [duplicate]

Possible Duplicate: Alternatives to type casting in your domain I've run into this issue in a number of places and have solved it a bunch of different ways but looking for other solutions ...
2
votes
2answers
2k views

DB Object passing between classes singleton, static or other?

So I'm designing a reporting system at work it's my first project written OOP and I'm stuck on the design choice for the DB class. Obviously I only want to create one instance of the DB class ...
6
votes
10answers
482 views

Teaching Classes and Objects

I'm trying to teach how an object is just an instance of a class to a buddy of mine. However, he doesn't seem to understand it so well. I've heard a ton of the examples (blueprint to a house, etc.) ...
3
votes
3answers
351 views

Is partial classes modern Subject-Oriented programming?

Important discussion follows: C# and other language have made partial classes more popular. But isn't this really a tool that have reinvented the subject-orientated programming wheel? What do you ...
11
votes
9answers
4k views

When should you use a private/inner class?

To clarify, what I'm asking about is public class A{ private/*or public*/ B b; } vs. public class A{ private/*or public*/ class B{ .... } } I can definitely think of some ...
10
votes
2answers
696 views

Design: Object method vs separate class's method which takes Object as parameter?

For example, is it better to do: Pdf pdf = new Pdf(); pdf.Print(); or: Pdf pdf = new Pdf(); PdfPrinter printer = new PdfPrinter(); printer.Print(pdf); Another example: Country m = new ...