0
голосов
2ответов
564 просмотров

How will I do a property drill down?

How will I know if an object instance is a property or a sub property of another object instance? for example I have this class structure: public class Car { public Manufacturer Manufacturer {get;set;} } public class Manufacturer { public List<Supplier> {get;set;} } public...

2
голосов
3ответов
1044 просмотров

PHP error_log performance issues

I've been trying to write an error handling class that I can use on sites, that will email me in the event of an error. Problem is, when I profile the application, it's choking on the error_log function. Here's my code (omitting the class: class ErrorHandler { private static $instance; private s...

6
голосов
4ответов
414 просмотров

Pythonic way to only do work first time a variable is called

my Python class has some variables that require work to calculate the first time they are called. Subsequent calls should just return the precomputed value. I don't want to waste time doing this work unless they are actually needed by the user. So is there a clean Pythonic way to implement this ...

2
голосов
3ответов
2541 просмотров

What are guard methods/classes?

i just noticed the guard method/class mentioned in this question and i don't really get the concept from the answers. And alas, Jon Skeet's link to an MS site never loaded. A few quick Google searches seemed to yield only products, not software engineering concepts. Any explanation and/or sample...

2
голосов
4ответов
3776 просмотров

PHP extending class properties

I have two classes in a PHP application, B extending A for example. Class A has a function which returns some of its other properties in the form of an array of SQL insert queries eg Class A { $property_a; $property_b; $property_c; $property_d; function queries() { $queries = array(); $queries[...

8
голосов
3ответов
16361 просмотров

Python: Get name of instantiating class?

Example: class Class1: def __init__(self): self.x = Class2('Woo!') class Class2: def __init__(self, word): print word meow = Class1() How do I derive the class name that created the self.x instance? In other words, if I was given the instance self.x, how do I get the ...

7
голосов
3ответов
6975 просмотров

PHP runtime class modification

So I want to be able to add/remove class methods at runtime. Before you tell me that's horrible pratice in oop, it might be, but I don't really care. The reason I want to be able to do this is because I want the application to be very modular, so some plugin could extend some base class and add m...

15
голосов
8ответов
4810 просмотров

When structures are better than classes?

Duplicate of: When to use struct in C#? Are there practical reasons to use structures instead of some classes in Microsoft .NET 2.0/3.5 ? "What is the difference between structures and classes?" - this is probably the most popular question on intrviews for ".NET developer" vacancies. The only a...

2
голосов
2ответов
182 просмотров

What term is used to describe when two classes depend on each other?

I've got the following two classes in C#: public class MyFirstClass : IMyFirstClass { MySecondClass mySecondClass; public MyFirstClass(IMySecondClass mySecondClass) { this.mySecondClass = mySecondClass; } public MyFirstClass() : this(new MySecondClass()){} } public ...

34
голосов
6ответов
20599 просмотров

Wrapping C++ class API for C consumption

I have a set of related C++ classes which must be wrapped and exported from a DLL in such a way that it can be easily consumed by C / FFI libraries. I'm looking for some "best practices" for doing this. For example, how to create and free objects, how to handle base classes, alternative solutions...

-1
голосов
2ответов
114 просмотров

some kind off variable problem within php class

I have this in my class When the second function is called php errors with wrong datatype and only variables can be past by reference. I don't know what they mean by that This code comes from php.net If the same code is outside the class it executes fine What am I doing wrong here, if I am wo...

45
голосов
8ответов
66021 просмотров

Can I instantiate a PHP class inside another class?

I was wondering if it is allowed to create an instance of a class inside another class. Or, do I have to create it outside and then pass it in through the constructor? But then I would have created it without knowing if I would need it. Example (a database class): class some{ if(.....){ inclu...

0
голосов
5ответов
10438 просмотров

ASP.NET Application - Architecture and Class Diagrams

I am new to ASP.NET Development. Could anyone please refer a document/tutorial/link which gives a sample code, architecture, class and sequence diagrams for 3 / 4 / n tier based simple ASP.NET application/example? It would be of great help to me.

-2
голосов
3ответов
324 просмотров

Complexity class

Assume that methods m1 and m2 are static void and compute the same result by processing an argument of type Object[]. Empirically we find that m1 -> T(N) = 100N and m2 -> T(N) = 10Nlog2N where the times are in microseconds. For what size inputs is it better to use m1 and m2? So I would use...

21
голосов
3ответов
9789 просмотров

Does C# have an equivalent of Java static nested class?

I am converting Java into C# and have the following code (see discussion in Java Context about its use). One approach might be to create a separate file/class but is there a C# idom which preserves the intention in the Java code? public class Foo { // Foo fields and functions // ... ...

2
голосов
4ответов
1843 просмотров

Should I refactor static nested classes in Java into separate classes?

I have inherited code which contains static nested classes as: public class Foo { // Foo fields and functions // ... private static class SGroup { private static Map<Integer, SGroup> idMap = new HashMap<Integer, SGroup>(); public SGroup(int id, String type) { //...

0
голосов
4ответов
1517 просмотров

Call pure virtual function from parent class

I'm very new to c++, but I think I understand what is going on. The parent class is trying to call the pure virtual member function in the parent class. I thought that by overriding the virtual function in the child class, it would be called instead. What am I doing wrong? Provided for me i...

0
голосов
2ответов
361 просмотров

php5 extend main class and use statics

why I can't do like this? <?php class core { public static $db; function __construct() { $this->db = new mysql('host', 'user', 'pw', 'db'); } } class stat extends core { public static function log() { core::$db->query("insert into mytable values(now()...

0
голосов
6ответов
2491 просмотров

How to point to CSS default class using the class attribute

Is there a way to point to the default CSS class of an object? For example, depending if a user is logged in I want to specify a different CSS class to control the style of a header. $css_class = ""; if($logged_in) $css_class = "success" echo "[h1 class=".$css_class."] My Title [/h1]" I...

3
голосов
2ответов
1246 просмотров

C# - To use Partial Classes, or Seperate Ones?

Possible Duplicate: Why use partial classes? Which way is best practice and the best programming approach, Partial Classes or Individual classes?

5
голосов
2ответов
4883 просмотров

Templates for AS3 (like c++)

How do I define C++-like templates in AS3?; I have a map class (2d array) that I want to re-use across projects but the cell data is a different class depending on the project or implementation; There are a bunch of other reasons regarding sharing code accross different implementations, but I'd ...

0
голосов
3ответов
156 просмотров

Preempting __del__ hmmm

I need to preempt __del__ and I want to know what is the right way to do this. Basically my question in code is this.. class A: def __init__(self): self.log = logging.getLogger() self.log.debug("In init") self.closed = False def close(self): self.log.deb...

1
голосов
3ответов
339 просмотров

something i missed here, style in PHP table row works partly!

no border shows up when setting style in the table row below, inside the while loop? why? Background color setting works fine, but not this... NO BORDER SHOWS UP... // Build Result String $display_table = "<table>"; while($row = mysql_fetch_array($qry_result)){ $display_table .= "<...

26
голосов
4ответов
32927 просмотров

What's the ampersand for when used after class name like ostream& operator <

I know about all about pointers and the ampersand means "address of" but what's it mean in this situation? Also, when overloading operators, why is it common declare the parameters with const?

3
голосов
5ответов
34201 просмотров

Fatal error: Call to undefined method stdClass

I get an error that says Fatal error: Call to undefined method stdClass::mysql_con() in ........../.../includes/script/import.php on line 68. Line 68 corresponds to: if(!$ip2c->mysql_con()) I do have a require_once() statement at the beginning of my script What could be the problem...

2
голосов
2ответов
1360 просмотров

Display lookup value based on foreign-key in bindingsource

I am looking for "best-practices" to display the value of foreign-key in a BindingSource. Sample data: PetID---PetName---PetTypeID 1---Tom---1 2---Jerry---2 PetTypeID---PetType 1---Cat 2---Mouse I have a Pet class and Pet form. The following code is on the Pet form to return data from the ...

2
голосов
3ответов
2469 просмотров

PHP - Extension vs. Library vs. Class - when and why

I'm trying to accomplish a task and turns out that the code I need is packaged as a PHP extension, which according to what I've been told means I have to have root access to install it (I'm on shared hosting so that's a bit of a problem. I'll solve this problem later, but for now I'm trying to ...

0
голосов
2ответов
1090 просмотров

Is it possible to choose the effect for a switchClass jQuery UI function?

I would like to add a subtle and quick fadeOut and FadeIn effect to a button change through switchClass. jQuery("a#btnPause").switchClass(pauseClass,playClass,200); The effect used by default is a slideLeft. If I would use standard jQuery, I would like to put an effect on addClass and removeCl...

5
голосов
2ответов
1357 просмотров

How to work (portably) with C++ class hierarchies & dynamic linked libraries

Ok, so I know portability is not the strong point of C++, but I have to get my code running on both Mac&Windows. I've come up with a solution, but it's not perfect, and I'm interested to see if there is someone out there who can suggest a better one. I need to us a class hierarchy in several...

6
голосов
3ответов
35980 просмотров

VB.NET need a class property to be a list array

Stack Overflowers: I have been racking my brain trying to get an List(of T) type array to be the property of a class. I know there has to be a simple way of doing it and I can't find a good example on google. Everytime I create a class that I think will work I get the "Object reference not set...