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

3
votes
1answer
115 views

Is avoiding the private access specifier in PHP justified?

I come from a Java background and I have been working with PHP for almost a year now. I have worked with WordPress, Zend and currently I'm using CakePHP. I was going through Cake's lib and I couldn't ...
1
vote
1answer
95 views

Proper library for enums

I'm trying to refactor some code such that the display is separate from the implementation, and I'm not sure where to put the existing enums. My project is currently structured as follows: ...
1
vote
2answers
522 views

Dependency injection with Finite State Machines and the Interface Segregation Principle

I am trying to figure out what is the best way to setup a FSM and also keep my interfaces clean and use an IOC container to use DI. Let's just visit the Head First design pattern textbook example of ...
29
votes
3answers
5k views

Rich Domain Models — how, exactly, does behavior fit in?

In the debate of Rich vs. Anemic domain models, the internet is full of philosophical advice but short on authoritative examples. The objective of this question is to find definitive guidelines and ...
20
votes
7answers
1k views

Does functional programming ignore the benefits gained from the “On the Criteria To Be Used in Decomposing Systems into Modules” (data hiding)?

There's a classic article named On the Criteria To Be Used in Decomposing Systems into Modules that I just read for the first time. It makes perfect sense to me, and is probably one of those articles ...
4
votes
2answers
580 views

How much logic can be put into an object-pooling factory class before it does more harm than good?

The main language I'm interested in doing object pooling in is AS3, which is known to need it in many cases. In the past I've always made a brand new factory class for every type I was going to try ...
3
votes
3answers
317 views

Making some methods mostly contain method calls, while others doing “the lowest level” work [duplicate]

So I thought about this, and I don't know if it's included or not in any methodology. I think the advantages of this coding style is that, at the lowest level, the code is extremely testable, and ...
1
vote
1answer
169 views

When should one use composition instead of re-writing the functionality?

Say, I have a class A which has methods m1,m2,m3,m4,m5.... m100. I am making another simpler class B and I require only m2,m3 and m5 in B. Should I be ideally using compositions and put a reference ...
2
votes
2answers
732 views

OOP Objects, nested objects, and DAO's

Here's something I keep struggling to figure out the best solution to. I've had this problem while working with PHP and Java so it's a fundamental understanding of OOP issue. Examples are in PHP. ...
1
vote
0answers
225 views

How should Object Model wrapper classes behave when underlying objects are deleted?

I'm currently building an object model library for use in a project. It wraps our internal concepts - Servers, Folders, Items - in an object hierarchy (IFolder, IItem, etc), and we have several ...
3
votes
2answers
166 views

How do I alter an open source library for my own use?

I'm programming in Objective-C. I want to include a camera library, DLCImagePicker, in my project. There is a variable I need to change, but it is private and I have no access to it. I've thought of ...
5
votes
3answers
393 views

How should I create a combined interface for two logically independent modules?

I'm having trouble coming up with a good way to structure the interfaces for two modules that are logically independent but whose implementations may be combined for the purposes of performance or ...
1
vote
3answers
227 views

Pattern / methodology for representing large database records as objects

A bit of background information: We have an old database application written in Access that lets users monitor their workload, and the code is... 'procedural' might be too kind. The vast majority of ...
1
vote
2answers
350 views

A better alternative to incompatible implementations for the same interface?

I am working on a piece of code which performs a set task in several parallel environments where the behaviour of the different components in the task are similar but quite different. This means that ...
1
vote
4answers
507 views

How to get Object Oriented Programming Concepts? [closed]

What is the best way or best resources or tutorials to learn Object Oriented Programming? For instance, when I begin a program with Java and all my code goes into just one class and I can't estimate ...
0
votes
3answers
281 views

Liskov substitution principle when implementing two unrelated interfaces

