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)

4
votes
2answers
645 views

Python classes with only one instance: When to create a (single) class instance and when to work with the class instead?

Given a Python class which will be instantiated only once, i.e. there will be only one object of the class. I was wondering in which cases it makes sense to create a single class instance instead of ...
9
votes
1answer
211 views

Python's join seems to focus not on the items to join, but on the symbol, as compared to Ruby or Smalltalk, for a design reason?

I thought one of the cornerstone of OOP is that, we have objects, which are the items we are interested in dealing with, and then we send messages to them. So it may seem natural that, I have a ...
8
votes
4answers
246 views

Best strategy for reporting progress to the UI - how should the callback happen?

Sometimes the user starts an extended technical operation that takes a while to execute. In these cases, it's usually nice to display some kind of progress bar, along with information about which task ...
1
vote
1answer
127 views

Child classes only change some “options” - what's the best approach?

I'm currently implementing functionality in Symfony (PHP - not that it should make any difference which language I'm using) where I have about four controllers that do almost exactly the same thing. ...
9
votes
4answers
300 views

Parameter management in OOP application

I'm writing a medium size OOP application in C++ as a way to practice OOP principles. I have several classes in my project, and some of them need to access run-time configuration parameters. These ...
0
votes
2answers
189 views

Does Python have any features which can be used for encapsulating private data?

Usually in OOP world we are told that modularity is a good practice and keeping loose coupling between module is a great thing. Encapsulation helps us achieve this loose coupling. In Java ...
10
votes
2answers
419 views

Why is it inappropriate to use UML diagrams to plan how your code will be organized?

So, yes, diagrams can be inappropriate at times. When are they inappropriate? When you create them without code to validate them, and then intend to follow them. There is nothing wrong with ...
-1
votes
1answer
99 views

PHP: where to call helper class in MVC?

I've a helper class in Laravel 5.1 with static methods for calculating week numbers, dates in weeks, etc. (Why static? I need max. 1 instance of this helper class) I need this logic in my views. I'm ...
4
votes
3answers
347 views

Avoiding constructors with many arguments

So I have a factory which creates objects of different classes. The possible classes are all derived from an abstract ancestor. The factory has a configuration file (JSON syntax) and decides which ...
3
votes
1answer
73 views

Command handler executing commands with different dependencies

Well basically, I have an Engine class that recieves a command as string from the input and passes it to a CommandHandler class which executes the apropriate command. The CommandHandler passes the ...
44
votes
3answers
10k 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 ...
5
votes
2answers
170 views

Factories, vectors and smart pointers - Design Question

So, my Business Code needs some Objects. It does not know how much objects it needs and it does not know the exact types (because polymorphism is involved). For me, that sounds for a good reason to go ...
3
votes
0answers
101 views

Refactoring of a client API for avoid duplicated code and unclear passage of parameters

I need to develop an API, the functions of the API are requests that call the service exposed by a server. Initially the API worked like this: class Server: def firstRequest(self, arg1, arg2): ...
26
votes
5answers
2k views

Saving an object via a method of its own or via another class?

If I want to save and retrieve an object, should I create another class to handle it, or would it better to do that in the class itself? Or maybe mixing both? Which is recommended according to OOD ...
16
votes
4answers
31k views

UML class diagram notations: Differences between Association, Aggregation and Composition

I'm confused about some of the notations of UML class diagrams. Pretty sure I know what Association means. Any relationship between instances of two classes, where an instance of one class needs to ...
14
votes
4answers
719 views

APIs and functional programming

From my (admittedly limited) exposure to functional programming languages, such as Clojure, it seems that encapsulation of data has a less important role. Usually various native types such as maps or ...
2
votes
0answers
39 views

Handling of messages with several indicators

I am currently working on an application, which will show several messages (alarms - warnings - hints) on a cable-connected display. As these messages depend on several indicators I have to decide ...
2
votes
3answers
315 views

Should conditional logic be always coded via type system where possible?

I have a choice. Option 1: public class Sample { bool IsRelevant { get; set; } } Option 2: public class Sample { } public class RelevantSample : Sample { } Is there a clear well-known rule ...
3
votes
1answer
97 views

Single Responsibility Principle : Proxy Pattern for refactoring

However, in cases where the tests did not force the separation, and the smells of Rigidity and Fragility become strong, the design should be refactored using the Facade or Proxy patterns to ...
0
votes
2answers
116 views

Designing classes that depend on each other

How would one go about designing classes for a system in which two components depend on each other? For a more concrete example, consider this scenario, you're designing a piece of software to manage ...
1
vote
2answers
84 views

What is “recorded” relationship in a class diagram? [closed]

Composite aggregates Part, Container contains Content, and Recorder records. Recorded are all very common relationships between classes in a class diagram. Creator suggests that the enclosing ...
1
vote
2answers
130 views

Acceptable design to use public member objects in composition?

