oop

Getting lost in the OOP joungle when trying to put a method in the right place etc.

Hi, It's not as though I don't understand OOP concept, and what should be done when, but sometimes I just mentally get lost in that. What better from an example? So I needed to download a file to a temp path, I decided to get the temp path not by the normal methods of dot net, because of irrelevant reason. So I wrote my own method for ...

Extending [Namespace]_Model_[Table] classes. is it safe?

Hello ladies and gentlemen! I'm new to php and zend framework and fill very uncertain about following: For example, I have two tables: table1: box(id, height, width, length, weight) table2: labels(id, boxid, text, position) labels.boxid -> box.id (labels.boxid is a foreign_key for primary_key box.id) I've generated two separate sta...

Is there an easy way to create derived attributes in Django Model/Python classes?

Every Django model has a default primary-key id created automatically. I want the model objects to have another attribute big_id which is calculated as: big_id = id * SOME_CONSTANT I want to access big_id as model_obj.big_id without the corresponding database table having a column called big_id. Is this possible? ...

Design pattern for a class that works on a collection of other objects?

I have a User model that can hold 1-n UserGroup models, each of which holds data about the user's relationship with a specific group (for example, if they're the admin of the group, when they joined the group, etc.). I'd like to provide some helper methods like isGroupUser() and isGroupAdmin() that work on the entire set of UserGroup mo...

Is it proper for a parent class to reference a property that exists only in the child?

In the project my team is currently working on, we're modifying a commercial PHP application. The app is strewn with code where a parent class checks for and works with a property that doesn't exist in the parent class, like so: class A { function doSomething() { if (property_exists($this, 'some_property')) { ...

Are these regular Perl subroutine calls?

I'm still trying to get a hang of Perl's OOP features. I'm confused about something, if I have a subroutine call like: My::Package::sub_name($param1,$param2) will this get "My::Package" sent as the first parameter? I'd tend to say no, but I'm not sure. ...

Problem Extending A Class in Clojure: ClassFormatError: Duplicate field name&signature

I'm trying to extend JButton with Clojure, but I ran into a problem when I try to create my own constructors. Whenever I use :constructors with :gen-class I keep getting a "ClassFormatError: Duplicate field name&signature" message when I try to instantiate my class. I think I'm following the Clojure docs properly. Am I doing something ...

interface classes

i"m new to interfaces i have this code example : public class DALF { public class Car { public int AddEdit(int? CarId, string Name) { .... } public DataTable Get(int? CarId) { ..... return CarD.Get(obj); } } public class Worker {...

PDO Connection Class, please help me understand if I have this right.

Hi everyone, I've been playing around with PDO for the last few days, I'm working on a small CMS system to teach myself OOP skills, but even though it's only a small CMS, I want it to be able to handle whatever the web can throw at it. This is what I've come up with so far, I'm going to add connection pooling to the constructor to enab...

Accessing array value

print_r($fanr); results in: HTML_QuickForm_text Object ( [_label] => FA-Nummer [_type] => text [_flagFrozen] => [_persistantFreeze] => 1 [_attributes] => Array ( [name] => auftragsnr [type] => text [value] => 123 ) [_tabOffset] => 0 [_tab] => [_lin...

php error reporting

Is there a common standard for reporting errors in your class functions? I've seen some c functions that you pass the error string to, so that if there is an error you can see what it is in that string, You need pointers for that though. I'm reluctant to use the return, because sometimes you do need the return for other variables. One...

Design pattern for class with upwards of 100 properties

What advice/suggestions/guidance would you provide for designing a class that has upwards of 100 properties? Background The class describes an invoice. An invoice can have upwards of 100 attributes describing it, i.e. date, amount, code, etc... The system we are submitting the invoice to uses each of the 100 attributes and is submitte...

Can I access a static method in a dynamically specified class in Perl?

Is it possible to dynamically specify a class in Perl and access a static method in that class? This does not work, but illustrates what I'd like to do: use Test::Class1; my $class = 'Test::Class1'; $class::static_method(); I know I can do this: $class->static_method(); and ignore the class name passed to stat...

How can I start designing my program on paper without over engineering things?

I'm interested in starting to properly design my software on paper before I ever start coding. What is the standard approach for this? I'm thinking something along the lines of UML but I feel that it's a bit overkill for a one-man project. What are some of the things professionals say is best to do when developing hobby projects? Anti...

JavaScript: Class.method vs. Class.prototype.method

What is the difference between the following two declarations? Class.method = function () { /* code */ } Class.prototype.method = function () { /* code using this.values */ } Is it okay to think of the first statement as a declaration of a static method, and the second statement as a declaration of an instance method? ...

Kohana: setting the template name dynamically

Perhaps I'm just missing a basic OOP idea in PHP, but for the life of me, I can't seem to set the "$template" variable dynamically. If I extend the Template_Controller, I can set the template name like this: public $template = 'template_file_name'; But I can't set it dynamically like: public $template = $this->setTemplate(); or ...

is C++ completely object oriented languge?

i read about small talk being completely object oriented.. is C++ also completely object oriented? if no.. then why so?? ...

C#: where to put "save()" method?

I have a question, here is an example I have a Model class: Stock public class Stock{ //some properties, stock name, stock code; public String StockName{ get,set } public String StockCode{ get,set } } Also I have a service class StockService, which will load the data from database and crea...

OOP design: string, enum, interface, or other?

I'm starting on a project that pulls data from and writes back to a legacy system database. I've started on the domain model and am trying to improve this design over past systems, so I'd like some feedback on this one. This example is arbitrary, so no need for specific advice there, but let's say there's a table in the database called ...

How should Web Applications Interfaces be designed?

I am building a web application and have been told that using object oriented programming paradigms affects the performance of the application. I am looking for input and recommendations about design choices that come from moving from One Giant Function to a Object-Oriented Programming Interface. In order to be more specific: If a W...