oop

Javascript plugin creation

I want to create a plugin called 'myPlugin'. Which method should I use and what is the difference between these two methods? Please tell me the advantages too. I am from designing background and not much programming knowledge. var myPlugin = { myId:"testId", create:function(){}, destroy:function(){} } OR funct...

An inaccessible class. VS2010.

I realy dont know what the problem is with VS2010. I created a class, and when I'm trying create an exemplar of the class I get an error: "Error xxx is inaccessible due to its protection level. Example: public class Person { Person(string name, int age) { this.name = name; this.age = age; } public stri...

How would I create an object that uses String type behaviour for creation?

I'd like to be able to create an object that is created like a String object, and when created verifies that the String value is an appropriate option. I.E. SpecificString can be "Bob" or "Jim". SpecificString BadName = "Sam" //Throws exception SpecificString GoodName = "Bob" //Does not throw exception. The most important functionali...

Private constructor and public parameter constructor -C#

I heard that private constructor prevent object creation from outside world. When i have a code public class Product { public string Name { get;set;} public double Price {get;set;} Product() { } public Product(string _name,double _price) { } } here still i can declare public constructor(parameter),won't it sp...

Using OpenGL drawing operations in an object-oriented setting?

I've been plowing through basic shaders and whatnot for an application I'm writing, and I've been having trouble figuring out a high-level organization for the drawing calls. I'm thinking of having a singleton class which implements a number of basic drawing operations, taking data from "user" classes and passing that to the appropriate...

How to apply Single Responsibility Principle to a service class

Hello Suppose we are designing a UserServiceImpl class which does CRUD(Create, Read, Update, and Delete) operations. In my view Create, Read, Update, and Delete are four reasons for a class to change. Does this class violates Single Responsibility Principle? If it violates, then should we have four classes like CreateUserServiceIm...

How to call object's method from constructor?

Hello, var Dog = function(name) { this.name = name; this.sayName(); } Dog.prototype.sayName = function() { alert(this.name); } I'm creating new instance of Dog object Dog('Bowwow'), but method sayName() is undefined. Why? Or maybe I should do something like (but I can't see difference)... var Dog = function(name) { this.na...

Ruby: Mark an object for garbage collection

Hi, I was wondering if there is a similar .finalize() method for Ruby objects, that marks them ready for garbage collection. If I would create 20,000 objects and each instance has a counter, I would like the object to be marked for garbage collection when reaches zero. I know this is pretty much a Java approach, but I have not sufficien...

How can i use complextype class or multi type class is it generic collection?

i need a complex returning type. i have 4 class returning types COMPLEXTYPE must include Company, Muayene, Radyoloji, Satis because i must return data switch case situation how can i do? Maybe i need generic collections How can i do that? public class GenoTipController { public COMPLEXTYPE Generate(DataModelType modeltyp...

Programming methods design phase assignment

Hey, i have an assignment (NCC) which deals with the design phase. The Scenario is that you have four soccer divisions (divisions 1,2,3 and 4) which consist of 22 teams each and hence each team plays 42 games (home and away). The concept is similar to the barclays premier league whereby ranking is based on points or else goal difference ...

Can't get custom error rendering to work in symfony 1.4

I'm tring to customize error rendering in my form according to this example. Here is my code: if ($this['message']->hasError()) { $error_msg = '<ul>'; foreach ($this['message']->getError() as $error) $error_msg .= "<li>$error</li>"; $error_msg .= '</ul>'; } return $error_msg; but when $this['message'] has error this code retur...

Design Technique: How to design a complex system for processing orders, products and units.

Hi, Programming is fun: I learned that by trying out simple challenges, reading up some books and following some tutorials. I am able to grasp the concepts of writing with OO (I do so in Ruby), and write a bit of code myself. What bugs me though is that I feel I'm re-inventing the wheel: I haven't followed an education or found a book ...

python: how to design a container with elements that must reference their container

(the title is admittedly not that great. Please forgive my English, this is the best I could think of) I'm writing a python script that will manage email domains and their accounts, and I'm also a newby at OOP design. My two (related?) issues are: the Domain class must do special work to add and remove accounts, like adding/removing t...

Static creator with variable number of arguments

I am looking for the best way to have a static creation method at the abstract level in a class family that can have a variable number of arguments in the constructor. For example, if I know that all extended versions of Foo will have two constructor arguments, I could do this: abstract class Foo { abstract public function __constr...

Best Lua OOP library

Hi! What is the best Lua OOP library in terms of speed, syntax convenience, LOC and license? Thank you. I've found LOOP. http://loop.luaforge.net/index.html It offers pretty nice syntax: local oo = require "loop.base" local Date = oo.class { -- default field values day = 1, month = 1, year = 1900, } local birthday = Date {...

Explain to me what is a setter and getter

What are setters and getters? Why do I need them? What is a good example of them in use in an effective way? What is the point of a setter and getter? Update: Can I get some coding examples please? ...

Class Design - Returning a List<Object> From <Object>

Given a simple class: public class Person { public string FirstName; public string LastName; public string GetFullName() { return FirstName + LastName; } } The user of this class will populate a List<Person> object by reading an Xml file or some other data source. Should the logic for populating the List be...

NSArray multiply each argument

Is the there a way to multiply each NSNumber contained in the array by 10? Here is what I have so far: NSMutableArray *vertex = [NSMutableArray arrayWithCapacity:3]; [vertex addObject:[NSNumber numberWithFloat:1.0]]; [vertex addObject:[NSNumber numberWithFloat:2.0]]; [vertex addObject:[NSNumber numberWithFloat:3.0]]; [vertex makeObje...

How do I use a modalViewController Identically in Two Controllers?

I'm using the Three20 TTMessageController in my app. I've figured out how to use it, adding on a bunch of other stuff (including TTMessageControllerDelegate methods and ABPeoplePickerNavigationControllerDelegate methods). It works great for me, after a bit of a struggle to figure it out. The trouble I'm having now is a design issue: I w...

Re-usable Obj-C classes with custom values: The right way

I'm trying to reuse a group of Obj-C clases between iPhone applications. The values that differ from app to app have been isolated and I'm trying to figure out the best way to apply these custom values to the classes on an app-to-app basis. Should I hold them in code? // I might have 10 customizable values for each class, that's a lon...