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
20 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 ...
0
votes
0answers
45 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
74 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
1answer
39 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 ...
-2
votes
2answers
197 views

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

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
155 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{ ...
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->...
4
votes
3answers
162 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
4answers
104 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
1answer
54 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 ...
3
votes
3answers
171 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 ...
2
votes
2answers
116 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 ...
1
vote
4answers
165 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 ...
0
votes
1answer
76 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 ...
5
votes
1answer
272 views

Small classes and methods, but code still difficult to maintain and follow

Did I do something wrong in my code organization ? I still find my own program difficult to follow. I tried to decompose my program on small, easy to understand classes and functions, still I find ...
1
vote
1answer
75 views

Polymorphic constants in Java

I am designing some polymorphic code to perform mathematical operations. The idea is to abstract out the underlying representation of the data, as different use cases require different representations....
2
votes
1answer
90 views

Is it anti-pattern to alter domain model on front end?

We are making a quiz application, I'm trying to integrate my Angular 2 UI with the REST api. Our Quiz domain model consist of the following (simplified) hierarchy: -Quiz -Category -Question -Choice ...
0
votes
1answer
198 views

Are there any flaws or oversights in the design of my OO video game inventory system?

I'm making a video game and and I would like to know if my OO Inventory System has any flaws or oversightes. Here is the the item system anything that can be stored in an inventory system is an item....
3
votes
2answers
87 views

Could this be called a decorator pattern?

I want to add some extra methods closely related to Book without extending Book. So I found the decorator pattern. Most examples I have seen are eg. extending an abstract decorator class which ...
0
votes
0answers
48 views

How should i handle deeply nested data with codeigniter/mvc?

I want to build a website with categories, pages, sections and slides. Hierarchically it should look something like this: [category 1] [page 1] [section 1] [slide 1] ...
2
votes
3answers
166 views

How to gently steer a giant PHP app toward better practices? [duplicate]

So I'm responsible for maintaining and enhancing a PHP codebase that runs to around 1,100 files and 120,000 lines of code. In general, it's not terrible, although since it was written over some 10+ ...
0
votes
1answer
109 views

Is it wrong to call a “non-static nested class” an “inner class” in Java?

I was reading this question in SO, and it contains the following: A non-static nested class (sometimes incorrectly referred to as an 'inner class') (...) And it confused me. At 350+ upvotes, I ...
0
votes
1answer
82 views

Dependency Injection (DI) and Dependency Inversion Principle (DIP) for built-in functions and external libraries

Question I apologize if this question has already been posted. I tried searching but I couldn't find the answer. I often find myself trying to use DI and DIP where I need to open a file or a socket. ...
10
votes
2answers
517 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 ...
3
votes
1answer
120 views

Create different classes for staffers and users?

I am building a program for a law firm. When a staffer is active (i.e. still works at the firm) he has a password to login the program; When a staffer is inactive (i.e. no longer works at the firm) ...
0
votes
1answer
45 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
1answer
81 views

Need help with figuring out a better method of my application layout, please

I am working as the sole .Net developer at a company and I have been tasked with a very large and complex project, an internal intranet site for inventory and time tracking. I have built a project ...
12
votes
4answers
3k views

Can a C struct behave like it had a function?

I use C and structs where a struct can have members but not functions. Assume for simplicity that I want to create a struct for strings that I name str and I want to be able to do str.replace(int i, ...
5
votes
5answers
306 views

Do you generally send objects or their member variables into functions?

Which is generally accepted practice between these two cases: function insertIntoDatabase(Account account, Otherthing thing) { database.insertMethod(account.getId(), thing.getId(), thing....
5
votes
1answer
230 views

Why does this shared buffer work?

Background The following code snippet is taken from a problem in, Visual C# 2005: How to Program, by Paul and Harvey Deitel (pp. 735). The code snippet is more or less an application for accessing ...
17
votes
5answers
3k views

When to use inheritance, when to use 'just a boolean field'?

In our Rails application, we are adding notifications. Some of these are blocking: They stop the progress of whatever resource they are added on, because some information on that resource is missing. ...
2
votes
2answers
134 views

Placing preconditions in the right place

I am trying to figure out the best way to define the responsibility of checking preconditions. Let's consider the following case: we have an Event class representing a sports event and a Matchup ...
0
votes
0answers
27 views

I am trying to make a function with that returns true/false if an element is in the vector but I am getting an error? [migrated]

I am trying to implement a function in C++ using STL which takes an object and a vector of objects and return true if the vector contains the object else false. Below is the implementation of the ...
2
votes
5answers
339 views

Why do I need to declare virtual functions as such?

Example: We have a base class Base and three subclasses which all implement their own version of doSomething(). In an intermediate function f(Base b), we want to call the relevant version of ...
2
votes
2answers
96 views

C++ vs Java: Pointing to Objects

In Java: private State current_state; As "State" is a superclass, I can then assign subclass objects to current_state, effectively making current_state point to a different object: current_state = ...
3
votes
2answers
87 views

Creating Instances from same SuperClass Object

I have 3 subclasses (LowState, MediumState, HighState) which derive from the same superclass (State). Within the superclass, State, I have declared several variables which need to be accessed and ...
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 ...
5
votes
3answers
142 views

Breaking large class into smaller classes when they need a common state?

I am writing a parser for a fairly complicated language in C++. The Parser class is given a list of tokens and it builds the AST. Though only a part of the parser is completed, the Parser.cpp file is ...
-1
votes
3answers
55 views

What do you call the two types of classes on a instance declaration

When you declare a new instance of a class, you do so in a lot of languages as: MyClass obj = new MyClass(); The two MyClass mean subtly different things, often you will see: IMyClass obj = new ...
-4
votes
2answers
177 views

OOP project design

here is the UML class diagram subscribe method is used to add a herbivore object to the plant's watchers. when a plant is told to notify, itloops through all of the herbivore object in its watchers ...
2
votes
2answers
186 views

How to avoid circular reference in OOP Javascript?

I have a problem while working with entity framework in JavaScript. I have two classes Table and Column Class Table { Columns: Column[] } Class Column { Parent: Table } Everything works fine until ...
4
votes
4answers
137 views

Serializing mutating objects

In our system a media file can have several states: invalid, empty, uploading, ingesting, ready… Depending of the state, information about the media are accessed in different ways. For example, during ...
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
3answers
165 views

Is data duplication bad in programming (in contrast to database designing)?

I have three classes: User, Conversation and Message: Message properties: User sender; // Some more Conversation properties: List<Message> messages; List<User> participants; // Some ...
3
votes
4answers
227 views

From the perspective of OOP, taking performance into account - should a database connection be a static field, an instance field, or a local variable?

When methods use a database connection, should the connection be a static field, an instance field, or a local variable? Here are my doubts. I dithered which are correct and which are baseless. I ...
0
votes
2answers
242 views

Don't auto-implemented properties violate encapsulation?

In C#, when a field getting or setting requires logic, we use properties. For example: private int _age; public int Age { get { Console.Writeline("Club member is {0} years old", _age);...
1
vote
3answers
99 views

Xml Messages: One Type to Rule Them All?

My job involves a project that has a lot of different pieces that all need to communicate via XML messages. There are two schools of thought on how these messages should be organized. In reality ...
46
votes
10answers
6k views

Should we avoid custom objects as parameters?

Suppose I have a custom object, Student: public class Student{ public int _id; public String name; public int age; public float score; } And a class, Window, that is used to show ...