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)

-5
votes
1answer
55 views

Preventing a Javascript object function called twice [on hold]

I am trying to reuse an object but my function is getting called twice. Here is what I have: var KEYBOARD = { template: 'keyboard', getkeyboard: function(){ console.log(this.template); } } ...
0
votes
2answers
44 views

Should `setX(Object o)` methods perform deep or shallow copies of objects?

My particular situation is related to Java, but I believe this is a more general OOP question than just Java programming. The Question: Should "mutator" methods perform deep or shallow copies? An ...
1
vote
1answer
103 views

C++ : Association, Aggregation and Composition

I'm beginning to study OOAD and I'm having difficulty finding a C++ code example that'd illustrate how Association, Aggregation and Composition are implemented programmatically. (There are several ...
0
votes
0answers
66 views

Designing a simple file manager [on hold]

I've been trying to come up with the best way to design my file manager for a project. I need to work with many file implementations and I have a File class made of 2 classes inside: Data and ...
2
votes
3answers
233 views

Could the creation of many methods in Java affect performance? [closed]

I was told by a colleague that in Java, the performance may be worse if we create more methods, stacking many methods calling over them in JVM, specially in a Java EE environment. This seems to ...
1
vote
4answers
132 views

Domain model associations that do not required the behaviour of the associated object. How to model?

I've been struggling with this question for a while. I'm specifically thinking within the object orientated domain model. Let's say I have two entities. A supplier and a customer. There is a ...
-1
votes
0answers
55 views

“Resource center”: should the resources be exposed as public constants, or through getters?

I'm working on an application that has to do with music. Since the beginning of the work on the app, I had a public class named MusicalResources. The class had public static final Notes and Chords. ...
1
vote
0answers
70 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 ...
0
votes
5answers
339 views

Liskov Substitution and SRP Principle violation - how best to structure this scenario?

While learning SRP and LSP, I'm trying to improve the design of my code to comply best with both of these principles. I have an employee class that has a calculatePay method on it. Firstly, I believe ...
2
votes
1answer
192 views

Any OOP design pattern that is somewhat representative of all of the SOLID OOP design principles at play?

I'm trying to teach an object oriented design principles course (on SOLID) at a training institute. I also want to teach the students a few OOP design patterns such as factory, singleton and one ...
0
votes
1answer
101 views

Are there two type of associations between objects or are there just different representations?

I've been spending some time on 're-tuning' some of my OOP understanding, and I've come up against a concept that is confusing me. Lets say I have two objects. A user object and an account object. ...
4
votes
1answer
108 views

Reducing dependency cycles and reducing coupling

I'm trying to learn how to produce quality object-oriented code and have been studying concepts like SOLID. I'm currently working on an entity-component-process system for a small game engine. ...
0
votes
1answer
282 views

Single responsibility: how does this code cause problems?

Given the following interface interface Modem { public void Dial(string pno); public void Hangup(); public void Send(char c); public char Recv(); } Uncle Bob writes However, ...
1
vote
2answers
133 views

How to let the outside world decorate my private field?

Imagine a simple Controller (as in process control) interface. I have some concrete classes, say PIDController, that implement it. I also have some decorator classes that extend these classes ...
3
votes
1answer
171 views

Redundancy caused by polymorphism

I have two chat rooms, one has administration behaviour, and one doesn't. I have factored out all of the common code into a base chat room, but the AdministerChatroom behaviour I have pulled out into ...
0
votes
1answer
70 views

Efficiency of getters/setters with database performance

I'm currently in the process of refactoring a very old personal project of mine, which used procedural PHP-in-HTML code. I'm modernising it as a learning project, using OOP where beneficial. I ...
2
votes
1answer
70 views

class hierarchy with structurally different subclasses

I want to implement a protocol layer which sits on top of the TCP/IP stack. There is a limited set of PDUs that can be sent and for each PDU there is a class which represents it in a structured form. ...
2
votes
5answers
502 views

