Search Results

Search found 12093 results on 484 pages for 'partial classes'.

Page 6/484 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • penalty for "inlined" classes

    - by 2di
    Hi All Visual studio allow you to create "inlined" classes (if I am not mistaken with the name). So class header and implementation all in one file. H. file contain definitions and declarations of the class and functions, there is no .cpp file at all. So I was wondering if there is any penalty for doing it that way? any disadvantages ? Thanks a lot

    Read the article

  • Catch requests to non-existent classes (not autoload)

    - by Spot
    Is there a manner in which to catch requests to a class which does not exist. I'm looking for something exactly like __call() and __static(), but for classes as opposed to methods in a class. I am not talking about autoloading. I need to be able to interrupt the request and reroute it. Ideas?

    Read the article

  • How to deal with static utility classes when designing for testability

    - by Benedikt
    We are trying to design our system to be testable and in most parts developed using TDD. Currently we are trying to solve the following problem: In various places it is necessary for us to use static helper methods like ImageIO and URLEncoder (both standard Java API) and various other libraries that consist mostly of static methods (like the Apache Commons libraries). But it is extremely difficult to test those methods that use such static helper classes. I have several ideas for solving this problem: Use a mock framework that can mock static classes (like PowerMock). This may be the simplest solution but somehow feels like giving up. Create instantiable wrapper classes around all those static utilities so they can be injected into the classes that use them. This sounds like a relatively clean solution but I fear we'll end up creating an awful lot of those wrapper classes. Extract every call to these static helper classes into a function that can be overridden and test a subclass of the class I actually want to test. But I keep thinking that this just has to be a problem that many people have to face when doing TDD - so there must already be solutions for this problem. What is the best strategy to keep classes that use these static helpers testable?

    Read the article

  • Classes as a compilation unit

    - by Yannbane
    If "compilation unit" is unclear, please refer to this. However, what I mean by it will be clear from the context. Edit: my language allows for multiple inheritance, unlike Java. I've started designing+developing my own programming language for educational, recreational, and potentially useful purposes. At first, I've decided to base it off Java. This implied that I would have all the code be written inside classes, and that code compiles to classes, which are loaded by the VM. However, I've excluded features such as interfaces and abstract classes, because I found no need for them. They seemed to be enforcing a paradigm, and I'd like my language not to do that. I wanted to keep the classes as the compilation unit though, because it seemed convenient to implement, familiar, and I just liked the idea. Then I noticed that I'm basically left with a glorified module system, where classes could be used either as "namespaces", providing constants and functions using the static directive, or as templates for objects that need to be instantiated ("actual" purpose of classes in other languages). Now I'm left wondering: what are the benefits of having classes as compilation units? (Also, any general commentary on my design would be much appreciated.)

    Read the article

  • Python class design - Splitting up big classes into multiple ones to group functionality

    - by Ivo Wetzel
    OK I've got 2 really big classes 1k lines each that I currently have split up into multiple ones. They then get recombined using multiple inheritance. Now I'm wondering, if there is any cleaner/better more pythonic way of doing this. Completely factoring them out would result in endless amounts of self.otherself.do_something calls, which I don't think is the way it should be done. To make things clear here's what it currently looks like: from gui_events import GUIEvents # event handlers from gui_helpers import GUIHelpers # helper methods that don't directly modify the GUI # GUI.py class GUI(gtk.Window, GUIEvents, GUIHelpers): # general stuff here stuff here One problem that is result of this is Pylint complaining giving me trillions of "init not called" / "undefined attribute" / "attribute accessed before definition" warnings.

    Read the article

  • How to import classes into other classes within the same file in Python

    - by Chris
    I have the file below and it is part of a django project called projectmanager, this file is projectmanager/projects/models.py . Whenever I use the python interpreter to import a Project just to test the functionality i get a name error for line 8 that FileRepo() cannot be found. How Can I import these classes correctly? Ideally what I am looking for is each Project to contain multiple FileRepos which each contain and unknown number of files. Thanks for any assistance in advance. #imports from django.db import models from django.contrib import admin #Project is responsible for ensuring that each project contains all of the folders and file storage #mechanisms a project needs, as well as a unique CCL# class Project(models.Model): ccl = models.CharField(max_length=30) Techpacks = FileRepo() COAS = FileRepo() Shippingdocs = FileRepo() POchemspecs = FileRepo() Internalpos = FileRepo() Finalreports = FileRepo() Batchrecords = FileRepo() RFPS = FileRepo() Businessdev = FileRepo() QA = FileRepo() Updates = FileRepo() def __unicode__(self): return self.ccl #ProjectFile is the file object used by each FileRepo component class ProjectFile(models.Model): file = models.FileField(uploadto='ProjectFiles') def __unicode__(self): return self.file #FileRepo is the model for the "folders" to be used in a Project class FileRepo(models.Model): typeOf = models.CharField(max_length=30) files = models.ManyToManyField(ProjectFile) def __unicode__(self): return self.typeOf

    Read the article

  • Why does forward declaration not work with classes?

    - by eSKay
    int main() { B bb; //does not compile (neither does class B bb;) C cc; //does not compile struct t tt; //compiles class B {}; struct s { struct t * pt; }; //compiles struct t { struct s * ps; }; return 0; } class C {}; I just modified the example given here. Why is that the struct forward declarations work but not the class forward declarations? Does it have something to do with the namespaces - tag namespace and typedef namespace? I know that the structure definitions without typedefs go to tag namespace. Structures are just classes with all public members. So, I expect them to behave similarly.

    Read the article

  • Problem using in GWT project classes from other project/source folders

    - by voipsecuritydigest.com
    My project contains 2 source folder, one is generic J2EE application another is smartCleintGWT, I want to use some already existing DTO classes from first source folder (src) Note that class used on client side and on server side of GWT project! When I do that I getting error [ERROR] Errors in 'file:/C:/..Projects/Admin/DMX/src_console/com/ho/nod/client/AdminRPC.java' [ERROR] Line 7: No source code is available for type com.dmx.synch.server.descriptors.DMXLicense; did you forget to inherit a required module? Source is available obviously; is there any way to import all that into GWT? PS In the future 2 source folder will be separated into 2 projects...I hope it wont be that complicated as well.

    Read the article

  • Can you select an element with two classes in jQuery

    - by Petras
    I have an element that has two classes but can't seem to select it with jQuery. Is it possible. Here's the code: <html> <head runat="server"> <script type="text/javascript" src="abc/scripts/jquery-1.4.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { alert($(".x.y").html()); //shows null, I want it to show "456" }); </script> </head> <body> <div class="x" class"y">456</div> </body> </html>

    Read the article

  • C++ Template Classes Circular Dependency Problem

    - by TomWij
    We have two classes: template<typename T, typename Size, typename Stack, typename Sparse> class Matrix and template<typename T, typename Size> class Iterator Matrix should be able to return begin and end iterators and Iterator will keep a referrence to the Matrix to access the elements via it's interface. We don't want Iterator to depend on the internal storage of the Matrix to prevent coupling. How can we solve this cyclic dependency problem? (The internal Storage class has the same template parameters as the Matrix class and the same access procedures as the Matrix itself)

    Read the article

  • Declare two classes from eachother.

    - by tumba25
    I'm writing a app in NetBeans. I have two classes MyApp_View and MyApp_Functions. The MyApp_View class starts like this public class MyApp_View extends FrameView { MyApp_Functions My_functions = new MyApp_Functions(); public MyApp_View(SingleFrameApplication app) { super(app); In MyApp_Functions I have MyApp_View my_view = new MyApp_View(null); I want to access the public variables in MyApp_View from MyApp_Functions and the public methods in functions from view, but have no success with this. Is this doable? And how?

    Read the article

  • Beginner having a problem with classes

    - by David
    I'm working through O'Reilly's "Learning Python" and having a problem with classes. I think I understand the concept, but in practice have stumbled upon this problem. Fron page 88-89: >>> class Worker: def __innit__(self, name, pay): self.name=name self.pay=pay def lastName(self): return self.name.split()[-1] def giveRaise(self, percent): self.pay*=(1.0+percent) Then the book says "Calling the class like a function generates instances of a new type ...etc" and gives this example. bob = Worker('Bob Smith', 50000) This gives me this error: TypeError: this constructor takes no arguments. And then I start muttering profanities. So what am I doing wrong here? Thanks for the help.

    Read the article

  • Java: Non-static nested classes and instance.super()

    - by Kiv
    I'm having a hard time wrapping my head around non-static nested classes in Java. Consider the following example, which prints "Inner" and then "Child". class Outer { class Inner { Inner() { System.out.println("Inner"); } } } public class Child extends Outer.Inner { Child(Outer o) { o.super(); System.out.println("Child"); } public static void main(String args[]) { new Child(new Outer()); } } I understand that instances of Inner always have to be associated with an Outer instance, and that that applies to Child too since it extends Inner. My question is what the o.super() syntax means - why does it call the Inner constructor? I've only seen a plain super(args) used to call the superclass constructor and super.method() to call the superclass version of an overridden method, but never something of the form instance.super().

    Read the article

  • AS3 Memory management when instantiating extended classes

    - by araid
    I'm developing an AS3 application which has some memory leaks I can't find, so I'd like to ask some newbie questions about memory management. Imagine I have a class named BaseClass, and some classes that extend this one, such as ClassA, ClassB, etc. I declare a variable: myBaseClass:BaseClass = new ClassA(); After a while, I use it to instantiate a new object: myBaseClass = new ClassB(); some time after myBaseClass = new ClassC(); and the same thing keeps happening every x millis, triggered by a timer. Is there any memory problem here? Are the unused instances correctly deleted by the garbage collector? Thanks!

    Read the article

  • Python New-style Classes and the Super Function

    - by sfjedi
    This is not the result I expect to see: class A(dict): def __init__(self, *args, **kwargs): self['args'] = args self['kwargs'] = kwargs class B(A): def __init__(self, *args, **kwargs): super(B, self).__init__(args, kwargs) print 'Instance A:', A('monkey', banana=True) #Instance A: {'args': ('monkey',), 'kwargs': {'banana': True}} print 'Instance B:', B('monkey', banana=True) #Instance B: {'args': (('monkey',), {'banana': True}), 'kwargs': {}} I'm just trying to get classes A and B to have consistent values set. I'm not sure why the kwargs are being inserted into the args, but I'm to presume I am either calling init() wrong from the subclass or I'm trying to do something that you just can't do. Any tips?

    Read the article

  • migrating C++ code from structures to classes

    - by eSKay
    I am migrating some C++ code from structures to classes. I was using structures mainly for bit-field optimizations which I do not need any more (I am more worried about speed than saving space now). What are the general guidelines for doing this migration? I am still in the planning stage as this is a very big move affecting a major part of the code. I want to plan everything first before doing it. What are all the essential things I should keep in mind?

    Read the article

  • Python many-to-one mapping (creating equivalence classes)

    - by Adam Matan
    Hi, I have a project of converting one database to another. One of the original database columns defines the row's category. This coulmn should be mapepd to a new category in the new databse. For example, let's assume the original categories are:parrot, spam, cheese_shop, Cleese, Gilliam, Palin Now that's a little verbose for me, And I want to have these rows categorized as sketch, actor - That is, define all the sketches and all the actors as two equivalence classes. >>> monty={'parrot':'sketch', 'spam':'sketch', 'cheese_shop':'sketch', 'Cleese':'actor', 'Gilliam':'actor', 'Palin':'actor'} >>> monty {'Gilliam': 'actor', 'Cleese': 'actor', 'parrot': 'sketch', 'spam': 'sketch', 'Palin': 'actor', 'cheese_shop': 'sketch'} That's quite awkward- I would prefer having something like: monty={ ('parrot','spam','cheese_shop'): 'sketch', ('Cleese', 'Gilliam', 'Palin') : 'actors'} But this, of course, sets the entire tuple as a key: >>> monty['parrot'] Traceback (most recent call last): File "<pyshell#29>", line 1, in <module> monty['parrot'] KeyError: 'parrot' Any ideas how to create an elegant many-to-one dictionary in Python? Thanks, Adam

    Read the article

  • Obj-C: Passing pointers to initialized classes in other classes

    - by FnGreg7
    Hey all. I initialized a class in my singleton called DataModel. Now, from my UIViewController, when I click a button, I have a method that is trying to access that class so that I may add an object to one of its dictionaries. My get/set method passes back the pointer to the class from my singleton, but when I am back in my UIViewController, the class passed back doesn't respond to methods. It's like it's just not there. I think it has something to do with the difference in passing pointers around classes or something. I even tried using the copy method to throw a copy back, but no luck. UIViewController: ApplicationSingleton *applicationSingleton = [[ApplicationSingleton alloc] init]; DataModel *dataModel = [applicationSingleton getDataModel]; [dataModel retrieveDataCategory:dataCategory]; Singleton: ApplicationSingleton *m_instance; DataModel *m_dataModel; - (id) init { NSLog(@"ApplicationSingleton.m initialized."); self = [super init]; if(self != nil) { if(m_instance != nil) { return m_instance; } NSLog(@"Initializing the application singleton."); m_instance = self; m_dataModel = [[DataModel alloc] init]; } NSLog(@"ApplicationSingleton init method returning."); return m_instance; } -(DataModel *)getDataModel { DataModel *dataModel_COPY = [m_dataModel copy]; return dataModel_COPY; } For the getDataModel method, I also tried this: -(DataModel *)getDataModel { return m_dataModel; } In my DataModel retrieveDataCategory method, I couldn't get anything to work. I even just tried putting a NSLog in there but it never would come onto the console. Any ideas?

    Read the article

  • Partial upgrade error

    - by Dan
    this is an issue I have googled a lot and I have tried a lot of fixes, but non of them really worked. At some point (I can't remember when/how) my Update system sort of broke, and since then it is always complaining about "Not all updates can be installed, run a Partial Upgrade". If I click on Partial Upgrade, I get the following result But running apt-get install -f does not fix anything, and at the end I always get the following message Funny thing is that my apt-get system works perfect on Console. I can update my system through apt-get update, apt-get upgrade etc.. So.. how can I fix the graphic interface? I understand that my apt-get system is not broken, but somehow its GUI it is. Any thoughts about it? THANKS! P.D: I have already tried sudo dpkg --configure -a and sudo apt-get autoremove

    Read the article

  • Extending Currying: Partial Functions in Javascript

    - by kerry
    Last week I posted about function currying in javascript.  This week I am taking it a step further by adding the ability to call partial functions. Suppose we have a graphing application that will pull data via Ajax and perform some calculation to update a graph.  Using a method with the signature ‘updateGraph(id,value)’. To do this, we have do something like this: 1: for(var i=0;i<objects.length;i++) { 2: Ajax.request('/some/data',{id:objects[i].id},function(json) { 3: updateGraph(json.id, json.value); 4: } 5: } This works fine.  But, using this method we need to return the id in the json response from the server.  This works fine, but is not that elegant and increase network traffic. Using partial function currying we can bind the id parameter and add the second parameter later (when returning from the asynchronous call).  To do this, we will need the updated curry method.  I have added support for sending additional parameters at runtime for curried methods. 1: Function.prototype.curry = function(scope) { 2: scope = scope || window 3: var args = []; 4: for (var i=1, len = arguments.length; i < len; ++i) { 5: args.push(arguments[i]); 6: } 7: var m = this; 8: return function() { 9: for (var i=0, len = arguments.length; i < len; ++i) { 10: args.push(arguments[i]); 11: } 12: return m.apply(scope, args); 13: }; 14: } To partially curry this method we will call the curry method with the id parameter, then the request will callback on it with just the value.  Any additional parameters are appended to the method call. 1: for(var i=0;i<objects.length;i++) { 2: var id=objects[i].id; 3: Ajax.request('/some/data',{id: id}, updateGraph.curry(id)); 4: } As you can see, partial currying gives is a very useful tool and this simple method should be a part of every developer’s toolbox.

    Read the article

  • What are the steps to grouping related classes into packages

    - by user2368481
    I've been googling this for some time, but what I haven't found are the clear steps needed to be taken to group related classes into packages in Java. In my case, I have about a number of .java files that I'd like to group into 3 packages according to the MVC pattern. One package for Model classes, one package for View classes and one package for Controller classes. I've identified which belong in what package, but not sure of the next step.

    Read the article

  • What are the differences between abstract classes, interfaces, and when to use them

    - by user66662
    Recently I have started to wrap my head around OOP, and I am now to the point where the more I read about the differences between Abstract classes and Interfaces the more confused I become. So far, neither can be instantiated. Interfaces are more or less structural blueprints that determine the skeleton and abstracts are different by being able to partially develop code. I would like to learn more about these through my specific situation. Here is a link to my first question if you would like a little more background information: What is a good design model for my new class? Here are two classes I created: class Ad { $title; $description $price; function get_data($website){ } function validate_price(){ } } class calendar_event { $title; $description $start_date; function get_data($website){ //guts } function validate_dates(){ //guts } } So, as you can see these classes are almost identical. Not shown here, but there are other functions, like get_zip(), save_to_database() that are common across my classes. I have also added other classes Cars and Pets which have all the common methods and of course properties specific to those objects (mileage, weight, for example). Now I have violated the DRY principle and I am managing and changing the same code across multiple files. I intend on having more classes like boats, horses, or whatever. So is this where I would use an interface or abstract class? From what I understand about abstract classes I would use a super class as a template with all of the common elements built into the abstract class, and then add only the items specifically needed in future classes. For example: abstract class content { $title; $description function get_data($website){ } function common_function2() { } function common_function3() { } } class calendar_event extends content { $start_date; function validate_dates(){ } } Or would I use an interface and, because these are so similar, create a structure that each of the subclasses are forced to use for integrity reasons, and leave it up to the end developer who fleshes out that class to be responsible for each of the details of even the common functions. my thinking there is that some 'common' functions may need to be tweaked in the future for the needs of their specific class. Despite all that above, if you believe I am misunderstanding the what and why of abstracts and interfaces altogether, by all means let a valid answer to be stop thinking in this direction and suggest the proper way to move forward! Thanks!

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >