Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem.

learn more… | top users | synonyms

4
votes
3answers
454 views

Novel polymorphism - any reasons for this code?

As part of my work on a legacy C# application I've come across a novel (to me) use of an interface & concrete implementations. I can't think of any reason why you'd do the following, but I'm ...
1
vote
3answers
417 views

C# dynamics and Expando object [closed]

Under which application development scenarios C# dynamics and ExpandoObject can be used or when to consider using c# dynamics and ExpandoObject
7
votes
7answers
998 views

Is a pair of two tightly coupled classes any better than a single, larger class?

I'm rewriting somebody else's code at the minute, and I came across two classes which reference each other directly and call methods on each other. Like so (example in C#): class A { B otherClass; ...
3
votes
2answers
135 views

Does this situation call for well specified associations, single table inheritance, or polymorphic association?

I'm building a web-app where users can keep track of who owes whom money. I have users and debts. Given a user I want to be able to find out all the debts to other users, and all the loans to other ...
3
votes
3answers
524 views

Possible with PHP MVC Framework? A better solution to client 'override' of core functionality?

Background / The Problem I need to make a (large) application with a certain set of core functionality, and certain functionality for multiple clients within it. Each client has different ...
7
votes
6answers
735 views

Design guidelines for this scenario in C#?

I have to create a validation system(I don't want to use Data Annotation or any other system) for my C# application using .Net Compact Framework, where I have an object which contains many other ...
7
votes
7answers
3k views

Should I create interfaces for data transfer objects?

Is it a good idea or a bad idea to create an interface for data transfer objects? Presuming that the object is usually mutable. Though my example is in Java, it should be applicable to any other ...
4
votes
1answer
574 views

MVC Pattern - How to get errors from the model to the controller?

Say I have a typical MVC setup. The controller passes on some input to the model, and asks it to do something with it. But the validation of the data fails, or there is some other problem. What's the ...
2
votes
2answers
178 views

Changing __class__ in a factory?

I'm parsing a set of XML files of different kinds (these kinds are known in advance). These are my requirements: I want an object to represent each XML document (object-xml mapping) I'd rather ...
3
votes
3answers
891 views

Visitor stability vs instanceof flexibility

I am writing on a GUI program which allows for the visual creation of some configuration file. I have a class hierarchy for the configuration model and I use an object tree of that hierarchy in ...
3
votes
2answers
170 views

Automated object creation from user input

I am working on a command-line application that runs simulations. It has to be heavily configurable; the user should be able to provide a very large number (100+) of parameters, some mandatory and ...
1
vote
3answers
884 views

Is function overloading in general considered Evil? [closed]

Recently I found about two new programming languages(Vala and google's GO) which don't support method or function overloading and intend on not supporting them in the future ever! The creators of ...
0
votes
1answer
71 views

terminology for upward devolution from modules to framework

Is there a word for the problem of a framework becoming married to the software modules it supports, for example adding methods to a base class that may apply only to certain subclasses or use cases? ...
1
vote
1answer
82 views

How to get a reference to a central AssetLoader in every Widget?

I'm working on a simple UI system for a game. The building blocks are Widget objects, which can contain each other. There are several sub classes of Widget, e.g. LabelWidget, ImageWidgetand ...
4
votes
1answer
199 views

Can a common interface be defined for Cartesian and Polar coordinate data?

I'm rewriting a set of file readers that a former-colleague of mine created that read raw-point data of XYZ (Cartesian) coordinates or RTZ (Polar) coordinates. Currently the data is stored directly in ...
7
votes
7answers
5k views

OO Design related questions in technical interviews

I've been attending quite a few interviews recently and have been asked by companies to answer "design a [insert model]" questions more than a few times. Is this normal in the industry nowadays? ...
2
votes
0answers
386 views

Why does Java's Collections.unmodifiableList return a List interface instead of an UnmodifiableList interface? [duplicate]

Possible Duplicate: Why were Java collections implemented with “optional methods” in the interface? I was looking at the javadoc for Collections and I noticed the ...
1
vote
1answer
149 views

How to share common methods if objects have different roles?

If 2 classes have the following in common: part of how their state is represented (both have a linear container) multiple identical methods (identical code, not just signature) But are not ...
2
votes
4answers
1k views

Good design pattern for a c++ wrapper around a c object

I have written an extensible c++ wrapper around a very hard to use but also very useful c library. The goal is to have the convience of c++ for allocating the object, exposing its properties, ...
1
vote
2answers
414 views

Have I understood OOP correctly?

I had originally posed this on StackOverflow. The question was closed and I was asked to post this here instead. Here is the original question I had posted there: I have been programming using ...
9
votes
4answers
515 views

Good implementation strategies for encapsulating shared data in a software pipeline

I'm working on re-factoring certain aspects of an existing web service. The way the service APIs are implemented is by having a kind of "processing pipeline", where there are tasks that are performed ...
2
votes
2answers
302 views

Architecture Best Practice (MVC): Repository Returns Object & Object Member Accessed Directly or Repository Returns Object Member

Architecturally speaking, which is the preferable approach (and why)? $validation_date = $users_repository->getUser($user_id)->validation_date; Seems to violate Law of Demeter by accessing ...
4
votes
6answers
3k views

What are abstract classes and abstract methods?

I got several explanations but so far I'm not able to understand that what are the abstract classes and methods in Java. Some said it has to do something with the security of the program, other said ...
1
vote
3answers
196 views

Inheritance from the objects themselves

Making new inheritance hierarchy with the help of C++ I think about: Why there is no inheritance from the class objects? Abstract example (on abstract C++): struct Foo { int v; Foo(int a) : v(a) ...
1
vote
1answer
412 views

Liskov substitution and abstract classes / strategy pattern

I'm trying to follow LSP in practical programming. And I wonder if different constructors of subclasses violate it. It would be great to hear an explanation instead of just yes/no. Thanks much! P.S. ...
3
votes
3answers
399 views

Override methods should call base method?

I'm just running NDepend against some code that I have written and one of the warnings is Overrides of Method() should call base.Method(). The places this occurs are where I have a base class which ...
2
votes
2answers
3k views

How to design a scalable notification system? [closed]

I need to write a notification system manager. Here is my requirements: I need to be able to send a Notification on different platforms, which may be totally different (for exemple, I need to be ...
1
vote
3answers
207 views

OOD: All classes at bottom of hierarchy contain the same field

I am creating a class diagram for what I thought was a fairly simple problem. However, when I get to the bottom of the hierarchy, all of the classes only contain one field and it is the same one. ...
3
votes
4answers
306 views

Representing complex object dependencies

I have several classes with a reasonably complex (but acyclic) dependency graph. All the dependencies are of the form: class X instance contains an attribute of class Y. All such attributes are set ...
1
vote
1answer
1k views

Use decorator and factory together to extend objects?

I'm new to OOP and design pattern. I've a simple app that handles the generation of Tables, Columns (that belong to Table), Rows (that belong to Table and have Columns) and Values (that belong to ...
3
votes
1answer
481 views

Too complex/too many objects?

I know that this will be a difficult question to answer without context, but hopefully there are at least some good guidelines to share on this. The questions are at the bottom if you want to skip the ...
0
votes
2answers
290 views

Examples of Liskov Substitution [closed]

I'm facilitating a session next week on the Liskov Substitution Principle and I was wondering if anyone had any examples of violations 'from the trenches'? I'm looking for something other than uncle ...
6
votes
4answers
255 views

Do functional generics exist and what is the correct name for them if they do?

Consider the following generic class: public class EntityChangeInfo<EntityType,TEntityKey> { ChangeTypeEnum ChangeType {get;} TEntityKeyType EntityKey {get;} } Here EntityType ...
0
votes
1answer
312 views

would a composite design pattern be useful for group membership?

I'm trying to think about the best way to handle group memberships on a website. People sign up and select checkboxes in a list of interests. Every week we send out interest-themed emails to those ...
1
vote
3answers
228 views

Should I use an interface when methods are only similar?

I was posed with the idea of creating an object that checks if a point will collide with a line: public class PointAndLineSegmentCollisionDetector { public void Collides(Point p, LineSegment s) { ...
1
vote
2answers
580 views

REST API wrapper - class design for 'lite' object responses

I am writing a class library to serve as a managed .NET wrapper over a REST API. I'm very new to OOP, and this task is an ideal opportunity for me to learn some OOP concepts in a real-life situation ...
2
votes
2answers
222 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 ...
4
votes
6answers
182 views

Where should I put a method that returns a list of active entries of a table?

I have a class named GuestbookEntry that maps to the properties that are in the database table named "guestbook". Very simple! Originally, I had a static method named getActiveEntries() that ...
8
votes
6answers
5k views

What are the differences between abstract classes, interfaces, and when to use them

Recently I have started to wrap my head around OOP, and I am now to the point where the more I read about the differences between abstract classes and interfaces the more confused I become. So far, ...
0
votes
2answers
169 views

When modeling a virtual circuit board, what is the best design pattern to check for cycles?

To make it simple assume you have only AND and OR gates. Each has two inputs and one output. The output of two inputs can be used as an input for the next gate For example: A AND B -> E C AND D -> F ...
4
votes
1answer
693 views

Why doesn't Java's BigInteger class have a constructor capable of taking a numeric literal? [closed]

Why doesn't Java's BigInteger class have a constructor capable of taking a numeric literal? Every single time I use BigIntegers, and many times I merely think about them, I wonder this. What reason ...
2
votes
3answers
664 views

What kind of programs/solutions can only be written with OOP or are too hard to achieve without it? [closed]

Paraphrasing a recent question: What is Object Oriented Programming ill-suited for? I would like to ask the opposite question: What kind of programs cannot be written unless you use OOP? What kind ...
2
votes
2answers
390 views

design a model for a system of dependent variables

I'm dealing with a modeling system (financial) that has dozens of variables. Some of the variables are independent, and function as inputs to the system; most of them are calculated from other ...
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 ...
4
votes
1answer
255 views

Object oriented wrapper around a dll

So, I'm writing a C# managed wrapper around a native dll. The dll contains several hundred functions. In most cases, the first argument to each function is an opaque handle to a type internal to the ...
21
votes
5answers
2k views

Do unit tests sometimes break encapsulation? [duplicate]

I very often hear the following: "If you want to test private methods, you'd better put that in another class and expose it." While sometimes that's the case and we have a hiding concept inside our ...
18
votes
8answers
2k views

What can go wrong if the Liskov substitution principle is violated?

I was following this highly voted question on possible violation of Liskov Substitution principle. I know what the Liskov Substitution principle is, but what is still not clear in my mind is what ...
71
votes
7answers
5k views

Is this a violation of the Liskov Substitution Principle?

Say we have a list of Task entities, and a ProjectTask sub type. Tasks can be closed at any time, except ProjectTasks which cannot be closed once they have a status of Started. The UI should ensure ...
1
vote
1answer
177 views

Object behaviour or separate class?

When it comes to OO database access you see two common approaches - the first is to provide a class (say "Customer") with methods such as Retrieve(), Update(), Delete(), etc. The other is to keep the ...
52
votes
10answers
3k views

My proposed design is usually worse than my colleague's - how do I get better? [closed]

I have been programming for couple of years and am generally good when it comes to fixing problems and creating small-to-medium scripts, however, I'm generally not good at designing large scale ...