class

Java synchronized methods: lock on object or class

The Java Tutorials say: "it is not possible for two invocations of synchronized methods on the same object to interleave." What does this mean for a static method? Since a static method has no associated object, will the synchronized keyword lock on the class, instead of the object? ...

Help needed--Is class necessary in Python scripting???

I am creating an interface for Python scripting. Later I will be dong Python scripting also for automated testing. Is it necessary the at i must use class in my code.Now I have created the code with dictionaries,lists,functions,global and local variables. Is class necessary? Help me in this. ...

make a parent function return - super return?

there is a check I need to perform after each subsequent step in a function, so I wanted to define that step as a function within a function. >>> def gs(a,b): ... def ry(): ... if a==b: ... return a ... ... ry() ... ... a += 1 ... ry() ... ... b*=2 ... ry() ... >>> gs(1,2) # should return 2 >>> gs(1,1) # should re...

Python classes from a for loop

I've got a piece of code which contains a for loop to draw things from an XML file; for evoNode in node.getElementsByTagName('evolution'): evoName = getText(evoNode.getElementsByTagName( "type")[0].childNodes) evoId = getText(evoNode.getElementsByTagName( "typeid")[0].childNodes) evoLevel = get...

How to setup an Object Creation Interface "rule" in C#?

The general rule is that I want to say, "T has a method with a String parameter which will return List." Put verbosely, we might call the interface ICanCreateListOfObjectsFromString. A possible application might be search. It feels like it'd be nice to have a static method in my interface, but I know that's not allowed in C#. What is...

C++ Question about default constructor

Hi, I have a question. What does it mean to call a class like this: class Example { public: Example(void); ~Example(void); } int main(void) { Example ex(); // <<<<<< what is it called to call it like this? return(0); } Like it appears that it isn't calling the default constructor in that case. Can someone give a reason why ...

do you put your calculations on your sets or your gets . .

which is better ??? public class Order { private double _price; private double _quantity; public double TotalCash { get { return _price * _quantity; } } or public class Order { private double _totalCash; private double _price; private double _quantity; private void CalcCashTotal() { _tot...

What's the difference between an object and a class in Perl?

I'm having a little trouble getting my head around the conceptual difference between an object and a class. I don't really understand the distinction between the two in any programming language, but currently I'm working with Perl, and Moose, so I'd prefer an explanation using those things. Cheers ...

Does python have an equivalent to Java Class.forName()?

I have the need to take a string argument and create a class in python. In Java, I would use Class.forName().newInstance(). Is there an equivalent in python? Thanks for the responses. To answer those who want to know what I'm doing: I want to use a command line argument as the class name, and instantiate it. I'm actually programmi...

Restricting T to string and int?

I have build myself a generic collection class which is defined like this. public class StatisticItemHits<T>{...} This class can be used with int and string values only. However this public class StatisticItemHits<T> where T : string, int {...} Won't compile. what am I doing wrong? ...

Usage of MATLAB classes compiled to .NET

I compiled a MATLAB class to .NET, but instead of having my proper constuctor and methods in my class classdef Foo properties p1 p2 end methods function bar ... I have these functions in the .NET assembly: ~Algo() public Algo() public void Foo(int numArgsOut, ref MathWorks.MATLAB.NET.Arrays.MWArray[] argsOut, Mat...

Is there any advantage in using a Python class?

I have a Python class full of static methods. What are the advantages and disadvantages of packaging these in a class rather than raw functions? ...

How do classes help you manage large applications?

This came up in a conversation I was having online, and it occured to me that I have no idea how this is supposed to work: Quite a lot of programmers seem to just take as a given- indeed, obvious that classes are a necessary language feature for managing huge software projects. It's not obvious to me how they do this. My question to yo...

Custom nested properties/methods in asp.net

I'm looking for a way to write a custom .net class that would allow for nested methods. For example... say I have a class X with a function Y that returns a list. Then I have another function that returns a sorted list... I would like to be able to do something like x.y().z() where z would accept the output of y() as its input. Basic...

Enterprise Library Validation Block - Should validation be placed on class or interface?

I am not sure where the best place to put validation (using the Enterprise Library Validation Block) is? Should it be on the class or on the interface? Things that may effect it Validation rules would not be changed in classes which inherit from the interface. Validation rules would not be changed in classes which inherit from the cl...

C++ Classes default constructor

Earlier I asked why this is considered bad: class Example { public: Example(void); ~Example(void); void f() {} } int main(void) { Example ex(); // <<<<<< what is it called to call it like this? return(0); } Now, I understand that it's creating a function prototype instead that returns a type Example. I still don't get why ...

(Java) How can I override a class using a separate jar?

A customer requires a preview of a new feature of our product. They asked to have that feature sent to them in a jar file (like a patch). There's no problem with including the new classes in said jar file. However, an existing class was modified, which is needed to integrate the new feature. They just want to add this new jar file withou...

Overload constructors in VBScript

I found a way to extend classes in VBScript, but are there any ways to pass in parameters or overload the constructor? I am currently using an Init function to initialize the properties, but would like to be able to do this when I create the object. This is my sample class: Class Test Private strText Public Property Get Text ...

Is it better to use properties in the child class to access the parent, or make the parent public?

I have 2 classes, a parent and a child. Class Test Private Test_Text Private Sub Class_Initialize() Test_Text = "Hello" End Sub Private Sub Class_Terminate() End Sub Public Property Get Text Text = Test_Text End Property Public Property Let Text(ByVal strIn) Test_Text = strI...

Javascript `this` not working as I thought?

I'm adapting a pretty basic js function into a class. Anyway, basically it just creates a floating container above the main page. I'm aware it's incomplete, but I'm in the middle of typing it up, and keep getting caught out when attempting to call the close() function. Firefox returns a this.sdiv is undefined. I'm confused as to how thi...