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
3answers
670 views

What are the valid uses of static classes?

I noticed that nearly every time I see programmers using static classes in object oriented languages such as C#, they are doing it wrong. The major problems are obviously the global state and the ...
2
votes
1answer
67 views

SRP and Getters/Encapsulation

I recently watched this presentation of Robert C. Martin about the Single Responsibility Principle: https://www.youtube.com/watch?v=Gt0M_OHKhQE He presents an Employee class with multiple ...
0
votes
0answers
59 views

What is the use of stateless object? [on hold]

While it is possible to create a stateless object, I am curious to know a use case or advantage of the same. If a stateless object is created for only providing the behavior then I would prefer static ...
4
votes
2answers
215 views

Why override a static method of an abstract base class?

I'm working on C# code where a static method of an abstract base class is being overridden by the class that inherits the base class. Why is this being done? I thought that only a virtual method of an ...
-3
votes
1answer
58 views

Polymorphism: How to explain it? [on hold]

I was having a conversation with a stranger in which they asked me to explain Polymorphism. I told him that to implement Polymorphism you'll need at least 2 classes, or more generally, 2 things. They ...
4
votes
2answers
135 views

Fix a leaky abstraction (type checking)

I have a method that accepts an interface and does type checking on the parameter, and depending upon the type a decision is made to either send an email or an alert public void ...
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 ...
6
votes
2answers
2k views

Why do we need an instance of the Scanner Class to get an Input on Java?

Java is object oriented, but, why do we need to create an object from the Scanner Class to get input? Couldn't next() methods, for example, just be Static? C looks to me pretty simpler as you just ...
0
votes
1answer
283 views

What is the convention regarding class names that may already exist in the ORM? [closed]

This is a generic question about class names and ORMs, but for context; I'm working on a Flask web app in Python using SQLalchemy. I'm struggling with naming a new class that will contain the ...
3
votes
2answers
416 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: ...
5
votes
1answer
91 views

Clean Architecture - How to go from “Database Driven” to “Independent of Database” [on hold]

I am looking for some clarity and hopefully some advice on writing clean architecture for a large system. My Companies "Web Solution" is +-10 years old, my job is to rewrite it. It is written across a ...
1
vote
1answer
66 views

Pass data into a constructor or instead create virtual methods?

