oop

designing business msgs parser / rewriting from scratch

I take care of critical app in my project. It does stuff related to parsing business msgs (legacy standard), processing them and then storing some results in a DB (another apps picks that up). After more then a year of my work (I've other apps to look after as well) the app is finally stable. I've introduced strict TDD policy and I have ...

Problem with inheritance in C++

Here's my problem: I have a virtual method defined in a .h file that I want to call in a class that inherits from the base class. Sadly though, the method in the derived class doesn't get called. Is there a better way to implement what I'm trying to do? #ifndef ofxBASE_SND_OBJ #define ofxBASE_SND_OBJ #include "ofConstants.h...

prototypes versus classes

Steve Yegge recently posted an interesting blog post on what he calls the universal design pattern. In there he details using prototypes as a modelling tool, instead of classes. I like the way this introduces less coupling compared to inheritance. But that is something one can get with classes as well, by implementing classes in terms of...

How to best visualize a "permission Matrix" in an UML class diagram?

For the sake of simplicity: There is a permission based system in place with different kinds of user levels and actions (think: UNIX file system permissions) What would be the best approach to visualize this in UML? ...

Define an interface method that takes different parameters

My application uses measurement instruments that are connected to the PC. I want to make it possible to use similar instruments from different vendors. So I defined an interface: interface IMeasurementInterface { void Initialize(); void Close(); } So far so good. Before a measurement I need to setup the inst...

Should this property be part of my object's interface?

I have a property called "IsSecureConnection" that is part of my object's interface. This makes sense for most implementations of the interface, however, in some implementations I would like to make the property ReadOnly. Should I omit this property from the object's interface even though it is required by all of the implementations ...

How can I make an interface property optionally read-only in VB.NET?

This is a follow-up to a previous question I had about interfaces. I received an answer that I like, but I'm not sure how to implement it in VB.NET. Previous question: http://stackoverflow.com/questions/239909/should-this-property-be-part-of-my-objects-interface public interface Foo{ bool MyMinimallyReadOnlyPropertyThatCanAlsoBeRea...

Why would I want to use Interfaces?

I understand that they force you to implement methods and such but what I cant understand is why you would want to use them. Can anybody give me a good example or explanation on why I would want to implement this. ...

Accessing more than one data provider in a data layer

I'm working on a business application which is being developed using DDD philosophy. Database is accessed through NHibernate and data layer is implemented using DAO pattern. The UML class diagram is shown below. http://img266.imageshack.us/my.php?image=classdiagramhk0.png I don't know the design is good or not. What do you think? B...

Learning/Implementing Design Patterns (For Newbies)

I'm a confused newbie and hobbyist programmer trying to get a grip on this, so forgive me if my question is a little off or doesn't make much sense. I see a lot of questions on SO revolving around the use of design patterns, and I'm wondering if anyone has a good resources for learning about, and implementing design patterns? I understa...

Best practices for managing several specialized versions of one app

I have a web application that has many faces and so far I've implemented this through creating themes. A theme is a set of html, css and images to be used with the common back end. Things are laid out like so: code/ themes/theme1 themes/theme2 And each instance of the web application has a configuration file that states which theme ...

OOP Problems to use for Coding Tests during interviews

As a second interview I get people to sit down and write code...I try to make the problem really technology independent. My programming problems that I have don't really exercise peoples OO abilities. I tend to try and keep the coding problem solvable within 2 hours ish. So, I've struggled to find a problem small enough and involved e...

How do you define a Single Responsibility?

I know about "class having a single reason to change". Now, what is that exactly? Are there some smells/signs that could tell that class does not have a single responsibility? Or could the real answer hide in YAGNI and only refactor to a single responsibility the first time your class changes? ...

What is the equivalent of .NET events in Ruby?

The problem is very simple. An object needs to notify some events that might be of interest to observers. When I sat to validate a design that I cooked up now in Ruby just to validate it.. I find myself stumped as to how to implement the object events. In .Net this would be a one-liner.. .Net also does handler method signature verificat...

How do you balance Framework/API Design and TDD

We are building a framework that will be used by other developers and for now we have been using a lot of TDD practices. We have interfaces everywhere and have well-written unit tests that mock the interfaces. However, we are now reaching the point where some of the properties/methods of the input classes need to be internal, and not v...

Database Guy Asks: Object-Oriented Design Theory?

I've worked with designing databases for a loooong time, and these days I'm working in C# too. OO makes sense to me, but I don't feel that I have a good grounding in the deep theory of OO design. In database land, there's a lot of theory around how to design the structure of a database, the main notion being normalisation. Normalisa...

When is Object Oriented not the correct solution?

I've encountered lately some opinions saying that Object Oriented design/programming should not always be used. Do you know some use-cases that will not benefit from and should not use Object Oriented design? For example: there are some problems (concerns) that will benefit from AOP. ...

Removing repeated conditions using polymorphism and the Factory pattern

<?php /** * My codebase is littered with the same conditionals over and over * again. I'm trying to refactor using inheritance and the Factory * pattern and I've had some success but I'm now stuck. * * I'm stuck because I want to derive a new class from the one * returned by the Factory. But I can't do that, so I'm obviously * d...

Matlab copy constructor

Hi, Is there a better way to implement copy construcor for matlab for a handle derived class other than adding a constructor with one input and explicitly copying its properties? obj.property1 = from.property1; obj.property2 = from.property2; etc. Thanks, Dani ...

Recommendations for how to do OOP design

I find that whenever I begin writing an app in Java/C#, things start off good, but over time, as the app becomes more complex, it just gets more and more complicated. I've become aware of the fact that I'm not very good at design and high level architecture. All my classes become fairly strongly coupled and the design isn't "elegant" a...