A methodology that enables a system to be modeled as a set of objects that can be controlled and manipulated in a modular manner

learn more… | top users | synonyms (3)

2
votes
1answer
86 views

Why would a program allow an object to be initialized when it doesn't support all methods/properties of the interface type it was defined as?

I'm under the impression that an object MUST support all methods/properties upon being initialized or else the program will create an error. However, if you see below I am defining 2 variables (doc ...
1
vote
3answers
149 views

What categories of software modeling problems is object orientation highly unsuitable for? [closed]

I'm trying to get a better grasp of the applicability of object-oriented programming and design. I'm curious about some examples of situations where object orientation is not simply inefficient or ...
0
votes
1answer
270 views

Accessing database from static and non-static methods

I'm currently building a REST API in PHP & MySQL, and now I'm stuck at how I should structure the classes and the database connection. Let's say I have a table in my database for movies. How ...
0
votes
0answers
79 views

C++ object design

I am programming a database similar to Cassandra. I use C++. Simplified database store its data in one or two "memory table" and several "disk tables", all stored in single directory. I have class ...
3
votes
1answer
164 views

When writing a math library, will operator overloading maintain OOP?

I want to make a fairly complicated mathematical library for a personal project and then have a visualization/GUI to go along with it to demonstrate the maths - nothing hardcore like topology but just ...
3
votes
2answers
410 views

How to use SOLID principles in this example

I have reading about SOLID principles last week and decided to try to solve real world problem by using them. So I got the problem of real world ecommerce site managing totals. Problem Statement: ...
3
votes
1answer
70 views

How should I handle incompatible configurations with the Bulider pattern?

This is motivated by this answer to a separate question. The builder pattern is used to simplify complex initialization, especially with optional initialization parameters). But I don't know how to ...
23
votes
8answers
2k views

Should my (sequential) collection start at index 0 or index 1?