In an object oriented module describing a database, should I pass DB description data structures to the constructor in the constructors of derived classes, or should I instead create ("virtual" that ...
2
votes
2answers
65 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 ...
7
votes
4answers
856 views

Should Objects with lots of fields be broken up? [duplicate]

When I have an Object that has lots of fields is it better to have them all as fields or try to find logical groupings as their own Objects and make those the fields? I guess it comes down to which ...
1
vote
3answers
428 views

C: “this” vs “<instance name>”

I'm using C in a minimal, efficient OOP style to build a game engine. A problem I've begun to face as the engine code settles is my (erstwhile) choice to use this. For example, I have: void ...
2
votes
1answer
388 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 ...
5
votes
1answer
100 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: ...
1
vote
2answers
277 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) { ...
7
votes
2answers
207 views

Should well-known business ID of an entity be represented with a dedicated type in DDD/OOP?

In practical terms it means using an custom (immutable) class over a string or some other primitive type. Examples: Publishing: International Standard Book Number. Finance: International Securities ...
1
vote
1answer
81 views

Pattern for passing in a field as a parameter

I'm writing a Rails app which uses ActiveRecord ORM and a Postgres DB. I've got two attributes which are similar but are separate fields in the database. The assignment and saving of these is kinda ...
2
votes
4answers
240 views

Good practice for holding immutable data

I'm wondering what is the best practice for holding immutable data, more specifically in C#. For instance, lets say I have an immutable object called Foo. public sealed class Foo { public int ...
0
votes
3answers
279 views

Unable to convince on data hiding

I am working on a Selenium + java project where all Web Element in a class are declared as - public class CheckoutPaymentConfirmpage extends WebPage{ public final Button btnPrintorder = new ...
2
votes
1answer
365 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 ...
3
votes
3answers
282 views

'Encapsulation Vs Performance' trade-off in a lockable linked list

Main purpose of encapsulation is to protect in-variants of any class(in java). Here is the complete code for class DList/class lockDList/class DListNode/class LockDListNode. class DList and it's ...
11
votes
2answers
654 views

DRY principle in good practices?

I am trying to follow the DRY principle in my programming as hard as I can. Recently I have been learning design patterns in OOP and I have ended up repeating myself quite a bunch. I have created a ...
21
votes
3answers
3k views

The principle of least knowledge

I understand the motive behind the principle of least knowledge, but I find some disadvantages if I try to apply it in my design. One of the examples of this principle (actually how not to use it), ...
4
votes
1answer
53 views

Should domain model be intelligent or there must be services, which operate it?

I'm building a web-app for a licensing service. My domain models are Licenses, and they can be of two types at the moment: server and client license. They are almost same, except server license has ...
2
votes
2answers
137 views

Refactoring wordy conditional tests [duplicate]

My first attempt at this question was too theoretical, so I've rewritten it with actual code. See the edit history if you care. Supposing this logic, "suffering" from the arrow anti-pattern: /** ...
1
vote
4answers
207 views

OOP Principles in Customer and Account classes of a Bank

I am designing a Bank Application which deals with Customers having FD Accounts. There are two approaches to this : Approach 1 In this the customer has a list of accounts. The bank application ...
1
vote
3answers
124 views

How to understand if a property is a member of a class or I have to create a different class that holds it?

Sometimes when you create a class you can add there several properties (new data members) that you are not certain if you want to do or not. For example, I have a casino slots game. I have tiles and ...
0
votes
4answers
220 views

How to represent an algorithm as a class?

I am trying to understand how to design classes which take an input, do some processing, and return a result. More specifically, should the object store the intermediate results between function calls ...
0
votes
0answers
58 views

Execute a method upon loading a class [migrated]

I need to have a static constructor. I was always wondering why there is no support for this functionality. I need to run a function once when the class is loaded, currently the way I've seen it done ...
7
votes
2answers
538 views

Dependency Inversion Principle: Understanding how both low level components and high level components depend on abstractions

I'm learning about the Dependency Inversion Principle. It states that: High level modules should not depend upon low-level modules. Both should depend upon abstractions. For a while I tried to ...
3
votes
1answer
411 views

What is interaction oriented programming? [closed]

There is this new kid on the block called Interaction Oriented Programming (IOP). Can somebody explain how it works? How does it compare to object oriented programming? Will this replace object ...
1
vote
2answers
134 views

How can I create a 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 ...
1
vote
1answer
181 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 ...
4
votes
3answers
11k views

Confused about the definition of 'abstraction' in OOP

I am trying to understand the definition of 'abstraction' in OOP. I have come across a few main definitions. Are they all valid? Is one of them wrong? I'm confused. (I re-wrote the definition with my ...
1
vote
1answer
110 views

How to watch a message queue properly

I have a scenario where I need to 'watch' an Amazon queue. When a message arrives I need to get this message and process it. Right now this is implemented with a do/while and Thread.Sleep when no ...
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
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
132 views

Should I force the user to wrap the arguments, or allow them to pass in the data at the cost of having more arguments?

I have the constructor: public class Player { final private DoubleDuple position; final private DoubleDuple momentum; public Player(double xPos, double yPos, double xMom, double yMom) { ...
4
votes
1answer
250 views

Advantages and drawbacks of different ways using Either-types

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 ...
0
votes
1answer
31 views

What is a receiver in SWT (or GUI programming in general)?

I see this notation used throughout documentation and discussions on SWT, but I've yet to see it actually defined. The comment on Stack Overflow by MarsAtomic makes me think it is just the object that ...
4
votes
1answer
56 views

Best practice for defining and keeping related stateless methods together in Objective-C

I have a few methods which are stateless: loginWithEmail: password: completion: signUpWithEmail: password: completion: resetPasswordForUsername: completion: Currently what I do is I create a class ...
0
votes
2answers
473 views

Emulation of MMU accessing the contents of the registers

I'm having a play around with emulating a simple old CPU. I've set the structure up, so far anyway, as follows: The device is the main and creates an instance of the CPU. The CPU then creates ...
1
vote
1answer
363 views

Is it possible to avoid a lot of using statements?

Lets say I have a simple code like this (fiddleLink): using System; public class Program { public static void Main() { //Dependency register logic here var service = new ...
30
votes
6answers
6k views

LSP vs OCP / Liskov Substitution VS Open Close

I am trying to understand the SOLID principles of OOP and I've come to the conclusion that LSP and OCP have some similarities (if not to say more). the open/closed principle states "software ...
1
vote
2answers
140 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 ...
0
votes
2answers
115 views

How should I structure these Python classes?

Base Class I have a class called Remote. This class represents a remote machine and has properties such as ip, hostname, username, and password, as well as methods for transferring files to/from the ...
16
votes
5answers
6k views

Using static classes as namespaces

I have seen other developers using static classes as namespaces public static class CategoryA { public class Item1 { public void DoSomething() { } } public class Item2 { ...