Are a class's methods stored only once in memory? [closed]

When I create an instance of a class the system allocates memory for all instance variables of the class. Some languages may call them fields or properties. But what about the code of the class ...
1
vote
1answer
123 views

Entity Component System Coupling

Lately I've been working on a small personal project which is basically an Entity Component System framework with autoupdated Systems. While I have a pretty good idea on the way the framework should ...
0
votes
2answers
137 views

Designing Nested List<Class> Property in a Class

I'm currently in the class modeling phase of my project. Real life Scenario: Let's say I have a Project that is composed of Main Components and each Main Component is composed of Sub Components and ...
0
votes
2answers
171 views

C# - initialize variable inside method and use in whole class [closed]

this is a conceptual question, but if i initialize a variable in c# as public will it be able to be used in the class as I want a variable "player1" and a variable "player2" where either could be one ...
0
votes
1answer
47 views

The ViewController design in iOS vs MVC in tradiational web apps design

As I came from the background of webapps and move to iOS programming, I am wondering why we can't just apply the MVC design approach to native apps, i.e. in iOS, the view and controller are tightly ...
2
votes
1answer
151 views

Composing programs from small simple pieces: OOP vs Functional Programming [closed]

I started programming when imperative programming languages such as C were virtually the only game in town for paid gigs. I'm not a computer scientist by training so I was only exposed to Assembler ...
1
vote
3answers
144 views

Am I violating LSP if the condition can be checked?