I am creating an object model for a device that has multiple channels. The nouns used between the client and I are Channel and ChannelSet. ("Set" isn't semantically accurate, because it's ordered ...
3
votes
5answers
268 views

OODesign: Data Structure which calls algorithm on insert

I have a data structure which has an add function. When the user instantiates a new data structure object, she can specify an algorithm which will be executed each time the add function is called and ...
6
votes
3answers
216 views

Should instance of Employee contain a reference to instance of Office, or should Office contain an array of Employee?

Title is an abstraction of what I am actually doing, but in essence the same. The main entity I will be dealing with are the Employees themselves; "Send package to employee John Doe". In order to ...
1
vote
3answers
151 views

What is a good Design Pattern for a bundle of methods that comprises an algorithm?

This is a Design question relating to finding out a good OO design pattern or design structure or class combination that can house an algorithm that processes user selection to produce product ...
66
votes
13answers
6k views

Do objects in OOP have to represent an entity?

Does an object have to represent an entity? By an entity I mean something like a Product, Motor, a ParkingLot etc, a physical, or a conceptual object, something that is well defined, with some core ...
2
votes
1answer
261 views

What design patterns could be used here?

I'm trying to come up with a nice design (preferably pythonic) for the following use case. Say there's three services - A, B, C in multiple locations L1, L2, L3, etc. Each service provides ...
-3
votes
2answers
148 views

Advantages of these recommendations in ooprogramming using Java

Below are the recommendation from section 5.1 of this essay. While Java is not a pure object-oriented language, it is possible to program in a pure object-oriented style by obeying the following ...
-1
votes
3answers
281 views

Why List<E> interface is additionally introduced in collection hierarchy? [duplicate]

Below is the diagram, where, if we just consider the implementations of List, AbstractList maintains the core behavior of list. To introduce the new implementation class MyList(say) one can ...
4
votes
2answers
197 views

Should serialization and deserialization be the responsibility of the class being serialized?

I'm currently in the (re)design phase of several model classes of a C# .NET application. (Model as in M of MVC). The model classes already have plenty of well-designed data, behaviors, and ...
2
votes
1answer
76 views

Conceptual question whether to pass data between functions or use a Class

I have a hard time to find an ideal concept / design and would appreciate your thoughts on this. I have 16 "tissues" that I need to keep track on. Each tissue holds a pressure that need to be ...
1
vote
3answers
85 views

Where should PDOExceptions be dealt with?

I wrote a database wrapper class to help with queries and I'm trying to figure the best way to implement try-catch blocks. In my database class, I have a helper function; public function ...
3
votes
1answer
50 views

Can I resolve an issue with SRP, SOC that prevents object initialization via constructor?

In OOP, I can populate (initialize) an object using constructor injection at object creation time, or setter injection, after creation time. I like the idea of populating object at creation time via ...
2
votes
1answer
57 views

Why is SRP using the class construct to contain a responsibility opposed to using any other OOP entity?

SRP states ... There should never be more than one reason for a class to change. But why a class? Why not use granularity of a function/method? What instead of separating my functionality into ...
1
vote
2answers
139 views

User and role modeling

I'm working with a system in ASP.NET MVC, with Entity Framework for ORM. The application has a requirements to allow users to have different types of roles, and authorization rules will be different ...
10
votes
8answers
3k views

How do I design a subclass whose method contradicts its superclass? [duplicate]

How do I design a subclass whose method contradicts its superclass? Let's say we have this example: # Example 1 class Scissor def right_handed? true end end class LeftHandedScissor < ...
-1
votes
3answers
120 views

What design pattern is this? [duplicate]

I'm struggling to come up with the name of a design pattern that I need to write about. I've been lead to think it was abstraction but apparently not. Let's say I had a driver class which has a Drive ...
1
vote
1answer
152 views

How to avoid tying these two methods together with global mutable state?

I'm in the process of reading Code Complete 2 and learned that using global state is a no-no. What can I do to avoid using global state in this situation? Some background information: I have two ...
1
vote
1answer
131 views

Design Pattern - Adding features to a class

I'm finding myself unable to solve a design problem. For the sake of my simplicity, I'm going to use C# (Web API). Let's say I have an abstract class RestController: public abstract class ...
19
votes
5answers
3k views

Create new object or reset every property?

public class MyClass { public object Prop1 { get; set; } public object Prop2 { get; set; } public object Prop3 { get; set; } } Suppose I have an object myObject of ...
0
votes
0answers
42 views

DDD Request Validation Handling

I stuck somewhere that I can't find a solution! There are plenty of validation questions here, but as far as I see, most of them were asking about entity validation. But what about request validation? ...
3
votes
1answer
162 views

Is Apple sample code the “correct” way to go?

I'm in a place were I know how to build apps and have submitted at least 5 for different clients to the app store and wanted to step up my game. So of course I went to Apple resources and analyse the ...
4
votes
1answer
125 views

Where to initialize objects

I have an BallEntity class that is part of a game that uses a Entity Component System architecture. This class have 'components' that are like the attributes of that class. I create and initialize ...
0
votes
2answers
147 views

Best practice relationship variable naming: Should I use the description of the relationship or variable. Example personId or owner? [closed]

When I'm creating domain models and adding variables to a class. I'm havng to trouble which naming I should use. For example If I have a Person and a Car. When I have: Class Person { var int ...
5
votes
1answer
99 views

When applying the interface segregation, should you separate interfaces for regular setters and mathematical operations?

When applying the interface segregation, should you have separate interfaces for a straightforward setters and interfaces that perform an operation before setting? For example, say you have a class: ...
5
votes
1answer
199 views

PHP: Injecting the same database connection into multiple objects

Suppose that there are two classes that define objects of vastly different function such that in the datastore, the information they require is divided into two separate databases. For example, the ...
1
vote
4answers
338 views

How can I avoid the use of strings?

I'm implementing a program where the user can 'create a musical scale' from a variety of notes (identified by their names), and the program will generate music from this scale. I want to implement a ...
2
votes
1answer
135 views

Beginners C# question about Array.Reverse

I am sitting through a very well-explained and thorough video tutorial series, using Visual Studio 2012 as my developing environment. Anyway, one thing that is hard to figure out is this. Say you ...
3
votes
1answer
154 views

Providing views to an std::container

I want to maintain a buffer of 5 seconds of sensor data. The sensor data consists, among other things, of accelerometer readings in x,y,z dimensions, gyroscope readings in x,y,z dimension and ...
10
votes
5answers
515 views

Should I prefer composition or inheritance in this scenario?

Consider an interface: interface IWaveGenerator { SoundWave GenerateWave(double frequency, double lengthInSeconds); } This interface is implemented by a number of classes which generate waves ...
1
vote
2answers
42 views

Instantiating a set of Objects from information in File

Let’s say I have four classes A,B,C,D. Each of those classes contains a Tree object. This tree object needs to be built according to information stored in files f_A, f_B, f_C, f_D, for classes ...
4
votes
0answers
78 views

is this use case well structure?

I'm trying to create a use case that make sense, and i am a little bit confused with the alternate path i think i am doing it in the wrong way, the system should tell the admin when a shared playlist ...
1
vote
1answer
90 views

OO Design: Algorithm changing State (Information Flow Question)

I have a class Context, which contains an instance of an abstract class State, which has multiple concrete subclasses (this is an implementation of the State Pattern). Each State subclass executes a ...
2
votes
0answers
66 views

What's the best pattern to validate a conditional entity? [duplicate]

I'm developing an ASP.NET MVC 5 website and I have a view with a grid. In this grid I have a column which represents an URL property. This url is a link to download some files, but this url should be ...
14
votes
5answers
942 views

Is the semantic contract of an interface (OOP) more informative than a function signature (FP)?

It is said by some that if you take SOLID principles to their extremes, you end up at functional programming. I agree with this article but I think that some semantics are lost in the transition from ...
-1
votes
1answer
107 views

What might be a good way to get hands on experience with Object Oriented PHP [closed]

I am a Computer Science student. I took a course on OOP, and I understand the concepts (classes, extending, encapsulation, etc). I'm also a web developer, have been doing it for about three years; ...
1
vote
1answer
95 views

If the representation part of type abstraction is declared private, then how does sub-classing violate encapsulation?

Here, I learned that sub-classing violates encapsulation: it violates encapsulation, since the implementations of the superclass and subclass become tightly coupled For instance, If we consider ...
8
votes
3answers
521 views

Cleanest way to write logically procedural software in an OO language

I'm an electrical engineer and I don't know what the hell I'm doing. Please save the future maintainers of my code. Recently I've been working on a number of smaller programs (in C#) whose ...
2
votes
1answer
178 views

Injection, strategies and OO

I'm working on refactoring a project. The business logic looks very much like using the Strategy pattern would be very beneficial, because depending on the values of three properties (let's say age, ...
1
vote
1answer
138 views

Should I use generics whenever possible or is object ok in some cases?

I'm having an interface ProgressReporter which basically takes a list of input items (the working queue) through a method SetWorkPackages(IEnumerable<T> workPackages) and then has another method ...
1
vote
1answer
61 views

Virtual method returning a unique collection - how to ensure and hint?

I have a virtual method that returns a collection of items that must be unique. I want to make sure that it will be obvious when overriding the method. What is the best way to do this? Here is an ...
0
votes
0answers
31 views

Graph curve and actual curve plotted on screen implementation patterns

I'm implementing a graph plotter. There are Curve objects, that contains points of actual XY data. When I plot to screen, I need to calculate the XY points on screen, resulting a PlottedCurve. This ...
4
votes
3answers
139 views

Unit of Design Versus Unit of Re-use. What is the difference?

Contemporary object-oriented programming languages employ the class as the unit of reuse. At the same time, the class is also the unit of design. This implies that to reuse a class, the design ...
4
votes
1answer
175 views

OOP design for conditional event processing queue

This will be in C++11, but the object design should be rather agnostic. I have 3 interface classes, IEvent, ICondition, IRunnable. The main loop processes multiple kinds of IEvent, ranging from "an ...