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

Java constructors confusion? [closed]

public class example { private String one; private String two; public example(String one, String two) { this.one = one; this.two = two; } public static void ...
2
votes
1answer
119 views

Are nested private classes considered composition?

Background I am considering a design that includes a public API class containing many nested private classes. I am doing this for the following reasons: Why private nesting? They will have no use ...
5
votes
4answers
657 views

Does making a method static save memory on a class you'll have many instances of?

In response to Aaronaught's response to the question at: Can't I just use all static methods? Isn't less memory used for a static method? I am under the impression that each object instance carries ...
19
votes
5answers
4k views

Is it okay for a class to use its own public method?

Background I currently have a situation where I have an object that is both transmitted and received by a device. This message has several constructs, as follows: public void ReverseData() public ...
4
votes
3answers
181 views

What is the purpose of writing functions and methods? When should you make a snippet of code into a function or method?

I have a philosophical disagreement with one of my co-workers, and I'm trying to get back to basics here. What is the purpose of a method? In this question, consider this example. I was criticized ...
1
vote
1answer
113 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 ...
0
votes
0answers
79 views

How do I replicate my object-ish style from Python into Golang?

I've been going around in circles on this for a while Googling and reading, time to ask experts. When coding my common approach is to create a type of thing and add it to some sort of list with ...
4
votes
3answers
66 views

Using Multiple 'Sub-types' vs a larger single type?

I have a user model in an application that I'm working on, which currently uses sub-types to encapsulate properties depending on what type of user you are - I just can't help but think that this is ...
8
votes
4answers
2k views

Why would passing objects through static methods be advantageous?

Why would there be an advantage to use a static method and pass the reference to an object as a parameter rather than calling the method on an object? To clarify what I mean, consider the following ...
1
vote
2answers
129 views

Safety of magic setters in PHP

I don't know how in else languages, but in PHP seems to me that they are very unsafe way how to set value of any member variable - because one setter cannot easily validate input for many variables ...
9
votes
3answers
249 views

Are Python mixins an anti-pattern?

I'm fully aware that pylint and other static analysis tools are not all-knowing, and sometimes their advice must be disobeyed. (This applies for various classes of messages, not just conventions.) ...
3
votes
1answer
106 views

Avoiding tightly coupled class definitions in Python for has-a relationships

I have the following code: class Car(object): def __init__(self, my_id): self.my_id = my_id self.color = color self.brand = brand self.get_color() ...
11
votes
4answers
874 views

Why is there no consistent definition of essential concepts to OOP?

I am very new to coding and a bit confused from reading\hearing different conventions from different sources: Does Object-oriented programming have 4 or 5 concepts? As a newcomer, I understand these ...
17
votes
5answers
1k views

best way to “introduce” OOP/OOD to team of experienced C++ engineers

I am looking for an efficient way, that also doesn't come off as an insult, to introduce OOP concepts to existing team members? My teammates are not new to OO languages. We've been doing C++/C# for ...
-1
votes
1answer
131 views

Does this pattern have a name?

I have a large XML file that I extract information from. I am extracting the information using a list of classes with a main method of the type ParsedValue[] GetValue(BigXmlFile). This is a bit like ...
5
votes
1answer
436 views

Are we abusing static methods?

A couple of months ago I started working in a new project, and when going through the code it stroke me the amount of static methods used. Not only utility methods as ...
7
votes
2answers
254 views

Object reading from file, violation of SRP?

I am writing a physics simulation program in C++. I am a novice in OOP and C++. In my program, several objects need to be initialized based on data from an input file. For example, an imaginary ...
5
votes
2answers
85 views

Should Modelling Document Analysis?

I use UML I, like most (I think), use UML as my main diagramming toolset. UML is clear and useful for representing OOP and has sufficiently diverse diagrams that there is something for whatever area ...
1
vote
4answers
100 views

File-Directory Implementation: Does a a file have to own a reference to it's dir?

I am currently issuing a problem while forming the program-design, which is exact like a File-Directory relationship, and to ease it, I am using that as an example. I think it is usual, that a ...
2
votes
2answers
79 views

How do I decide whether to make an Input/Output data type an array or a class?

I have some input that I send to a computational library, which processes the input and produces some output. Question: What considerations do I take into account to help me decide whether the ...
6
votes
5answers
1k views

PHP - Internal APIs/Libraries - What makes sense?

I've been having a discussion lately with some colleagues about the best way to approach a new project, and thought it'd be interesting to get some external thoughts thrown into the mix. Basically, ...
4
votes
1answer
203 views

Do I have to stop using Dependency Injection to keep object debug printouts small?

Say I have a large object - think EntityManager of an ORM such as Doctrine, or a custom DAO object, or what have you. Object, output of which is required to be used inside a class, but the object ...
3
votes
1answer
194 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 ...
3
votes
1answer
91 views

PHP OOP, structuring my objects properly

I have an architecture similar to this: User (Name, Email, ID...) ---- Studios (Name, Location, Description...) ---------- Videos (Title, Description, URL, Length, Views...) Simply put, a user can ...
1
vote
0answers
114 views

OOP - Modeling a Chat Design Review [closed]

Seeking thoughts on the following design. I know the design could be lot simpler if use Sockets. But I wanted to think of a design with pure POJO classes. User string id; string displayname; ...
1
vote
0answers
53 views

Creating duplicate instances of objects for timeline functionality

I am working on a Spring-MVC based project, in which I would like to add Timeline functionality. The most important object in our project is the Note, there are objects associated with it like ...
82
votes
5answers
18k views

Functional Programming vs. OOP [closed]

I've heard a lot of talk about using functional languages such as Haskell as of late. What are some of the big differences, pros and cons of functional programming vs. object-oriented programming?
1
vote
5answers
149 views

Can variable names match field names? [closed]

Microsoft suggested that variable names should not match field names. However I saw this extensively in Java (e.g., this tutorial), especially in setters and constructors. So, among these two styles: ...
3
votes
0answers
81 views

How to think about a schedule that pulls from a database as objects

I am working on a personal project using Python. I have been using version control to the best of my abilities and if you would like to check it out and run the app ...
75
votes
22answers
22k views

Why is OOP difficult? [closed]

When I started using an object-oriented language (Java), I pretty much just went "Cool" and started coding. I've never really thought about it until only recently after having read lots of questions ...
3
votes
1answer
311 views

Bad c++ code design? [closed]

This is bothering me a long time. I feel like I am doing mistakes on the code design relative to the performance. I never had any teacher to indicate my mistakes so its hard to me to make it right in ...
2
votes
2answers
126 views

Abstraction on Iterator Pattern?

Recently, I had the task to implement a research project where I had to read an XML file. XML file contained a list of messages that I had to send to some other system on a specific port. Each message ...
37
votes
9answers
7k views

Explanation on how “Tell, Don't Ask” is considered good OO

This blogpost was posted on Hacker News with several upvotes. Coming from C++, most of these examples seem to go against what I've been taught. Such as example #2: Bad: def ...
3
votes
1answer
96 views

Snap to grid functionality in drawing application

I'm working on drawing application and I want to provide grid with snap to grid functionality. I'm trying to find the right way how to do that (ideally some design pattern), but I'm quite confused ...
0
votes
2answers
199 views

General term for T[], T*, and T& [closed]

An array of T, a pointer to T, and a reference to T (represented as T[], T*, and T& respectively by Type.ToString) all share the similarity that they are constructed from an "element" type (which ...
3
votes
1answer
116 views

Confused about approach I should take to designing classes for a card game

My primary goal is to create a Euchre game in Python. Euchre card games are rare on the Linux platform, no matter the language or the desktop flavor of choice. For now I want to be able to just ...
129
votes
12answers
82k 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 ...
2
votes
3answers
1k views

Are CK Metrics still considered useful? Is there an open source tool to help?

Chidamber & Kemerer proposed several metrics for object oriented code. Among them, depth of inheritance tree, weighted number of methods, number of member functions, number of children, and ...
2
votes
0answers
74 views

Confused about how to 'design' my (leaflet.js) map application; OOP

I asked another question recently regarding constructors calling constructors in order to organise my code properly but the answers really ended up giving me more questions than answers (which is good ...
3
votes
4answers
136 views

Low-level error handling

I am working with some low-level (by that I mean code that can't use C++ exceptions and/or the standard library) code that makes heavy use of classes. Basically, every class contains a bool ...
0
votes
1answer
35 views

Boolean flags in Presenters to control flow of execution

I can see people use boolean flags, especially in Controllers / Presenters, to control the flow of execution. For example, public void onButtonClicked() { hasButtonClicked=true // code here ...
0
votes
0answers
57 views

Concepting a Server - Handling Clients/Connections

I am writing the Server-Side of an Application, just for practicing my Java programming skills. I have made an attempt to program it, but I am not satisfied with my solution and I think it is because ...
3
votes
2answers
350 views

Cleanest way to expand a base class without explicitly mapping properties in C#

Lets assume I have following base class: public class Base { public int Id {get; set;} public string SomeText {get; set;} public string SomeOtherText {get; set;} public static Base ...
2
votes
3answers
141 views

Shall I call this “Multitasking” in OOP?

I am very new to programming and have this humble OOP-related question: Can we have a module in a OOP-manner written program, that contains 2 or more OOP features? Say, both Encapsulation and ...
5
votes
3answers
6k views

When I create an object, is fresh memory allocated to both instance fields and methods or only to instance fields

I have a following class class Student{ int rollNumber; int marks; public void setResult(int rollNumber, int marks){ this.rollNumber=rollNumber; this.marks=marks; } public void ...
8
votes
3answers
300 views

How to manage single responsibility when the responsibility is shared?

I have base two classes, Operation and Trigger. Each has a number of subclasses which specialise in certain types of operations or triggers. A Trigger can trigger a specific Operation. Whilst an ...
1
vote
1answer
163 views

What is the DRY-est factory pattern to instantiate subtypes based on one of their properties' values?

Take the following class hierarchy: Client FacebookClient PinterestClient TwitterClient Each client must define a value for an enum property named ClientType (string property Url in the ...
14
votes
10answers
2k views

Can objects constructed from the same class have unique method definitions?

I know this seems like a weird question, since the point of two or more objects sharing the same class is that their behavior is the same, i.e. their methods are identical. However, I'm curious if ...
2
votes
1answer
239 views

When mapping from a database, do OOP objects (entities) need to store the database values in attributes?

When it comes to OOP where an external database is being read from and written to, is it necessary to have attributes/properties within the objects to store the data? Or is it enough to simply read ...
-2
votes
2answers
131 views

How do you hash 4 doubles into a size_t?

I have bounding boxes the key type. Box { double mins[2]; double maxs[2]; } And I want to have Box as the key type in the D programming language, so I have to implement: size_t toHash() const ...