Tagged Questions
Object-oriented programming is a programming paradigm using "objects": data structures consisting of data fields and methods together with their interactions.
2
votes
3answers
69 views
what is “static{}” in Java?
I'm not a pro in OOP so please bear with me.
This piece of code is from android's auto generate Master/Detail Flow project :
static {
// Add 3 sample items.
addItem(new ...
0
votes
0answers
5 views
Domain model - modeling a template class and the instance class?
I'm writing a program where someone can set up an email (To, CC, Subject, Body, etc.). They can then set up various triggers that will cause an email to be sent using the set up they defined.
How ...
2
votes
3answers
59 views
Object oriented code reuse in iOS and objective-c
I have a viewController in my iOS class and in viewDidLoad, I create a gradient with CAGradient and add it to the layer of my view. I want this to appear in other views too, so what's the best way to ...
6
votes
3answers
63 views
Design Pattern to track partial results of a complex process
I'm facing a programming problem that I don't know how to solve in a object oriented and flexible way. I have in mind some bad solutions, but I'm searching for a good one. I develop in Java, so I ...
1
vote
3answers
44 views
Object instantiation with a Factory Method
I am currently enrolled in a CS2 course (data structures) where Java is the language used and I am interested in comparing and contrasting object instantiation using the traditional constructor method ...
0
votes
2answers
18 views
javascript oop. Constructor vs prototyping
I can understand what is the difference in creating and object as a constructor and creating an object in a literal notation and when is better to use each definition, but I can not understand the ...
0
votes
0answers
17 views
Convert Namespace to a single proc
I have a set of procs and a namespace as you can see below:
namespace eval ::_API {
if {[info exists ::_API::API_ids]} {
catch {API erase -ids [array names ::_API::API_ids]}
}
...
0
votes
1answer
13 views
Access modifiers for properties within abstract classes
While I have been developing objects for PHP for some time now, abstract classes are somewhat new to me. From my understanding, I would use an abstract class when I want to define a list of methods I ...
0
votes
4answers
17 views
PHP Abstract Classes w/ Common Methods: How to call
I'm a bit confused on the proper way to call common methods within abstract classes. Using the following code:
abstract class Transaction {
abstract public function process();
abstract ...
3
votes
5answers
48 views
iOS: is there a way to use a single class to hold common variables and not break Object Oriented principles?
I want to separate the data from the implementation in several classes, for many reasons.
One reason, for example, is that I have a few different menu screens that display text. I want to have one ...
0
votes
2answers
38 views
Methods and properties
I'm fuzzy on the terminology, and I've tried searching - but have so far not gotten any wiser.
I'm trying to learn OOP in PHP, and I'm trying to write a configuration class that stores value/key pairs ...
0
votes
3answers
36 views
change property of C# class type instance (e.g. dictionary) after it's defined
I can set a dictionary to ignore case when comparing, during instantiation:
Dictionary<string, long> SomeDict=new Dictionary<string, long>(StringComparer.InvariantCultureIgnoreCase);
...
0
votes
2answers
29 views
How to communicate different modules working with MVC
I'm trying to work with the following structure in order to implement MVC
Structure
Each module has a controller, a view and a model.
I don't know how to create a communication between different ...
0
votes
2answers
32 views
OOP and Persistence
In the spirit of tell don't ask and never let an object get into an invalid state oop design, I'm wondering how persistence would be handled in a dynamic environment.
For a contrived example, ...
1
vote
2answers
19 views
Reloading a Class
I have a PHP daemon script running on the command line that can be connected to via telnet etc and be fed commands.
What it does with the command is based on what modules are loaded, which is ...
0
votes
0answers
44 views
OOP Class properties automatically [migrated]
One of my friend made a framework.
He made an abstract class, called NullObject (see below).
For his convenience, hid does this, so when he want to build an object from database, just inherit this ...
0
votes
4answers
53 views
Java interface method call via object
I have the main method written as following:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package excercise.pkg5;
/**
*
* @author Azraar
*/
...
0
votes
1answer
15 views
Django, problems with overriding model in sites packages
i got problems with overriding of model "Sites", that contains in Sites framefork. I have a form with "Sites" on my site, i need to display names of Sites, not Site.domain, i'm override model, route ...
0
votes
1answer
35 views
Choosing a random instance from a tree in python
Iam trying to iterate through a tree, find a random instance, mutate it then exit but am having problems with recursion.
Note concerning escaping the loop after mutation I have tried raising an ...
1
vote
0answers
37 views
Designing a thin Object Oriented Query Language for SQL
Given the following class :
class People {
.....
String getName();
int getAge();
...
}
I want to query my database for all people whose age is greater than 20. So I would like to write something ...
-3
votes
1answer
28 views
Go through object properties to check if string contains
I want to go through every property my object has and check whether it is contained in a given string. The problem is, I now have 10 properties and wrote 10 if/else-cases. I think I can compromise it ...
6
votes
1answer
53 views
Performance and memory of prototype pollution vs dedicated library object
Not sure if this is new question so pls ref to any good source if have one.
My team is working on a big js chart project we inherited from the previous developers who made intensive use of built-in ...
0
votes
2answers
21 views
Javascript private variables and parameters what is the difference?
While creating some objects in javascript I started to wonder if there is any point to create private variables that just point to the parameters since all the functions in an object (that can use the ...
0
votes
3answers
43 views
How to check if a value is valid when set property
Say I have a fruit class and check the fruit type when constructing:
var fruitType = {
"apple": 0,
"orange": 1
};
fruit = function(name) {
if (name in fruitType) {
this.name = name;
} ...
3
votes
1answer
45 views
Can a JavaScript object be considered a plain dictionary? [on hold]
Today I heard that a JavaScript object is no more than a plain dictionary (taking as a reference the python dictionary)
I think it's a wrong idea, but I did not know how to answer to that.
So, can ...
5
votes
3answers
47 views
Represent multiplicity in java with less coupling
Consider two classes Team and Players.
Class Player
{
String name;
int age;
//Getters and Setters
}
What is the best way to represent a team of players.
1)
Class Team
{
String teamName;
...
1
vote
0answers
51 views
Why is my effort to implement Parasitic Inheritance in Javascript failing here?
I am playing with classical inheritance in Javascript (in Chrome) following the example of Crockford. I like the parasitic interface but am looking for a bit cleaner way to encapsulate inheritance.
...
0
votes
1answer
31 views
Javscript :: Global Objects Or Function Return Local?
When writing sound code should i be using global objects or passing locals to functions and then returning the functions local object back to the original function?
function func1(obj) {
..modify ...
0
votes
1answer
29 views
Using self for property return in python class
I come from a javascript background which I think is the reason I have this question in the first place.
Is there any difference when using self to refer to properties of a class in method ...
0
votes
0answers
33 views
Instantiate controller from url for usage in view
My blog view contains a foreach which requires the return value of the main function inside my blog controller.
Since the url contains both the requested class and function I tryed use them for ...
0
votes
1answer
45 views
Empty array messing up default argument values
I'm following through the Hungry Academy curriculum using a post here: http://jumpstartlab.com/news/archives/2013/09/03/scheduling-six-months-of-classes
And I'm up to the EventReporter project found ...
0
votes
1answer
74 views
Java - Object creating itself many times - any design pattern for this?
i want to know what is the closest Design pattern that helps in such a situation,
an object (lets call it the original big one) takes an instance (call it INST), and check if it holds an object of ...
8
votes
3answers
163 views
What are Mixins (as a concept)
I'm trying to get my head around the Mixin concept but I can't seem to understand what it is.
The way I see it is that it's a way to expand the capabilities of a class by using inheritance.
I've read ...
3
votes
0answers
65 views
Should I extend the element or create decorators to achieve consistent styling of common UI elements? [on hold]
This is definitely a philosophical point but I'm hoping there are clear advantages one way or the other (to settle a debate).
I'm working in Zend Framework 1.12 (PHP). We have a submit button called ...
0
votes
0answers
23 views
What do you think of implement a DAO layer in php?
I have a thought hanging about me, and perhaps someone will be able help me to clarify this.
I usually write code OOP style in PHP. I came from Java SE. I usually write a DAO layer between data ...
0
votes
2answers
23 views
initializing a private array in a class in php
yes...im creating a class where i want to use a predefined (ie const) array as a private class member yet php isn't loading the array ie when i try the array_flip in constructor its telling ...
5
votes
4answers
66 views
Perl OOP attribute manipulation best practice
Assume the following code:
package Thing;
sub new {
my $this=shift;
bless {@_},$this;
}
sub name {
my $this=shift;
if (@_) {
$this->{_name}=shift;
}
return ...
1
vote
4answers
44 views
Difficulty in understanding Loose coupling via Interfaces
In "Head First Servlets and Jsp" book by Kathy sierra at page 744
it is mentioned that,
"A very common approach when class A wants to use methods in class B is to create an interface between the ...
0
votes
1answer
46 views
JS - called method is not a function
I have object:
var devark = {
init: function() {
var obj = this;
obj.assignHandlers();
},
assignHandlers: function() {
var obj = this;
...
-3
votes
1answer
33 views
Turn a slug into an id
I am quite new to Symfony and Doctrine and I'm trying to work out how I can get the following route to convert to an id so I don't have to search by strings all the time (unless that is considered to ...
0
votes
1answer
34 views
overloading functions with base class smart pointers
Hi sorry but I wasn't sure how to word this question but here goes:
I have 3 classes: the first a pure virtual base class base with derived classes derived1, derived2...
class base{
public:
...
0
votes
1answer
21 views
Javascript Singleton communication definition required
I made a object to keep my functions became singleton, using that, i made sample methods to call and communicate each other.. but i don't get any appropriate results..
any one correct me, the ...
0
votes
3answers
93 views
How would you explain a layman person or a beginner in programming, the bold point of object oriented approach - the SECURITY? [on hold]
What does a secure code actually mean? Is it that you cannot make that code do something else, it wasn't supposed to do?
Many of my peers say to migrate to c++ or java as they are more secure because ...
1
vote
2answers
56 views
Automatically decorate superclass functions in subclass?
I have a subclass that adds graphics capabilities to a superclass that implements the algorithms. So, in addition to a few extra initialization functions, this subclass will only need to refresh the ...
2
votes
3answers
75 views
The OOP way of doing things (in PHP) [on hold]
I'm still trying to wrap my head around OOP, having been brought up in procedural coding a long time ago. Been stretching my legs in PHP for a while now.
So I've read a lot about best practices and ...
3
votes
2answers
47 views
Javascript singleton inheritance
I would like to keep a single parent class. all clild classes that inherit the parent class will be able to share the same parent class object. How that can be achieved?
var ParentClass = function(){
...
1
vote
1answer
44 views
Ruby dynamic constant name access
I have a class API that pulls objects from a third party API and builds them into objects that are subclasses of type APIObject. APIObject subclasses match the object names from the API that I'm ...
0
votes
1answer
53 views
Scanner not blocking for input
I was able to solve my last problem, however, one of the guys suggested I make a new question for this, so here we are. This piece of code below is not running and is part of the EmployeeTest.java ...
0
votes
2answers
39 views
Fatal Error: Call to member function on non-object when it is an object
I have one class that holds an array of Classes. When looping through the array and trying to run Class functions, I get the error:
Fatal error: Call to a member function getTDs() on a non-object on ...
-6
votes
2answers
72 views
How to pass object as parameter in function
Please take a look at this. I have comments in the problem function and corresponding call in main.
#include<stdlib.h>
#include<iostream>
using namespace std;
void givesomespace()
{
...