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)

2
votes
3answers
382 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 ...
0
votes
0answers
13 views

Design from API documentation to code

I have a full API documentation made of uris, request and response bodies ready to use. Uris are all externals, and I have to first visit an entry point that'll give me a token, and then use that ...
0
votes
2answers
64 views

How to calculate new property for old records efficiently?

Let's say we have classes something like this: public class Item1{ public Guid Id {get; set;} public string Name {get; set;} public decimal Price {get; set;} public int Quantity {get; ...
0
votes
0answers
41 views

Should I split function reference into a class reference and method reference?

We have code like ['Index::Show::AjaxPost', ...] which references a function AjaxPost in Index::Show module. I was ordained to refactor it in object oriented manner. Should I split it into [['Index::...
7
votes
6answers
5k views

Understanding “programming to an interface”

I have come across the term "programming to an interface instead of an implementation" a lot, and I think I kind of understand what it means. But I want to make sure I understand it's benefits and it'...
-3
votes
1answer
281 views

What is disinheritance in object oriented programming? [on hold]

I am confused over Virtual Inheritance and disinheritance ? Is both are same ?
0
votes
0answers
91 views

A modification of singleton pattern

"Singleton" is widely considered anti-pattern ("bad" in everyday language). What about this alternative modified singleton pattern? An object constructor for our class ensures that at any given ...
0
votes
2answers
77 views

Static factory method in base class

An increasingly popular definition of factory method is: a static method of a class that returns an object of that class' type. But unlike a constructor, the actual object it returns might be an ...
1
vote
1answer
95 views

What is the difference between ADTs and objects? [closed]

This question was answered in "Understanding Abstract Data Types (ADTs)", and the top voted answerer (by Frank Shearar) is currently as follows: Objects are not ADTs (*) [editor's note: Links to "...
0
votes
0answers
29 views

Choosing class names and relations for different user scopes

I am developing an online Order Management System using PHP in which I have some different behavioural scopes regarding the User class: some user scope under which the chronological transactions are ...
14
votes
9answers
12k views

Use constructor or setter method?

I am working on a UI code where I have an Action class, something like this - public class MyAction extends Action { public MyAction() { setText("My Action Text"); setToolTip("My ...
2
votes
1answer
41 views

Where should view-specific data/logic be defined in a PHP MVC application?

After many hours of research and thinking I have found an understanding, then coming to question it again, I am struggling to find something concrete which I can grasp and apply to my code in a ...
0
votes
0answers
51 views

How to search through an array of objects?

I am using an array of objects to store data to render a page. A few examples of data an object can contain: PHP filepath for an include CSS filepath for CSS files Meta data of the page Element ...
1
vote
2answers
76 views

How do you represent an object when you need to know which subtype you're working with?

I have some data that I need to represent in a form. As an example, it might look like this (in psuedo-json): [ { "value1" : "int" "value2" : "{1, 2, 3, 4, 5}" "value3" : "...
-2
votes
2answers
211 views

Is it normal for a graduate to be overwhelmed when looking at other's code? [closed]

I'm a recent graduate, applying for a junior programming position (.NET). I've spoken with a few companies already, some of which I met through a recruiter. I like one of them a lot, but I'm worried I ...
0
votes
1answer
160 views

Should I force “composition over inheritance” rule to class members?

As I know, according to "composition over inheritance" rule, we should avoid reuse a method by inheritance, but how about class members? Suppose I have parent and child classes: public class Animal{ ...
7
votes
3answers
301 views

Is mutually referencing classes a consequence of bad design? [closed]

I am currently working on a small game I did in about ten days. Since I am programming for myself, I am being lazy and going to the easiest solution with (too) little concern about bad code quality. ...
52
votes
17answers
6k views

Is OO-programming really as important as hiring companies place it? [closed]

I am just finishing my masters degree (in computing) and applying for jobs. I've noticed many companies specifically ask for an understanding of object orientation. Popular interview questions are ...
1
vote
3answers
95 views

Implementing an event scheduler for animations

The basic idea is to have some animated widgets that sit in a container, quite similar to Qt (the only actual difference is that my widgets are animated). The animation is in some cases dependent on ...
2
votes
2answers
201 views

Child class accessing its parent's method from Ancestor method

I find myself right now banging my head with the following issue (in PHP): I have an abstract base class, which has a non-abstract method, inherited and unchanged all over the inheritance chain (...
0
votes
0answers
41 views

Export a method vs using a boolean property in a class?

I am writing a base class with common code for several Web sites. Two of these sites have mobile support. Should I create (constant) boolean object property mobile_support and write if(site->...
3
votes
3answers
97 views

Ways to structure a program with 2 states

I'm working on some sort of a Level Editor but I'm not quite sure how I want to handle the two different states: The Editor state and the Player state. In this first state game elements can be moved ...
4
votes
3answers
167 views

Role and importance of static method in OOP

Background Thinking about OOP I feel that it binds data and behavior together, taking the real world example we already have array data type which is a collection of homogeneous type but in Java we ...
1
vote
1answer
55 views

Chain accessors or return the value of private pointer

hopefully the title isnt too confusing, I am having trouble thinking through what best-practice dictate I do in this situation. Say I have the following class structure Class A { public: bool ...
1
vote
4answers
105 views

ErrorAccumulator as an OO pattern

In the past couple of weeks I have seen a couple instances of people passing an ErrorAccumulator type of object into functions that aggregates errors as Strings inside of the function then after the ...
1
vote
2answers
163 views

Is a an object Necessary or can I still use a DataTable

I'm currently working on a fund project and I have it set up so I get the holdings from my database and store in in to a DataTable to process. I've created a function where my Database results are ...
138
votes
13answers
89k views

Why do we need private variables?

Why do we need private variables in classes? Every book on programming I've read says this is a private variable, this is how you define it but stops there. The wording of these explanations always ...
1
vote
4answers
259 views

Can the circle-ellipse problem be solved by reversing the relationship?

Having Circle extend Ellipse breaks the Liskov Substition Principle, because it modifies a postcondition: namely, you can set X and Y independently to draw an ellipse, but X must always equal Y for ...
4
votes
1answer
477 views

Should I declare the most specific type as return type of method?

In Android I can put only ArrayList of Parcelable objects in Intent: Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value); I can't put in there a List<? ...
4
votes
3answers
436 views

OOP and relational databases [duplicate]

I see a lot of talk in the OOP world about principles and laws such as Open/Close and Loose Coupling, I can understand how they are so high valued, However I seem to have ran into a problem with ...
3
votes
6answers
3k views

Criteria for a language to be considered “object oriented”

I had a discussion about OO programming today and by browsing the internet I found a lot of different specifications for object oriented languages. What are the requirements for a language to be ...
75
votes
13answers
8k views

Do objects in OOP have to represent an entity?

Does an object have to represent an entity? By an entity I mean something like a Product, Motor, a ParkingLot etc, a physical, or even a clear-cut non-physical conceptual object -- something that ...
3
votes
3answers
175 views

optional data in the constructor, bad practice?

Currently I have a model class that represents a user. This class has a constructor that takes an object with all user properties, used for example, when creating the user. In this case I instantiate ...
0
votes
3answers
228 views

DDD Request Validation Handling

I stuck somewhere that I can't find a solution! There are plenty of validation questions here, but as far as I see, most of them were asking about entity validation. But what about request validation? ...
2
votes
2answers
117 views

Unit testing / How to validate private fields of a newly created object?

I have a basic unit test (for the sample) that involves this code: void testShouldCreateACar() { Car car = someone.createFerrari(); assertTrue(car.name == "Ferrari"); // can't access name since ...
4
votes
2answers
2k views

Should we mock entities and value objects when doing DDD?

After reading a few articles about Newable vs Injectable objects and how these concepts relate to DDD's services, entities and value objects, I was left with some doubts about using newables in my ...
7
votes
3answers
3k views

Event Driven Programming: A sequence of unfortunate events

I have a very basic game loop whose primary purpose is to check for updates & changes to a list. I have contemplated using event driven programming to replace the game loop/list idea with an ...
1
vote
1answer
27 views

Redesigning schedule value hierarchy

I have a couple of schedule value classes that represent the value a schedule holds for a specific slot. First, there's the ScheduleValue class for schedules with two dimensions, where the first one (...
0
votes
1answer
132 views

Question(s) about PHP PDO connections

Let's say I have a Db class [ db.php ] : <?php class Db { // class properties private $db_driver = ''; // dsn credentials private $db_dhost = ''; private $...
0
votes
1answer
77 views

Example of class modeling

This is in the continuation of Small classes and methods, but code still difficult to maintain and follow as I have matured the problem and will rebound on people's answers. Here are all the elements ...
1
vote
4answers
166 views

Where should “conversion” functions be placed?

I have a type Bound as a sort of "alias" for an array of three numbers (working in TypeScript with: type Bound = [number, number, number]). I did this basically to help readability by specifying in ...
24
votes
6answers
3k views

Is it okay for interfaces to contain a method which returns the concrete type of the implementation in form of a constant?

I very often get myself in a situation where I need a different behavior of a component which depends on the concrete type of a different Interface. To illustrate my question, I have written a small ...
4
votes
4answers
3k views

What is the difference between instantiating and loading a class in Java?

In Java world, there are some scenarios where I see developers used to load the class rather than instantiation. What is the difference between instantiating and loading a class?
2
votes
2answers
120 views

Design of object alias

Suppose you develop an interpreter or file system. There are objects, like variables, procedures and files in some environment. They have a name and content (variable has current value, procedure has ...
1
vote
1answer
126 views

How to compute Pricing of Product & Options based on User Option Selection and Pricing per Option

I am building a service for pricing options of a product and for pricing the product itself when product has various options. Example User selects some X options out of Y options available, where X &...
1
vote
4answers
1k 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. ...
15
votes
3answers
2k views

Are there any OO languages without inheritance?

During a code review today, a colleague of mine said something interesting: prototype is only useful when you need inheritance - and when's inheritance ever a good idea? I thought about this and ...
10
votes
2answers
520 views

Is it bad to create classes whose sole purpose is to be converted to another class implicitly?

Imagine a situation where we're using a library that allows you to create Circle objects, where you can specify the radius and the center of the circle to define it. However, for some reason, it also ...