oop

Single class with multiple constructor parameter values or many classes?

I have a class Response which contains a HTTP response with a HTTP status code like 200 or 404 and few other things like a view name and a domain object. But lets focus on the status code. I could use a single class and pass the status as a parameter: public class Response { private int status; public Response(int status) { this...

DDD: Address as an aggregate root?

I’m struggling designing this system where an address is the most central piece of information. Now in this case, an address is not just a few lines of strings. We’re storing municipalities (code, name), district (post code, name), streets (code, name), house number on a street in a specific district belonging to a municipal. It's a very...

oo program vs business rules changes

I am maintaining a custom built and highly OO e-commerce application. The original designer made a few assumptions like: - there will never be more than 3 types of sales tax (state, national & hamonized) - each type of sales tax can have only one rate. - each state will be assigned one of the three tax types. He should have known b...

Is the C programming language object-oriented?

I was talking with a co-worker about C and C++ and he claimed that C is object-oriented, but I claimed that it was not. I know that you can do object-oriented-like things in C, but C++ is a true object-oriented language. What are your thoughts? Also, it triggered discussion on who decides what it means to be object-oriented and that i...

How to catch any method call on object in PHP?

Hi, I am trying to figure out, how to catch any method call on object in PHP. I know about magic function __call, but it is triggered only for method, that does not exist on called object. For example i have something like this: class Foo { public function bar() { echo 'foobar'; } public function override($method_name,$met...

Active Directory Class Library

I've got the following setup in one library: BaseObject ObjectGuid ObjectClasses DisplayName CreatedDate (etc) User : BaseObject Surname MemberOf etc Group : BaseObject ... Computer : BaseObject ... Now I'm trying to create another library with a "Connector" class that communicates with Active Directory. One of its static memb...

How to communicate between classes when both data and UI are involved?

I'm working on a largely navigation-based iPhone app that communicates with a REST API using OAuth, and I'd like to know how my classes should best communicate with each other. I've got multiple UITableViews, multiple UITableViewDataSources, an API class, and a view controller that handles authentication in a web view. Here's how I hav...

Passing objects and object oriented design best practices

I'm a university student learning programming. For practice I'm writing a blackjack program. I'm using C++ and doing an object oriented approach to this. I have a Deck class designed that basically builds and shuffles a deck of cards. The deck generated is composed of an array of 52 Card class objects. That's what I have so far. My pl...

Can do procedural PHP, want to do JavaScript, need to do OOP PHP first?

Here's a bit of a twist on the old which do I learn first question you've read a million times before... I began learning PHP last fall and feel I have become fairly competent in procedural PHP programming. As my site - the driving reason for these studies - has developed I've reached a point where learning OOP PHP would make for clean...

How can I make this application re-usable?

I made a .NET Windows form that allows users to view a particular document and sign it. I want to make it re-usable for future applications. The challenges are: The text to be signed requires parameters. Before the user signs it, the text is just a query - not saved anywhere When the user signs it, the text he/she signed must be sto...

Java code reuse through Inheritance when generics are involved (List in particular)?

I have very little knowledge of generics other than how to 'use them'. In my app I have various ListView Activity that seem to share similar methods and variables and have the exact 'algorithm' in the sense that the steps performed are all very much the same. For example in my onCreate method I call a method to add a footer, start a pr...

need help with classes for multilingual UI

I'm new to OOD so I have a question about the use of classes for creating multilingual UI. I would like to create a class that is available to all forms in my app so i could change UI language whenever I want. The basic idea is in keeping language resources in xml files and creating data bindings for all controls so the Text property is...

Relational features in object oriented programming languages

Other than Linq, have their been any other attempts to integrate relational features into an object oriented language itself, rather than just the libraries? UPDATE On of the most obvious examples is one-to-one, one-to-many or many-to-many relations. Then you can also consider relationships having properties themselves. ...

Problems designing Bejeweled game

I am trying to do the design of a Bejeweled game. I have basically 3 classes. The Game class, which is what is going to be used by the player, a Board class, that represents the board, and a SwitchController class that is responsible for checking if the wanted switch on the board is valid, making the switch, counting the number of possib...

When should you use a local class in Java?

I just discovered local classes in Java: public final class LocalClassTest { public static void main(final String[] args) { for(int i = 10; i > 0; i--) { // Local class definition--declaring a new class local to the for-loop class DecrementingCounter { private int m_countFrom; public DecrementingCounte...

How should i implement this in OOP?

How would you handle grouping different objects? For example, lets say you have a book of sport cards and you want to organize and spit out data about that book of sport cards. Obviously each sport card should have its own class and be its own object, but how would you group different sets of sprots cards? What if you wanted to see how...

Fast undo/redo with memento/command pattern?

I'm writing a painting/graphics Java application for a mobile phone (so memory is limited). The application state is essentially three 1000x500 bitmaps (i.e. layers of a painting). Loading three bitmaps takes about 2 or 3 seconds. I'm trying to write an undo engine but I just cannot work out a good way to do it. The typical approaches a...

Seperating code - modularising

When developing how useful is it to create small classes to represent little data structures. For example say as a simplified example, a program is using an array of strings to represent names of something, i.e cars. Instead of just keeping this array inside a method or class, hwo useful is it to seperate this and make it it own class....

When to use static classes and methods?

I have a general question...when should i be using static classes or static methods?.. I know the idea that static methods can be called without instantiating...and static classes should only be used for static methods?...but are there any performance concerns also with it...and when should they be preferred over instance methods and cla...

Something can go wrong but it is not an exception

I am often in a situation where I have a method where something can go wrong but an exception would not be right to use because it is not exceptional. For example: I am designing a monopoly game. The class Bank has a method buyHouse and a field which counts the number of houses left(there is 32 houses in monopoly). Something that could...