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
0answers
14 views

C# gets an enum, but doesn't work correctly with switch statement [migrated]

Im having some trouble with enums and then checking it with a switch statement. I'm not sure if I'm doing something super wrong, but I don't get any errors so hey. # Level.cs enum LevelID { ...
11
votes
8answers
882 views

Constructor-only subclasses: Is this an anti-pattern?

I was having a discussion with a co-worker, and we ended up having conflicting intuitions about the purpose of subclassing. My intuition is that if a primary function of a subclass is to express a ...
1
vote
1answer
97 views

Problems with OO design for application with pluggable components

I'm trying to refactor an ugly code and make it easly extendable in the future. The application should be nothing else but a series of components that have input(s) and output(s). The components ...
0
votes
1answer
68 views

Database object mapping, good practices [on hold]

I think I've understood the basic idea behind object mapping but there is one gap in my knowledge base that I hope to fill now. First let me tell you what I understand out of the whole thing. I have ...
0
votes
2answers
53 views

PHP extended class method requires same signature including object class requirement? [duplicate]

Not sure exactly how to phrase the question succinctly for the title. I have a collection class that extends another collection class. The parent collection-class has a method addMember(someClass ...
0
votes
2answers
80 views

How is a dictionary better than a big switch, when mapping data to action? [duplicate]

Often times we see stuff like that in code: void myFunction(string someValue) { if (someValue == "a") { // ... } else if (someValue == "b") { // ... } else if (someValue == ...
-2
votes
0answers
21 views

Estimating OOA&D timeframes [closed]

I'm not a CS grad just know HTML and Wordpress :( but am teaching myself OOP and am trying get an idea of how long it typically takes developers to do all the OOA&D for a website like Airbnb or ...
-2
votes
1answer
176 views

Why every value is an object in python?

I know about writing programs (using C) that have: Data values, that are manipulated. For example: integer, float values etc.. functions (rules), by which data values are manipulated. object is a ...
0
votes
1answer
125 views

Get inspired by real world objects and their interactions [closed]

Based on this question I think while the aim of OOP is not necessarily to copy real world objects, they could be source of inspiration to design a software or solve a problem or even learn the OOP ...
1
vote
2answers
125 views

Smells in exception handling: how to separate between public and internal exceptions?

During the development of a small web API, we decided to separate internal exceptions from public exceptions. Public exceptions are HTTP exceptions, that translate into HTTP responses with proper ...
56
votes
11answers
7k views

Why is base-for-all-objects discouraged in C++

Stroustrup says "Don’t immediately invent a unique base for all of your classes (an Object class). Typically, you can do better without it for many/most classes." (The C++ Programming Language Fourth ...
1
vote
0answers
35 views

Injecting data processing logic into class

I want find more elegant and appreciate way to inject processors into CommandProcessorDispatcher class. Or it can be another one solution (the goal is separate each command processing logic to ...
0
votes
0answers
39 views

How and where to make global function file in jsp sevlet web application

I am making a website in Servlet&JSP. I am looking for good way to make a specific function file from where I can call and declare my common functions. If I made a java file function. Java, so is ...
0
votes
2answers
101 views

Organizing C++ Components [closed]

In my current company we've brought the discussion about how to organize most of our different C++ components considering the following requirements: There might be interdependencies between ...
2
votes
3answers
86 views

Enterprise application object oriented modeling for user and role

Generally in the Enterprise Applications like ERP or ERM, CRM, BP etc. we see two things a lot, one of them is Role and the other one is User. What happens is that in the real world we have some ...
2
votes
1answer
115 views

Object Oriented Analysis and Design workflow for developer working alone

Studying about OOAD I've found a simple workflow based on five steps. I don't work with a team, so what I'm interested in is a workflow that can be used by a developer working alone. The workflow I ...
0
votes
1answer
92 views

Protected properties vs protected getters

If I have an abstract Animal class with a $name property and constructor like this: abstract class Animal { protected $name; public function __construct($name) { $this->name = $name; ...
0
votes
2answers
237 views

What is the rule for nested loop code?

I am new to programming and currently learning Java from Stanford free learning course. There was this assignment that I had trouble translating my algorithm into code. I feel like I have a ...
17
votes
7answers
3k views

Why is instance creation the way it is?

I've learned C# over the course of the past six months or so and am now delving into Java. My question is about instance creation (in either language, really) and it's more of: I wonder why they did ...
1
vote
0answers
64 views

Is this pattern of optional dependency injection sound? [duplicate]

A lot of the time when working on legacy code bases, I find it hard to move manually created dependencies to the constructor parameters, because of a variety of reasons. Sometimes it's because the ...
7
votes
8answers
2k views

Relation between object orientation and algorithms

As I read some algorithms textbooks, they are full of clever procedures for some problems (sorting, shortest path) or some general methods (recursive algorithms, divide and conquer, dynamic ...
5
votes
3answers
221 views

Is prototypal inheritance inherently slower?

I see Javascript 6 will add traditional class based inheritance, and one argument I hear is that classes are inherently much faster than prototypes because they can be optimized away by the compiler ...
0
votes
3answers
290 views

Overriding equals() method in Java

Short question: Why does Java allow overriding equals(), why is it not final? I am reading Effective Java 2nd edition by Joshua Bloch. I am a bit baffled by the conclusion that There is no way to ...
0
votes
1answer
101 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 ...
6
votes
2answers
290 views

What is the difference between Optionals and Nullable type

Swift has Optionals. C# has Nullable types. As far as I can tell both serve same purpose, besides value of some type they store information whether variable has value or is undefined ...
1
vote
3answers
135 views

Controller in MVC

Alright so it is an essential part of OOP that one class should only do one thing, and it makes sense. In practice I've seen that classes which don't obey this rule get thick and cluttered. So I was ...
20
votes
4answers
1k views

Why would many duck-typed dynamic programming languages use a class-based approach instead of prototype-based OOP?

Since quite many dynamic programming languages have the feature of duck typing, and they can also open up and modify class or instance methods at anytime (like Ruby and Python), then… Question 1) ...
0
votes
1answer
86 views

Statistics about the usage of programming paradigms [closed]

I hear very often that the object-oriented programming paradigm is the most widespread. But are there any scientific statistics about how often other programming paradigms like procedural programming ...
0
votes
3answers
128 views

Should abstract classes be used to prevent instantiation

Is preventing the instantiation of a class a valid reason to make it abstract? For example, if I have a class called Gauge which has subclasses HeadingIndicator and AirSpeedIndicator, is it a good ...
3
votes
1answer
102 views

Creating variables in methods/functions

In how far do we create variables in our methods or functions? Do we only create one when we're using the result of the variable more then one time like this? function someFunction(SomeClass ...
1
vote
4answers
236 views

When is it not acceptable to model physical world objects with classes?

Does Object Oriented Programming Really Model The Real World? [closed] also "Firstly, A represents an object in the physical world, which is a strong argument for not splitting the class up." ...
1
vote
1answer
65 views

PHP MVC Display many records - model logic

I bet this question has been asked already but I can't form my thought as you can see from the title, so I couldn't find anything. I am working with MVC for quite some time now and I'm pretty happy to ...
2
votes
1answer
88 views

Proper way to refactor multiple if based conditions [duplicate]

I took over a large legacy code base. It has a code like this: if ($route == 'login' || $route == 'logout' || $route == 'forgot-password') { return; } if ($loggedInUser == false && ...
-1
votes
0answers
54 views

Is partial application of functions the corresponding technique for state saving objects?

Imagine we have Converter object which is responsible for converting Strings in different ways, e.g. with convertingMethod1 and convertingMethod2. As the Converter depends on some context, it also ...
16
votes
6answers
986 views

Does functional programming increase the 'representational gap' between problems and solutions? [closed]

Since machine language (e.g., 0110101000110101) computer languages have generally evolved to higher forms of abstraction, generally making it easier to understand the code when it's applied to a ...
2
votes
1answer
194 views

Why do mainstream OO languages not have immutability on class-level built-in? [duplicate]

I regularly write classes which can only have immutable instances, much like string. I am wondering why Java or C# or VB.NET don't have immutability built-in into the language? That way, I can ...
0
votes
1answer
66 views

Condition before statement or statement in condition

I've come across this problem a few times: Is there any "programming rule" for checking for an condition (error checking for example) before you want to do execute code, or only execute the code when ...
0
votes
3answers
80 views

Heuristics on when should one subclass and when not [closed]

Are there any good tips, when one should subclass and when should not? It's clear that we should not subclass when we want to reuse a single method of some class we override all methods, changing ...
5
votes
1answer
113 views

How to use OO Design to Refactor a Library with Functions that are specific Product-aware

I have a class that acts as a library of functions for various products. To compute its data, the function currently needs to be aware of all product names. Depending on which product calls the ...
-1
votes
1answer
98 views

Why is it said that a class represents an abstraction? [closed]

I think that abstraction represents only the essential things needed for the purpose as there are so many unnecessary properties. So why is it said that a class represents an abstraction?
8
votes
5answers
2k views

class in OOP language and type

In programming language theory, a type is a set of values. E.g. the type "int" is the set of all integer values. In OOP languages, a class is a type, is it? When a class is defined with more than ...
2
votes
2answers
107 views

Initialize physical resources in constructor

Is it an acceptable practice to initialize physical/external resources from a constructor when the resource is needed for the object to do it's work? For instance, let's say I wanted to create an ...
-4
votes
1answer
155 views

object oriented programming vs. object oriented design [closed]

We know what is object oriented programming but my question is: What is the difference between object oriented programming and object oriented design?
4
votes
4answers
317 views

Does Object Orientation require the concept of inheritance? [closed]

I read Object-Oriented Analysis and Design with Applications Notes written by Grady Booch. In the book there is a sentence: There are three important parts to this definition: (1) Object-oriented ...
2
votes
2answers
123 views

Can a class method be accessed both in an instance and statically?

I am relatively new to class design and I have a task that I'm not sure how best to complete, or whether my idea in general is a code smell. I'm developing a RPG where people can own monsters, so ...
0
votes
4answers
223 views

How should nodes in a chain be connected?

Suppose you were building a system that receives data on one end and sends filtered data on the other end. The system is a chain of nodes, each receiving data from the node before and sending ...
1
vote
4answers
187 views

What is the efficient way to eliminate duplication? Design patterns?

I have a helper class which has a method that perform some checks against a field in a model. I have two models, ModelA and ModelB, they have some similarities but not all. One of them is they both ...
0
votes
1answer
164 views

Interface or boolean?

I have a CustomObject class which has the abilities like being Clickable, KeyPressable and Movable. I created interfaces: IClickable, IKeyPressable and IMovable and make different CustomObject classes ...
1
vote
2answers
73 views

Parsing input into multiple subclasses

Lets say I have 10 xml message types that come into my program via some type of input (file, port, etc). I have 10 subclasses of a type Message to handle the unique needs of each message type. When a ...
2
votes
3answers
154 views

Good or bad idea to create a “fromJSON” static factory constructor for an object that is often created by parsing a JSON coming from API?

I have a "Product" POJO class in my app. A Product object can either be created in-app by the user or by parsing a json that comes from the API. Product has 20+ fields, but Im using only 2 here for ...