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
15 views

Lock object in base class: private or protected?

I have a base class that contains some lists, queues, and other fields which determine its state. In the base class I only access these fields within a protected lock object since there could be ...
2
votes
0answers
19 views

What design pattern is used in this delegating scenario?

I am currently having to bend some framework API to fit my usecase. The framework provides generic interfaces such as public interface Processor<T> { T process(T t); } with various ...
4
votes
2answers
54 views

Sets of pair parameters

I have the following class, this class like many rely one parameters coming in as a pair. Originally for convenience, I set them as params Object[] values and check if there is an even number of them ...
1
vote
1answer
28 views

PHP MVC Model with a method to fetch all of the model from database

I have a crazy question, consider I'm developing a blog website, There is two model named Post and Comment, now I wanna add a method to fetch all comments from database, which model should I choose to ...
0
votes
0answers
78 views

How much is Uncle Bob's definition of OOP compatible with the mainstream definition? [on hold]

How much is Uncle Bob's definition of OO compatible with the mainstream definition? Uncle Bob in his Clean Coders series mentions and gives solid arguments that OO is basically about sending ...
-6
votes
0answers
42 views

Noob Question: Need explanation of abstraction, inheritance, polymorphism, and encapsulation! [on hold]

I know, I know. This is a really nooby question, but can somebody please explain these OOP concepts. I have read many explanations, but I only half understand it. I want to understand each concept ...
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 { ...
23
votes
11answers
3k 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
101 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
70 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
81 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
22 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
177 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
126 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
126 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
36 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
41 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
238 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
222 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
292 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
88 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
66 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
89 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 && ...
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
195 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
124 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 ...