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)

0
votes
1answer
12 views

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

Below is the diagram, where, if we just consider the implementations of List, 1) AbstractList maintains the core behavior of list. To introduce the new implementation class MyList(say) one can ...
4
votes
2answers
85 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 ...
1
vote
2answers
209 views

Big graph traversal with OOP

I'm trying to solve a algorithmic contest's problem. I have a matrix 2000x2000. I want to represent it as graph and traverse it with BFS/DFS. I have time limits on app running (2s). Simple vertices ...
0
votes
1answer
162 views

How much to encapsulate when objects being dealt with are pretty similar

As I have been answering questions related to object-oriented design and how to go about reducing the amount of classes to make sure that there is not a lot of "class clutter" and code repetition I ...
7
votes
3answers
399 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 ...
1
vote
2answers
55 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 ...
1
vote
1answer
111 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 ...
0
votes
0answers
72 views

Is java interface also good for defining core behaviors? [on hold]

This comment says that: Interfaces are also good for defining core behaviors! with one of the example taken as interface List<E>. My point of view: Taken from reference, item-18: Interfaces ...
1
vote
1answer
63 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 ...
3
votes
1answer
41 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
63 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
2answers
342 views

How does a search functionality fit in DDD with CQRS?

In Vaughn Vernon's book Implementing domain driven design and the accompanying sample application I found that he implemented a CQRS approach to the iddd_collaboration bounded context. He presents ...
2
votes
1answer
51 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 ...
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 < ...
93
votes
8answers
76k views

Aggregation vs Composition

I understand what composition is in OOP, but I am not able to get a clear idea of what Aggregation is. Can someone explain?
-4
votes
0answers
31 views

Best design for a SQL API - no antlr please [on hold]

As a programming exercise, I'd like to explore creating a simplified sql like api to query csv files. Parsing the files is no problem. My concern is with design. What's the best way to design the SQL ...
7
votes
5answers
1k views

Is method overriding always a violation of Liskov Substitution Principle? [duplicate]

Overriding a method originally defined in the super class, by definition means this method will do different things when invoked on an object of the base class or an object of the subclass. So does ...
-1
votes
3answers
110 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 ...
0
votes
2answers
82 views

How can I create a data model to efficiently answer the question of - where to place my db-interaction code I am about to write?

I am seeking the right model for storing and retrieving data, when working with any specific class, while keeping in mind the bigger picture. Details: I have some SQL code in (one) of my classes and ...
2
votes
1answer
336 views

DataMapper for a MMO game plugin to send packets

I am working on an plugin for some game-server. The information about the plugin is not really necessary. Few points you might find helpful to answer to this question: The server The server is ...
1
vote
3answers
411 views

Bad Practice using Auto Generated Classes for Data Access

I've seen this before but haven't found concrete reasons. When you add Entities to your EF model, EF auto generates classes for these entities. In terms of DataAccess, why is it preferred to not ...
0
votes
2answers
185 views

Cleanly using PHP Iterator class in Loops - calling first element

I have implemented the Iterator class in PHP and built the follow mandatory methods as follows class I implements Iterator { private $a = []; function __construct(array $a) { ...
23
votes
6answers
3k views

Can you implement “object-oriented” programming without the class keyword?

Say we want to provide an abstraction of an "account" in a bank. Here's one approach, using a function object in Python: def account(): """Return a dispatch dictionary representing a bank ...
1
vote
1answer
112 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 ...
3
votes
1answer
143 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 ...
18
votes
5answers
2k 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 ...
2
votes
1answer
312 views

Change routing to comply with Law of Demeter

I have a Task, Owner and Plan. Charge values are kept in a plan, owner is on a particular plan and task knows its owner. A task needs to setup its charges based on the knowledge the owner has. Owner ...
0
votes
0answers
25 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
3answers
500 views

How should my web application handle common errors such as incorrect password, session timeout, etc.?

How should my web application handle common errors such as incorrect password, session timeout, etc.? I have a class called Hotmail that contains various method such as login, logout etc. To ...
-2
votes
1answer
57 views

Functions that work with objects of same class [closed]

I am learning Swift from video tutorials. I have a question about classes and functions. Here is my code: class BankAccount { // stored properties let accountNumber: Int let routingCode ...
5
votes
1answer
119 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
124 views

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

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 ...
3
votes
1answer
152 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 ...
29
votes
9answers
9k views

Should the methods of a class call its own getters and setters?

Where I work I see lots of classes that do things like this: public class ClassThatCallsItsOwnGettersAndSetters { private String field; public String getField() { return field; ...
3
votes
0answers
47 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
87 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 ...
3
votes
1answer
252 views

Do serialization functions belong in a model or a controller?

I'm developing an application where: Models keep data as a multi-dimensional array, which are saved as-is to a MongoDB database. The model is used to provide methods to manipulate the data, and ...
0
votes
4answers
250 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
102 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 ...
17
votes
3answers
1k views

“Too object-oriented”

I come from a strong OO background, and I have recently started working in an organization which, although the code is written in Java, has a lot less emphasis on good OO design than what I am used ...
3
votes
4answers
10k views

What exactly are SDLC and OOP?

I have been asked "What are SDLC and OOP?" many times in job interviews but I am still not sure how to answer this question. I am a web developer for quite some time but I still have problem with ...
11
votes
5answers
426 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 ...
1
vote
1answer
78 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
55 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
128 views

DI container with multiple instances of same object

I'm looking for idea to make a DI container that can store multiple instances of the same object. Usually, a DI container should store either a single instance of the object, or create new object each ...
38
votes
10answers
14k views

Can't I just use all static methods?

What's the difference between the two UpdateSubject methods below? I felt using static methods is better if you just want to operate on the entities. In which situations should I go with non-static ...
14
votes
5answers
903 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
88 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; ...
2
votes
0answers
46 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 ...