Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem.
4
votes
2answers
169 views
Preventing Liskov Substitution violation
I am reimplementing some component and noticed that the original version has a Liskov Substitution violation. It's not all that critical, though I'd like to get rid of it in the new implementation . ...
4
votes
3answers
340 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 ...
0
votes
3answers
155 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
343 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
92 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 ...
1
vote
1answer
170 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 ...
3
votes
1answer
223 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 ...
5
votes
7answers
430 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 ...
3
votes
1answer
158 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
107 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
133 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
114 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 ...
0
votes
3answers
480 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
52 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
61 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
138 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 ...
4
votes
5answers
503 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
1answer
107 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
122 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
250 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
336 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 ...
8
votes
4answers
223 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
146 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 ...
1
vote
6answers
360 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
186 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) ...
0
votes
1answer
153 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. ...
0
votes
0answers
144 views
How to learn to deliver quality software designs when working on a tight deadline? [closed]
I read many books about how to design great software, but I kind of struggle to come up with a good design decisions when it comes to business apps, especially when the timeframe is tough.
In the ...
0
votes
1answer
69 views
Objected oriented approach to structure inside structure [closed]
This is for C++ but should apply to any OO language.
Trying to figure out the correct object oriented apporach to do the following (this is what I do in C).
struct Container {
enum type;
union {
...
3
votes
3answers
225 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 ...
1
vote
2answers
326 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
173 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
208 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
187 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
2answers
242 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
166 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
225 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
93 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
171 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
178 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
98 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
162 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 ...
6
votes
6answers
1k 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
138 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
231 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 ...
3
votes
3answers
412 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
136 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 ...
3
votes
2answers
311 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 ...
5
votes
1answer
130 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 ...
17
votes
4answers
657 views
Do unit tests sometimes break encapsulation?
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 ...
9
votes
7answers
895 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 ...