In Python, I'm trying to extend the builtin 'int' type. In doing so I want to pass in some keywoard arguments to the constructor, so I do this:
class C(int):
def __init__(self, val, **kwargs):
super(C, self).__init__(val)
# Do something with kwargs here...
However while calling C(3) works fine, C(3, a=4) gives: ...
I'm using a SqlDataReader to populate an entity in a Winform app. The entity class has several foreign key attributes in the database that I want to setup as properties in the entity class. Each property will be of type 'Attribute' with an ID & Description property.
Some of the users of the system are far from the database, so data acc...
Dear all: In advance, thank you for your time.
Lately, I have decided to learn Objective-C (I am a long time C-hacker) and after reading the beautiful text by Kochan and diving into the Apple documentation I am still confused as to the best way to implement a recursive class (ie. a class in which an ivar has the type of
the same class)...
Hi people of the world!
I have a class, this class can be empty. This class has only public properties of type String. When this class is in an empty state, that means that all properties have the value of String.Empty.
1) With a public static field, the properties of Class.Empty can be modified.
2) I don't see that a public static pr...
I'm not sure it's really a "polymorphism" question but anyway...
So I have an abstract class and 2 other classes that inherit from it.
Some code from the base class have a variable that would be different between classes that extends the base class.
What's the best way to do that? Override a "get" method? Change the architecture a litt...
I am trying to take the code in an .ASMX web service and change it into a class library project. The web service project has a web.config file with:
<applicationSettings>
<myService.Properties.Settings>
<setting name="DownloadChunkSize" serializeAs="String">
<value>100000</value>
</setting>
..and the co...
I'm interested in hearing some discussion about class attributes in Python. For example, what is a good use case for class attributes? For the most part, I can not come up with a case where a class attribute is preferable to using a module level attribute. If this is true, then why have them around?
The problem I have with them, is that...
I have a maintenance application that has to turn enterprise data (from various databases/tables) into flat files, each in a specific format, for consumption by a legacy application. I've got data models like
public class StatusCode
{
public String Id { get; set; }
public Char Level { get; set; }
public String Description { ...
Suppose I have a class with 3 constructors, a default (no argument) constructor, a parameterized constructor, and a static constructor. like this:
public MyClass() { ... }
public MyClass(string arg) : this() { ... }
static MyClass() { ... }
Supposing I invoke the parameterized constructor, in what order do these constructors ex...
Hi all,
When implementing a class, is it better practice to return a value for methods (interrogative) or to simply manipulate class attributes directly within the method (imperative).
For example, I have a class which builds a string to be output to a CSV file. I might do it this way:
String output = ""
String records[] = //list of ...
A sample class in "C# Class Desing Handbook" (pg 137) does not call the classes validation method for a specific field from inside the classes only constructor. So basically the sample class allows you to create an object with bad data and only throws an error for that data when you call the field's property which does validation on it t...
I have a class that has an inner struct/class (I have decided which yet, if it matters for this I will use that) I want the inner class to be accessed from other classes but only constructed by the outer class.
Is this possible?
Thanks
...
I wrote a application in MFC with C++. I need to write a class which can save all the data loaded from the database, These data might contain every kind of data type, such as int, string, byte, boolean, datetime and so on. We might filter, exchange columns, or sort on these data. For example:
int int string bool double float .... st...
Hello,
I have a database abstraction layer that starts with a base class like so:
class DB {
function DB() {
$this->host = "xxx";
$this->db = "xxx";
$this->user = "xx";
$this->pass = "xx";
$this->dbh = mysql_connect($this->host, $this->user, $this->pass);
mysql_select_db($this->db);
// etc
}
}
class DB...
Providing Synchronous and Asynchronous versions of Method in c# asks how to provide an async version of a method.
One of the answers suggests that class library developers should avoid providing the async method, if possible, based on the single responsibility principle.
Is this true?
Should I NOT provide async versions of methods? ...
My application uses a large amount of Panda objects. Each Panda has a list of Bamboo objects. This list does not change once the Panda is initialized (no Bamboo objects are added or removed). Currently, my class is implemented as follows:
class Panda
{
int a;
int b;
int _bambooCount;
Bamboo* _bamboo;
Panda (int c...
Is there a limitation on number of properties, methods a C# class can have?
I do a quick skim at Standard ECMA-334 and did not find any information on it.
Before jumping into why a class with many methods are bad design, I want to be more clear on the intention. Of course I will not be writing a class with large number of methods manua...
I'm looking for inspiration on how to design classes from scratch in a project with multiple developers in different locations (so no whiteboard sessions.)
Let's say you're tasked with implementing a rather big feature that is going to be used by the other developers later in the project. This feature will require several classes and wi...
Specifically, can anyone give me concrete examples of when or when not to use nested classes?
I've known about this feature since forever, but never had a reason to use it.
Thanks.
...
Hey,
I like to know how one can integrate the Qt libraries into an Enterprise Architect project. I do not know if it is possible at all but I tried it with partial success:
I added a new package to my project tried to import qt through Context Menu / Code Engineering / Import Source Directory and started with the directory src/corelib/k...