Suppose I have two unrelated interfaces with the same method: interface Table { /** * @param width (0 < width <= 100) */ void setWidth(int width); } interface Square { ...
4
votes
5answers
748 views

What is the name of this particular kind of over-engineering? [closed]

When faced with (even a small) project, I tend to fall into the following bad practice. I think about the structure of the problem. Then I create some base classes, derive from them and then derive ...
1
vote
3answers
151 views

Force user to extend class or use configuration

What is better practice: force user to extend abstract class or make class with configuration? Eg. pseudocode: ClassA{ this.name this.weight this.height this.width constr(config){ this.name = ...
0
votes
1answer
245 views

Architecting Domain Layer and other modules with dependency injection in mind

I am currently new to Dependency Injection pattern. I am influenced by link by Mark Seemann. I have a confusion regarding whether an interface for an agent class of some agent module should be ...
1
vote
5answers
1k views

What are the reasons to create UIView subclass?

I've noticed that there are a lot of UIView subclasses in my legacy project. Mostly the only reason of such a subclass is to split bigger view into custom subviews and provide layout for its subviews ...
1
vote
1answer
90 views

How much time should be spent with use cases?

I'm starting to work with agile iterative approach to software development and this question seems quite natural. After gathering the requirements I should write a few use cases to describe how the ...
0
votes
3answers
185 views

Deciding how to model customer when it can be both natural and legal person

Suppose that we are developing some application that requires us to be able to manage customers and that those customers can be both natural and legal person. There are some different ways on which we ...
2
votes
2answers
330 views

Is this a good use case?

I've been studying object oriented analysis and, so to get started with this in practice I've decided to first of all build my own management system to have my customers data and so on. Trying to ...
1
vote
4answers
491 views

How to figure out design pattern for this particular solution?

While working on a project I've come up with some design solution. I am having a hard time relating it to any general design pattern or analyzing this situation in details. This is also prohibiting me ...
2
votes
5answers
681 views

How to handle assumptions while designing any system?

I have been going through various system design examples to understand how we approach any system design question. Here is what I have understood till now. Know the system first and find out how it ...
4
votes
1answer
323 views

Is using protected inheritance to hide (but exploit) implemented interface from the public ok?

Recently, we had a discussion about code using protected inheritance in order to hide the fact (to client code) a class inherits from a specific base class but to exploit this fact in the ...
0
votes
1answer
265 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 ...
3
votes
2answers
700 views

Does cohesion really reduce coupling?

'Cohesive classes reduce coupling' So, if cohesive classes or connected classes reduce coupling (union), which piece of the puzzle is missing me? BTW, I took this sentence from an article about ...
3
votes
5answers
815 views

How do you learn to take a more OO approach to problems? [duplicate]

I have been learning C# and am trying to tackle some common projects / works of my own to become even better. Currently I am working on understanding the Mars Rover Problem. I read the description and ...
2
votes
3answers
101 views

Can certain expectations of behavior be part of an interface's contract?

Given the following code: public interface IUserDataProvider { ICollection<SomeClass> getSomeClassRecordsForUser(int idUser); } Is it possible to define (via documentation) an ...
1
vote
1answer
175 views

Where to put entity model classes in case of using a dataservice layer?

If my solution has both a "dataservice" project and a "business logic" project, where do the entity models, which represent database tables, belong? At first i thought putting them in the ...
5
votes
2answers
297 views

Does increasing the number of classes increase code complexity? [duplicate]

To illustrate the question, let's say we have two programmers of comparable skill that both solve the same problem. The code they turn out has roughly the same lines of code, but one programmer uses 5 ...
11
votes
3answers
1k views

How to create better OO code in a relational database driven application where the database is poorly designed

I am writing a Java web application that consists mainly of a bunch of similar pages in which every page has several tables and a filter that applies to those tables. The data on these tables comes ...
0
votes
1answer
163 views

How should I implement “queueing” of approval on my objects?

I have a list of objects that will need to go through an approval process. I am curious if it would be best to simply add some properties to my object, like ApprovedBy, and ApprovedOn. Another ...
1
vote
1answer
275 views

How to avoid peppering the code with IFs [duplicate]

I need to add a new payment type to an existing code base. That means that I'm going to have a few methods looking like this: if (old payment type) process old type of payment else process ...
1
vote
2answers
128 views

How to deal with requirements and use cases in this kind of situation?

Recently I've started to work with object oriented analysis and design and it seemed very interesting to me as a way to get work done better. But I'm still in doubt with one kind of situation. If this ...
3
votes
4answers
296 views

Separation of construction and initialization

I'm confused by this post by Mark Seeman. And his comment on IInitializable below: The problem with an Initialize method is the same as with Property Injection (A.K.A. Setter Injection): it ...
28
votes
3answers
2k views

Is a “start”, “run” or “execute” method a good practice?

I'm currently working on a code base that has many classes that implement a Start method. This seems like two-phase construction to me, which I had always considered a bad practice. I can't tell the ...
0
votes
1answer
129 views

Creating Set Subclasses or Allowing Outside Configuration

I have a TriggerCaller and a TriggerAction class. The Caller "calls" the do() method on the action, which is set with the TriggerCallers setAction() method. The rest of the program should deal with ...
0
votes
3answers
823 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 ...
16
votes
10answers
987 views

Object Oriented Design

Suppose you have the following: +--------+ +------+ | Animal | | Food | +-+------+ +----+-+ ^ ^ | | | | ...
1
vote
1answer
163 views

Component design: getting cohesion right

I currently have a set of components named DataValues, ValueParsers, ValueFormatters and ValueValidators. The first one defines an abstract base class DataValue and contains a whole load of ...
9
votes
4answers
953 views

Is the List interface a leaky abstraction?

If I have a variable containing a List it could contain objects of a lot of different types e.g. ArrayList or LinkedList. The difference between a LinkedList and an ArrayList is pretty big. The big O ...
14
votes
6answers
2k views

Loose Coupling in Object Oriented Design

I am trying to learn GRASP and I found this explained (here on page 3) about Low Coupling and I was very surprised when I found this: Consider the method addTrack for an Album class, two possible ...
5
votes
5answers
313 views

How to organise OO code [duplicate]

If you have a method that doesn't need access to any non public fields, properties or methods where should you put the method ? should it just be a normal method in the class, a static method that ...
7
votes
3answers
928 views

Is it a good practice to wrap all primitives and Strings?

According to Jeff Bay's Essay on Object Callisthenics, One of the practices is set to be "Wrap all primitives and Strings" Can anyone elaborate on this ? In languages where we already have wrappers ...
2
votes
2answers
2k 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: ...
5
votes
3answers
552 views

OO - are large classes acceptable? [duplicate]

Despite many years in IT, I still struggle with OO design. One particular problem I seem to keep ending up with is large classes, often containing many hundreds of lines of code. The OO world talks a ...
2
votes
1answer
155 views

Help me to understand following points about the strategy pattern, how it relates to open/closed principle

I am learning design patterns. I read this article. Point no. 3 is not clear to me. The writer said that strategy lets you change the guts of an object. But this is a violation of the open-close ...
2
votes
2answers
549 views

Is it a Single Responsibility Principle violation?

I'm designing an OO graph library and at the moment I'm trying to figure out the design for a GraphEdge class. I've added setters and getters for it's nodes, direction and weight. This seemes ...