Say I have a large class called Root, which has a lot of members & functions: class Root { public: void func1(); // operates on a and b void func2(); ... private: A a; ...
3
votes
3answers
204 views

How to “program to an interface”

I've read these questions: Understanding "programming to an interface" What is the point of an interface? Does it always make sense to "program to an interface" in Java? I ...
1
vote
0answers
38 views

WMC Calculation in CK Metrics Suite

I have two classes C1 and C2. C1 has 2 methods and C2 has 3 methods each of complexity value 1. C2 inherits from C1. So, I know C2 has 2+3=5 methods in all. The question is, should I take C2 to have 5 ...
2
votes
2answers
195 views

What is meant by reuse of inheritance?

A 2013 study of 93 open source Java programs (of varying size) found that While there is [no] huge opportunity to replace inheritance with composition (...), the opportunity is significant ...
-2
votes
1answer
108 views

Should objects with different properties (not behaviour) have different types?

I see a lot of classes that look like: class Student extends Model { public string major; public string minor; } class Employee extends Model { public string department; public ...
4
votes
3answers
175 views

Alternatives to Singletons for caching lists of data?

In my project, I have an abstract Cache class that allows me to populate a series of lists that globally persist throughout my application. These cache objects are thread-safe and can be manipulated ...
1
vote
3answers
114 views

How To Extend Parent Methods in Children Classes?

There is a parent class with a method which many children use but many children extend the method, what is the best way to extend it without violating DRY? Here are my 2 current solutions: 1: The ...
0
votes
1answer
70 views

How to periodically serialise object's state and deserialise on initialisation in Python?

We're designing an application that is supposed to monitor a system for certain events, email interested parties to prompt them to take action when relevant and parse their replies. The application ...
12
votes
4answers
949 views

Switch vs Polymorphism when dealing with model and view

I can't figure out a better solution to my problem. I have a view controller that presents a list of elements. Those elements are models that can be an instance of B, C, D, etc and inherit from A. So ...
1
vote
3answers
223 views

Function Overloading in Python

My book says that function overloading is not possible in python but it asks me questions like: WAP to find out the volume of a cube,cuboid and cylinder using function overloading. Do I have to ...
5
votes
1answer
363 views

Advantages and drawbacks of different ways using Either-types [closed]

I am writing software for compiling programs. Therefore have a Compiler that compiles a given sourcecode. It then returns a CompileResult that is similiar to an Either type (it is actually internally ...
9
votes
7answers
2k views

Checking if a method returns false: assign result to temporary variable, or put method invocation directly in conditional?

Is it a good practice to call a method that returns true or false values in an if statement? Something like this: private void VerifyAccount() { if (!ValidateCredentials(txtUser.Text, ...
36
votes
5answers
2k views

How is defining that a method can be overridden a stronger commitment than defining that a method can be called?

From : http://www.artima.com/lejava/articles/designprinciples4.html Erich Gamma: I still think it's true even after ten years. Inheritance is a cool way to change behavior. But we know that it's ...
3
votes
2answers
94 views

Best practice in helper/util methods: IoC container or static methods?

So I'm developing an application which is using an IoC container. Now I need some helper methods for array manipulation like set, get, etc. I see two possible ways to go: Using a class with static ...
5
votes
1answer
90 views

Object-Oriented design to create Images in Python

I'm creating images with centered text. I use Python but I'm faced with many question regarding how to write my class. I know that A class must aim to do one thing and do it well. Well, the ...
4
votes
2answers
798 views

Should all, none, or some overridden methods call Super?

When designing a class, how do you decide when all overridden methods should call super or when none of the overridden methods should call super? Also, is it considered bad practice if your code logic ...
4
votes
4answers
3k views

Is this the correct approach to an OOP design structure in php?

I'm converting a procedural based site to an OOP design to allow more easily manageable code in the future and so far have created the following structure: /classes /templates index.php With these ...
1
vote
1answer
88 views

Setting up my inheritance model?

I'm working on refactoring a synchronization web app that our company uses. Currently it's merely a set of controllers that fire up a set of helpers that go through a long chain of if-else type ...
16
votes
6answers
3k views

Use verbs with functions, nouns with classes - what about interfaces? [closed]

Ok, I understand the normal conventions of using verbs with functions and nouns with classes. What about interfaces? Is there any methodology when coming up with interface names that may not be that ...
3
votes
1answer
147 views

For what reasons would you use a separate class extension for each delegate in Swift?

I was working through a Ray Wenderlich tutorial and noticed that the author uses class extensions to hold delegate callbacks rather than having them be handled in the class itself i.e.: delegate ...
8
votes
5answers
2k views

A programming language that does not allow IO. Haskell is not a pure language

Are there any 100% pure languages (as I describe in the Stack Overflow post) out there already and if so, could they feasibly be used to actually do stuff? i.e. do they have an implementation? I'm not ...
1
vote
1answer
101 views

Template method pattern - abstract classes vs interface delegation

Template method pattern is commonly implemented with abstract classes. interface Algorithm { void perform(); } abstract class AlgorithmBase implements Algorithm { abstract void step1(); ...
5
votes
1answer
116 views

Testing procedural code

TL;DR. Writing procedural code within a DB transaction. How can I improve design of the code so it's better testable? In my application I have a service object that perform multiple things within the ...
3
votes
2answers
181 views

Where to put very specialised functions which heavily use one class?

I have a class which is centred around lower-level methods, to make this class much more useful it would be great to put some middle or higher level methods (i.e. methods which make a series of calls ...
1
vote
3answers
219 views

Factory of factories? [closed]

I have concrete factory classes which implement MyFactory interface. I want to get concrete factory objects based on parameter. How to do this? One way is to create factory of factories[FoF], and ...
8
votes
3answers
438 views

Would it be better to have extra checks, or would it be a waste of time? [duplicate]

In your opinion, do you think it is a waste of time to make checks that you know there is no possible way of it being there/not being there, or would you just put it there just in case there is a bug ...
2
votes
2answers
142 views

How to handle multiple models that relate to a single model

First of, sorry for the vague title. In our website framework, we have modal classes to represent our database tables, that hold a rows data. I'm currently working on a stat style page, and I'm ...
2
votes
2answers
137 views

Private variables and the old FORTRAN common blocks [closed]

This is a question that perplexes me about object oriented programming. In some OOP languages (e.g. C++) a member function can access private variables of the class without restriction. That means ...
1
vote
0answers
472 views

DataMapper for a MMO game plugin to send packets [closed]

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 ...