instances

Cloning vs. Instanciating a new class

Is cloning good practice in this case? How to do it better? public ModelCollection startParsing() { return parseFeed(new ModelSpecialEntry); } public ModelCollection parseFeed(ModelEntry pattern) { ModelCollection modelCollection = new ModelCollection(); while( condition ) { //TODO: Is cloning the best solution? ...

Why doesn't every OOP runtime allow manual deletion (garbage collection) of object instances?

You can create new objects, but when you've finished using them there's no real way to destroy them immediately as well? Why didn't every OOP runtime implement such behaviour? I'm sure we as developers could (often) organize for object instances to be destroyed when we've finished using them. function work(){ var p1:Point = new Po...

Instantiate and reuse instances of objects in XAML

I want to instantiate objects in XAML, and reuse these instances. I think it should be simple but I'm stuck, I'm probably missing something obvious. Say I want to add Cats to different Rooms (Room has an ObservableCollection containing objects of type Cat). In the UserControl.Resources I create ObjectDataProviders: <ObjectDataProvider ...

code problem - beginner

Ok here is my code so far: @implementation PtyView - (id)initWithFrame:(NSRect)frame; { if (self = [super initWithFrame: frame]) { [self setFont:[NSFont fontWithName:@"Courier" size:0.0]]; [self startTask]; } return self; } - (void)keyDown:(NSEvent *)event { const char * typein = [[event characters]...

Manager isn't accessible via model instances

Hi, i'm trying to get model objects instance in another one. And i raise this error : Manager isn't accessible via topic instance Here's my model : class forum(models.Model): # Some attributs class topic(models.Model): # Some attributs class post(models.Model): # Some attributs def delete(self): forum = se...

Accessing non-static DAL methods

Hi, I am fairly new to .net and am creating a web app for learning purposes. I have a DAL with non static methods in it. My question is, how should i be accessing these methods in the business layer? I'm not sure if this is a good or a bad way but currently i use this class to create instances of the DAL methods: public DataAccess { ...

Declaring class instance and its initialization

Hi, If I create the variable with type of a class, what is the actual value I will initialize it with? I mean - the int is initialized with value of that type that is number. But in the terms of technical precision, what happens when I create new instance of class? class a { } class b { a InstanceOfA; InstanceOfA=new (); //which ...

Polymorphic class-constrained instances

I want to make all types that are instances of Enum and Bounded also an instances of Random. The following code does this and should work (with the appropriate extensions enabled): import System.Random instance (Enum r, Bounded r) => Random r where randomR (hi, lo) = inFst toEnum . randomR (fromEnum hi, fromEnum lo) where inFs...

Load GIF from Resource to Dynamic form.

Hi, I have this piece of code: SELDR_WH := FindControl(FindWindow(nil,'PhoneDB Filtering')) as TForm; if seldr_wh <> nil then begin SELDR_WH.ClientHeight := SELDR_WH.ClientHeight + 20; gif := TGIFImage.Create; with gif do begin Parent := SELDR_WH; Top := SELDR_WH.ClientHeight - 20; Left := 30; try ...

How many database instances are too much with the ezcomponents database component?

Hi, I want to connect to about 9 databases and create an instance for everyone of them to aggregate my results in the queries. I am writing a metrics dashboard for my company that need to track results and performance over about 9 different databases with about 15mil+ records in each. Now the technical part is not hard. I know how to c...