A methodology that enables a system to be modeled as a set of objects that can be controlled and manipulated in a modular manner
0
votes
0answers
9 views
How do I land my first Software Engineering internship?
What are some milestones I need to reach so that I can have a good chance of landing an internship in software engineering? What do I need my resume to include so they consider me to be a worthy ...
1
vote
1answer
53 views
Virtual method returning a unique collection - how to ensure and hint?
I have a virtual method that returns a collection of items that must be unique. I want to make sure that it will be obvious when overriding the method. What is the best way to do this?
Here is an ...
-3
votes
0answers
44 views
Java for non computer devices [duplicate]
hello all there is an old saying that java is actually developed to run on different devices like VCR, AC etc. then my confusion is if they do so where they compile there code to run on different ...
0
votes
0answers
16 views
Graph curve and actual curve plotted on screen implementation patterns
I'm implementing a graph plotter.
There are Curve objects, that contains points of actual XY data.
When I plot to screen, I need to calculate the XY points on screen, resulting a PlottedCurve. This ...
4
votes
3answers
136 views
Unit of Design Versus Unit of Re-use. What is the difference?
Contemporary object-oriented programming languages employ the class as the unit of reuse. At the same time, the class is also the unit of design. This implies that to reuse a class, the design ...
4
votes
1answer
162 views
OOP design for conditional event processing queue
This will be in C++11, but the object design should be rather agnostic.
I have 3 interface classes, IEvent, ICondition, IRunnable.
The main loop processes multiple kinds of IEvent, ranging from "an ...
2
votes
2answers
76 views
How to handle an aggregated list of the fields of multiple objects?
I have some objects each hold a list of variables, and a list which holds all variables of these objects, for example
class A
{
List<Var> varList;
}
class B
{
List<A> aList;
...
0
votes
0answers
37 views
Design pattern identificaiton and improvement [closed]
QUESTIONS:
What is the name/style of the design pattern I am using by my use of the value property/attribute/method on each class?
Is there another/more appropriate design pattern that I should ...
34
votes
6answers
4k views
How to think as a C programmer after biased with OOP language? [closed]
Previously, I've only used Object Oriented Programming languages (C++, Ruby, Python, PHP), and am now learning C. I'm finding it difficult to figure out the proper way to do things in a language with ...
-1
votes
1answer
59 views
Are there any languages that allow subclassing or instance specific behavior without recompiling? [closed]
When I was in school the professor said that writing device drivers is very much an object oriented activity. Also consider PAM (pluggable authentication modules) and NSS (name service switch). These ...
1
vote
3answers
83 views
Dependency inversion without static methods?
It's clear that the dependency inversion principle and the use of interfaces makes software components less coupled and promotes maintainability. On the other hand, these principles make using static ...
23
votes
10answers
4k views
What's the proper way to model this real-world activity that seems to need circular references in OOP?
I've been wrestling with a problem in a Java project about circular references. I'm trying to model a real-world situation in which it seems the objects in question are interdependent and need to ...
0
votes
0answers
33 views
Design of a Smartcard listener [duplicate]
I have the task to write a listener which detects smartcards inserted into a terminal and notifies all registered classes. The listener needs to be accessible from different parts of a large ...
1
vote
1answer
198 views
Why can a constructor be used without `new` keyword in Javascript?
I found Date can be used without the new keyword.
Date(1)
> "Thu May 28 2015 15:54:20 GMT+0800 (CST)"
new Date(1)
> Thu Jan 01 1970 08:00:00 GMT+0800 (CST)
I was wondering whether there is ...
0
votes
1answer
99 views
Passing same argument to multiple small functions versus doing everything in one big function?
I have inherited a class method from another developer, which looks like below:
(Note: Class:X means X is a member of Class in the OOP paradigm.)
Class:BigFunction()
{
ImportantValue = ...
0
votes
0answers
69 views
Addicted to Interfaces - Good or bad? [duplicate]
After 2 years of programming, I usually found myself using the following design pattern:
public interface ISomeInterface {
void SomeMethod();
void OtherMethod();
}
public abstract class ...
4
votes
3answers
251 views
When is an object of real world a (computational) object of your program?
In an OOP design phase strategy,
Any physical/conceptual object of a system can be modeled(considered) as computational object in your OOP designed program based on below two conditions:
First ...
0
votes
2answers
128 views
What is the difference between an abstract method and an interface [duplicate]
An interface requires implementation of the specified functions in a class that implements the interface.
An abstract function from an abstract class requires implementation in a class that extends ...
1
vote
1answer
286 views
Avoiding long list of interfaces
Motivation
Let a project where...
... exists a lot different behaviors. For each behavior, there is an interface which has its possible actions. One object could perform a lot different behaviors.
...
1
vote
2answers
101 views
How can I have objects interacting and communicating with each other without forcing a hierarchy?
I hope these ramblings will make my question clear — I'd totally understand if they wont, though, so let me know if that's the case, and I'll try making myself clearer.
Meet BoxPong, a very ...
1
vote
2answers
44 views
Expressing interface inheritance in natural language [duplicate]
In object-oriented programming, when you extend a class you establish an is-a relationship between a new subtype and its parent(s), i.e. B is an A (aka code inheritance). When you compose a class with ...
22
votes
5answers
3k views
Can you implement “object-oriented” programming without the class keyword?
Say we want to provide an abstraction of an "account" in a bank. Here's one approach, using a function object in Python:
def account():
"""Return a dispatch dictionary representing a bank ...
-2
votes
2answers
104 views
How would you structure your code for a Neural Network? [closed]
I understand how Artificial Neural Networks work. However, implementing one in code is quite another thing. How would you go about designing the classes and data structures?
I found one great ...
1
vote
2answers
88 views
In javascript, should object properties be declared on top of the function?
I learned that it's good practice to declare variables before they are used. For example:
function myFunction() {
var i;
var j;
}
Does the same thing go for object properties, and is there a ...
3
votes
2answers
124 views
Domain object model: query by id vs object
Let assume I have two simple model classes: Product and Brand
It is obvious I have a query method in Product class like this
Product product = Product.findById(123);
What if, I want to query ...
9
votes
4answers
538 views
Is Visitor Pattern valid in this scenario?
The goal of my task is to design a small system which can run scheduled recurring tasks. A recurring task is something like "send an email to administrator every hour from 8:00 am to 5:00 pm, Monday ...
2
votes
2answers
231 views
Lesser of two evils regarding return types
I'm implementing a system in PHP where values are represented with objects that implement an Amount interface. I'm building two different implementations of this interface, one using a simple integer ...
0
votes
2answers
83 views
Refactoring case-when statement [duplicate]
The Product model which can have 2 price tables. The method price calculates the price of the product based on product's price table which is defined by price_table field.
class Product < ...
2
votes
2answers
168 views
return a object without returning the reference
i'm having some trouble with returning objects and lists of objects. To problem is I want to return a object in my example an developer but I don't want to give the reference.
What's the best ...
-1
votes
2answers
203 views
which one is recommended object-oriented design? [closed]
I made simple object-oriented prgram, and think about design.
I wonder which one of belows is recommended object-oriented design.
Most left side class is "Main" class. Black arrow means they are "Has ...
58
votes
9answers
9k views
How do you avoid getters and setters?
I'm having something of a hard time with designing classes in an oo way. I've read that objects expose their behavior, not their data; therefore, rather than using getter/setters to modify data, the ...
19
votes
3answers
3k views
The principle of least knowledge
I understand the motive behind the principle of least knowledge, but I find some disadvantages if I try to apply it in my design.
One of the examples of this principle (actually how not to use it), ...
0
votes
2answers
66 views
Are static methods of a class part of its type?
As far as I understand it, classes –as they are supported in OOP languages such as C++, Java, and Scala – define the type of each object I can instantiate with that class.
Not all features of a class ...
1
vote
2answers
48 views
Module based project vs Normal project [closed]
I am writing code on top an established Enterprise application. I see that the application has 4 modules as shown below.
-Srk
-SrkEJB
-SrkUtils
-SrkWeb
I have gone through the code and I see that ...
2
votes
4answers
158 views
How wrong it is to have multiple associations between classes?
I'm modeling a college process, in which I have three classes: Student, Subject and Degree
Degrees have their own subjects, students have a list of subjects they have passed, and also students should ...
3
votes
2answers
294 views
How do I override the Type of members in a base class from the derived class?
I have two classes that know each other in a many-to-many relationship. Now I want to have two additional classes that inherit from the existing classes. The association between the inherited classes ...
-1
votes
0answers
6 views
eclipse acting weird when creating methods [migrated]
I don't see what could be wrong here, I was working on a different method but had some problems so I tried to simplify it to check where could the mistake be but I ended going up into this very simple ...
2
votes
1answer
77 views
C++: Make classes immutable or compatible with STL containers
Making types immutable is often desireable, especially for multi-threaded applications. There's no need to worry about concurrent access and no need for any synchronization. The common STL containers ...
-2
votes
0answers
68 views
OOP vs ADM Comparisom
This is the ADM equivilant to the example code given in
Correct placement of Methods in OOP
In this example we have resolved the Method placement question by moving ALL methods away from the data, ...
4
votes
1answer
94 views
OO design in a data processing pipeline
I'm wondering how to design a fairly simple class whose properties are complex to compute. Also, the properties depend upon each other for computation.
An example using graphs and graph processing ...
3
votes
1answer
270 views
Correct placement of Methods in OOP
Which Class should contain a method which has dependencies on multiple classes?
I've coded up a specific example to avoid generalizations. In this example we have an initial requirement :
...
3
votes
3answers
337 views
Functional vs object-oriented style in C#
I'm learning functional programming and face the following confusion when applying it to my C# projects:
I begin by writing pure, static functions and use function composition.
After the code ...
0
votes
0answers
69 views
Is using Interface implemented by single class a not recommended practice? [duplicate]
I have several classes in C#, not just POCO class but with methods and implementations.
Each of those classes implement one Interface. e.g. IPerson implemented by Person class.
Employee implements ...
9
votes
6answers
419 views
Does it always make sense to “program to an interface” in Java?
I've seen the discussion at this question regarding how a class that implements from an interface would be instantiated. In my case, I'm writing a very small program in Java that uses an instance of ...
2
votes
1answer
264 views
Should all functions be fully self-contained (is it bad practice to share a variable between functions)?
There are two ways to do the same thing (pseudo code)
Define databaseHandle in the parent function, and use it as a global in this scope:
function API() {
function openDatabase() {
...
2
votes
1answer
55 views
Which approach for coding a 'texture atlas'?
For a game project, I have a couple of textures coming from multiple sources and I need to pack all these within a single texture atlas.
Example for a racing game circuit, there are textures for :
...
0
votes
1answer
67 views
Strategy pattern can use this pointer?
I want to use strategy pattern, but I wander if it is correct to use "this pointer" with the strategy pattern interface.
This is required in order to get internal information which is required for ...
4
votes
4answers
333 views
Legitimate cases of having .equals() behaving inconsistently with .compareTo()?
Java documentation says it's "strongly recommended" to have them behaving consistently.
But are there legitimate cases of java/c#/python/etc Object.equals() method behaving inconsistently with the ...
1
vote
4answers
200 views
Is there a name for refactoring technique that turns hardcoded values into configurable parameters?
What is that technique called when you take values in the code that are hardcoded and make them variable, possibly constructing elaborate OO constructs to make that variable properly configurable?
...
2
votes
2answers
210 views
When it makes sense to implement C# explicit operator?
Follow-up of Is my usage of explicit casting operator reasonable or a bad hack?
One of the users commenting on that question said that it's really bad if the casting operator creates a new object ...