This base class for some shapes I have in my game looks like this. Some of the shapes can be resized, some of them can not. private Shape shape; public virtual void SetSizeOfShape(int ...
1
vote
2answers
260 views

Advice on approaching a significant rearrangement/refactoring?

I'm working on an application (hobby project, solo programmer, small-medium size), and I have recently redesigned a significant part of it. The program already works in it's current state, but I ...
4
votes
5answers
374 views

Questioning one of the arguments for dependency injection: Why is creating an object graph hard?

Dependency injection frameworks like Google Guice give the following motivation for their usage (source): To construct an object, you first build its dependencies. But to build each dependency, ...
2
votes
1answer
159 views

Is this JS code a good way for defining class with private methods?

I was recently browsing a open source JavaScript project. The project is a straight port from another project in C language. It mostly use static methods, packed together in classes. Most classes are ...
1
vote
1answer
134 views

Dependency injection in constructor, method or just use a static class instead? [closed]

What is the best between: $dispatcher = new Dispatcher($request); $dispatcher->dispatch(); and $dispatcher = new Dispatcher(); $dispatcher->dispatch($request); or even ...
35
votes
5answers
4k views

Passing functions into other functions as parameters, bad practice?

We've been in the process of changing how our AS3 application talks to our back end and we're in the process of implementing a REST system to replace our old one. Sadly the developer who started the ...
3
votes
1answer
147 views

Project structure: where to put business logic

First of all, I'm not asking where does business logic belong. This has been asked before and most answers I've read agree in that it belongs in the model: Where to put business logic in MVC design? ...
2
votes
1answer
91 views

Models, collections…and then what? Processes?

I'm a LAMP-stack dev who's been more on the JavaScript side the last few years and really enjoying the Model + Collection approach to data entities that BackboneJS, etc. uses. It's helped me organize ...
1
vote
4answers
126 views

When should a method of a class return the same instance after modifying itself?

I have a class that has three methods A(), B() and C(). Those methods modify the own instance. While the methods have to return an instance when the instance is a separate copy (just as Clone()), I ...
5
votes
6answers
494 views

Requesting feedback on my OO design

I'm working on an application that creates music by itself. I'm seeking feedback for my OO design so far. This question will focus on one part of the program. The application produces Tune objects, ...
0
votes
3answers
137 views

How to change the state of a singleton in runtime

Consider I am going to write a simple file based logger AppLogger to be used in my apps, ideally it should be a singleton so I can call it via public class AppLogger { public static String file = ...
1
vote
0answers
75 views

JS closures - Passing a function to a child, how should the shared object be accessed

I have a design and am wondering what the appropriate way to access variables is. I'll demonstrate with this example since I can't seem to describe it better than the title. Term is an object ...
3
votes
4answers
229 views

Is there a way to avoid type-checking in this scenario?

I have a class SuperClass with two subclasses SubClassA and SubClassB. I have a method in a different class which takes a SuperClass parameter. The method should do different things depending on the ...
0
votes
1answer
149 views

Should I limit my type name suffix vocabulary when using OOP?

My co-workers tend to think that it is better to limit non-domain type suffixes to a small fixed set of OOP-pattern inspired words, e.g.: *Service *Repository *Factory *Manager *Provider I believe ...
0
votes
2answers
133 views

One boilerplate class or many similar classes?

Lets say I'm trying to model a variety of objects that are virtually identical, the only difference being their class variables. Am I better off creating one boilerplate class and just calling the ...
9
votes
4answers
433 views

Are first-class functions a substitute for the Strategy pattern?

The Strategy design pattern is often regarded as a substitute for first-class functions in languages that lack them. So for example say you wanted to pass functionality into an object. In Java you'd ...
0
votes
1answer
83 views

What's a “Polymorphic method”?

Sometimes people use the phrase "Polymorphic method/function". Does it mean: A method that takes a Polymorphic type as a parameter, and performs some operation on it. By "Polymorphic type" I mean a ...
1
vote
1answer
160 views

Passing in config values to a method using SOLID principles

I have an email helper class that has a method that sends email: private static class EmailHelper { public static void SendEmail(string from, string to, string subject, string message) { ...
0
votes
3answers
171 views

Drawback of using static method [duplicate]

For methods that never access instance variable or static variable and they act just like a function (name-spaced) and they are deterministic base on only the input arguments , I want to ask, are ...
1
vote
0answers
59 views

Dealing with class optional dependencies

I am wondering how are you guys handling an optional class properties. Let's say I have a product that can bud doesn't have to have a color property. Is that really the best way of doing that? Should ...
1
vote
3answers
378 views

Self-Evaluation: How do I know if I actually have a “good grasp” of OOP? [duplicate]

If I skip the back story and any thoughts I have on this topic, there's really only one question left to ask: How can I find out if I have a "good grasp" on OOP? (I am specifically using PHP, but ...
5
votes
2answers
947 views

Why are inheritance, encapsulation and polymorphism not the pillars of OOP? [closed]

One day I went to a Stack Overflow chat and saw a phrase, that was stating that inheritance, incapsulation and polymorphism are the pillars of OOP (in the sense that they are fundamental, a ...
1
vote
3answers
147 views

Protected variable & protected method in the era of TDD [closed]

I understand protected method is good for unit testing since you can easily mock by the class by overriding the protected method for the sake of testing. However, protected variable is just a global ...
28
votes
8answers
5k views

Is splitting up a function into several inner functions an anti-pattern? [duplicate]

Imagine a long and complicated process, which is started by calling function foo(). There are several consecutive steps in this process, each of them depending on result of the previous step. The ...
1
vote
3answers
149 views

Extending a struct. Using helper classes rather than composition

I have a struct which I want to add static methods to. Yes, you guessed right I'm talking about Datetime. It's a pretty typical requirement to add MyCustomParse. It happens to return Datetime?, so ...
1
vote
0answers
87 views

Parent class loses coupling after I refactored identical code blocks from child classes to parent

I have a class called Parent, and classes called Child1, Child2, etc, I have noticed that child classes have a series of function calls that had same (duplicated) lines of code that could be ...
0
votes
3answers
258 views

How do you make a service stateless?

When doing Domain Driven Design it is advised that services should be stateless. There are several kinds of services when doing DDD: Application services. Domain services. Infrastructure services. ...