Search Results

Search found 9771 results on 391 pages for 'equivalence classes'.

Page 53/391 | < Previous Page | 49 50 51 52 53 54 55 56 57 58 59 60  | Next Page >

  • Final classes in Python 3.x- something Guido isn't telling me?

    - by GlenCrawford
    This question is built on top of many assumptions. If one assumption is wrong, then the whole thing falls over. I'm still relatively new to Python and have just entered the curious/exploratory phase. It is my understanding that Python does not support the creating of classes that cannot be subclassed (final classes). However, it seems to me that the bool class in Python cannot be subclassed. This makes sense when the intent of the bool class is considered (because bool is only supposed to have two values: true and false), and I'm happy with that. What I want to know is how this class was marked as final. So my question is: how exactly did Guido manage to prevent subclassing of bool? >>> class TestClass(bool): pass Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> class TestClass(bool): TypeError: type 'bool' is not an acceptable base type Related question: http://stackoverflow.com/questions/2172189/why-i-cant-extend-bool-in-python

    Read the article

  • how would you like computer science classes to be taught?

    - by aaa
    hello I am a graduate student now, and hopefully someday I will teach. my interests are C++, Python, embedded languages, and scientific computing. Meanwhile I daydream about how I would teach. I was not quite happy with my undergraduate university as I found many computer science classes lacking. so I would like to ask you, if you were a student, how would you like your computer science classes to be taught? I understand it is a very subjective question, but nevertheless I think it's important to know what people want. Some specific points I am interested in: should computer languages be taught explicitly, or should students be required to pick up language on their own? what is better for learning, tests, projects, some sort of take-home exam? how do you think classtime should be used? theory, introduction, explanations, etc.? do you think the group projects are important? how much about computer architecture do you want to learn in computer science class, not necessarily assembler class. should particular operating system/editor be mandated or encouraged? Thanks thank you for your comments. Question has been closed because it is a discussion question rather than Q&A. If you know appropriate website for discussions of such sort with low noise ratio, please let me know.

    Read the article

  • Test Driven Development with C++: How to test a class which depends on other classes?

    - by Nikhil
    Suppose I have a class A which depends on 3 other classes X, Y and Z, either A uses these through a reference or a pointer or say A is templated to be instantiated with X, Y and Z doesn't matter, the key is that in order to test A, I need to have X, Y and Z. So I need to have fakes for A, B and C. Suppose I write them. Now, how do I swap real and fake objects easily? I can see that this works very easily in the case of templates. In order to make it work when A depends on X, Y and Z through a reference or a pointer, I would need to have a base class say X_Interface from which I can inherit X_Real and X_Fake. So basically, I would end up in having 3 times the number of classes for every class that would need to have a fake. I am most likely missing something. There has to be a simpler way to do this. Having a base class X_Interface is also quite expensive as I will be using more space and making virtual calls. I guess I could use CRTP as I know whether its a X_Real or X_Fake at compile time but still there must be a better way.

    Read the article

  • Can I force the auto-generated Linq-to-SQL classes to use an OUTER JOIN?

    - by Gary McGill
    Let's say I have an Order table which has a FirstSalesPersonId field and a SecondSalesPersonId field. Both of these are foreign keys that reference the SalesPerson table. For any given order, either one or two salespersons may be credited with the order. In other words, FirstSalesPersonId can never be NULL, but SecondSalesPersonId can be NULL. When I drop my Order and SalesPerson tables onto the "Linq to SQL Classes" design surface, the class builder spots the two FK relationships from the Order table to the SalesPerson table, and so the generated Order class has a SalesPerson field and a SalesPerson1 field (which I can rename to SalesPerson1 and SalesPerson2 to avoid confusion). Because I always want to have the salesperson data available whenever I process an order, I am using DataLoadOptions.LoadWith to specify that the two salesperson fields are populated when the order instance is populated, as follows: dataLoadOptions.LoadWith<Order>(o => o.SalesPerson1); dataLoadOptions.LoadWith<Order>(o => o.SalesPerson2); The problem I'm having is that Linq to SQL is using something like the following SQL to load an order: SELECT ... FROM Order O INNER JOIN SalesPerson SP1 ON SP1.salesPersonId = O.firstSalesPersonId INNER JOIN SalesPerson SP2 ON SP2.salesPersonId = O.secondSalesPersonId This would make sense if there were always two salesperson records, but because there is sometimes no second salesperson (secondSalesPersonId is NULL), the INNER JOIN causes the query to return no records in that case. What I effectively want here is to change the second INNER JOIN into a LEFT OUTER JOIN. Is there a way to do that through the UI for the class generator? If not, how else can I achieve this? (Note that because I'm using the generated classes almost exclusively, I'd rather not have something tacked on the side for this one case if I can avoid it).

    Read the article

  • .NET MVC: How to fix Visual Studio's lack of awareness of CSS classes in partial views?

    - by Mega Matt
    Hi all, This has been sort of an annoyance for me for a while. I make pretty heavy use of partial views in MVC, and am using Visual Studio 2008 to develop. The problem is that when I give html elements a class in a partial view (<div class="someClass">), it will underline them in green like it doesn't know what they are. I realize this is because I'm in a partial view, and haven't put link tags anywhere in that file for it to know where the CSS is (the link tags are in the main view that renders the partial view). The CSS still works fine on my site because the browser will render all views as one long html page anyway, but it's really annoying to look through my partial views and see all of my classes underlined in green. Is there a way that I can still tell Visual Studio that those classes exist somewhere, from the partial view? I figured there has to be a way to let it know, but am not sure what it is. Maybe a way to import the stylesheets from the parent view? Thanks for your help.

    Read the article

  • How to use StructureMap to inject repository classes to the controller?

    - by Lorenzo
    In the current application I am working on I have a custom ControllerFactory class that create a controller and automatically sets the Elmah ErrorHandler. public class BaseControllerFactory : DefaultControllerFactory { public override IController CreateController( RequestContext requestContext, string controllerName ) { var controller = base.CreateController( requestContext, controllerName ); var c = controller as Controller; if ( c != null ) { c.ActionInvoker = new ErrorHandlingActionInvoker( new HandleErrorWithElmahAttribute() ); } return controller; } protected override IController GetControllerInstance( RequestContext requestContext, Type controllerType ) { try { if ( ( requestContext == null ) || ( controllerType == null ) ) return base.GetControllerInstance( requestContext, controllerType ); return (Controller)ObjectFactory.GetInstance( controllerType ); } catch ( StructureMapException ) { System.Diagnostics.Debug.WriteLine( ObjectFactory.WhatDoIHave() ); throw new Exception( ObjectFactory.WhatDoIHave() ); } } } I would like to use StructureMap to inject some code in my controllers. For example I would like to automatically inject repository classes in them. I have already created my repository classes and also I have added a constructor to the controller that receive the repository class public FirmController( IContactRepository contactRepository ) { _contactRepository = contactRepository; } I have then registered the type within StructureMap ObjectFactory.Initialize( x => { x.For<IContactRepository>().Use<MyContactRepository>(); }); How should I change the code in the CreateController method to have the IContactRepository concrete class injected in the FirmController? EDIT: I have changed the BaseControllerFactory to use Structuremap. But I get an exception on the line return (Controller)ObjectFactory.GetInstance( controllerType ); Any hint?

    Read the article

  • How would I associate a "Note" class to 4+ classes without creating lookup table for each associatio

    - by Gthompson83
    Im creating a project tasklist application. I have project, section, task, issue classes, and would like to use one class to be able to add simple notes to any object instance of those classes. The task, issue tables both use a standard identity field as a primary key. The section table has a two field primary key. The project table has a single int primary key defined by the user. Is there a way to associate the note class with each of these without using a seperate lookup table for each class? I'm not so sure my original idea is a decent way to implement this. I considered the following (each variable mapping to a field n the notes table. Private _NoteId As Integer Private _ProjectId As Integer Private _SectionId As Integer Private _SectionId2 As Integer Private _TaskId As Integer Private _IssueId As Integer Private _Note As String Private _UserId As Guid Then I would be able to write seperate methods (getProjectNotes, getTaskNotes) to get notes attached to each class. I started writing this a few weeks ago but got pulled away before i could finish. When revisiting this code today my first thought "this is retarded". Thoughts on drawbacks to this design?

    Read the article

  • Is there a case for parameterising using Abstract classes rather than Interfaces?

    - by Chris
    I'm currently developing a component based API that is heavily stateful. The top level components implement around a dozen interfaces each. The stock top-level components therefore sit ontop of a stack of Abstract implementations which in turn contain multiple mixin implementations and implement multiple mixin interfaces. So far, so good (I hope). The problem is that the base functionality is extremely complex to implement (1,000s of lines in 5 layers of base classes) and therefore I do not wish for component writers to implement the interfaces themselves but rather to extend my base classes (where all the boiler plate code is already written). If the API therefore accepts interfaces rather than references to the Abstract implementation that I wish for component writers to extends, then I have a risk that the implementer will not perform the validation that is both required and assumed by other areas of code. Therefore, my question is, is it sometimes valid to paramerise API methods using an abstract implementation reference rather than a reference to the interface(s) that it implements? Do you have an example of a well-designed API that uses this technique or am I trying to talk myself into bad-practice?

    Read the article

  • What is the optimal way to animate a drawable within a view using the animator classes?

    - by littleFluffyKitty
    I have read about Property Animation and Hardware Acceleration but I am still uncertain what is the most efficient way to use the animator classes. (For the sake of this question I don't need to support devices before Honeycomb. So I want to use the animator classes.) For example, say I have a View. In this view I have a BitmapDrawable that I want to fade in. There are also many other elements within the view that won't change. What property or object would be best to use with the animator? The drawable? A paint that I am drawing the bitmap with in onDraw? Something else? How can this be done to be most efficient with hardware acceleration? Will this require calling invalidate for each step of the animation or is there a way to animate just the drawable and not cause the rest of the view to be redrawn completely for each step of the animation? I guess I imagine an optimal case would be the rest of the view not having to be completely redrawn in software, but rather hardware acceleration efficiently fading the drawable. Any suggestions or pointers to recommended approaches? Thanks!

    Read the article

  • [C#] How do I make hierarchy of objects from two alternating classes?

    - by Millicent
    Here's the scenario: I have two classes ("Page" and "Field"), that are descended from a common class ("Pield"). They represent tags in an XML file and are in the following hierarchy: <page> <field> <page> ... </page> ... </field> ... </page> I.e.: Page and Field objects are in a hierarchy of alternating type (there may be more than one Page or Field to each rung of the hierarchy). Every Field and Page object has a parent property, which points to the respective parent object of the other type. This is not a problem unless the parent-child mechanism is controlled by the base class (Pield), which is shared by the two descended classes (Page and Field). Here is one try, that fails at the line "Pield child = new Pield(pchild, this);": class Pield<T> { private T _pield_parent; ... private void get_children() { ... Pield<Page> child = new Pield<Page>(pchild, this); ... } ... } class Page : Pield<Field> { ... } class Field : Pield<Page> { ... } Any ideas about how to solve this elegantly? Best, Millicent

    Read the article

  • What are the disadvantages to declaring Scala case classes?

    - by Graham Lea
    If you're writing code that's using lots of beautiful, immutable data structures, case classes appear to be a godsend, giving you all of the following for free with just one keyword: Everything immutable by default Getters automatically defined Decent toString() implementation Compliant equals() and hashCode() Companion object with unapply() method for matching But what are the disadvantages of defining an immutable data structure as a case class? What restrictions does it place on the class or its clients? Are there situations where you should prefer a non-case class?

    Read the article

  • Are wrapper classes banned in the iPhone OS Developer Agreement?

    - by barfoon
    Hey everyone, I am a little confused after reading this thread on the revisions to the iPhone Developer Agreement. While it lists the languages that are permitted, I don't understand what classifies as falling under what is banned. Does this include wrapper classes? What if the code is written in Objective C but is not an official Apple class/library? I'm wondering about things like: Three20 from Facebook SQLite Wrappers such as this one Charting / Graphing Libraries If anyone could clarify this, I'd greatly appreciate it.

    Read the article

  • Where do I find a list of changes and bug fixes for .Net classes from 3.5 -> 4.0?

    - by Nathan Ridley
    I'm having trouble finding a list of the changes and bug fixes that have been made in the .Net framework for .Net 4.0. They're not easy to find, but surely they exist somewhere? Specifically I want to find out what changes and updates have been made for System.Net.HttpWebRequest and System.Net.CookieContainer, as both are quite bugridden in 3.5 and I want to evaluate whether I should write my code for .Net 4.0 or if I should create some custom classes to work around their issues.

    Read the article

  • How can I use CSS pseudo-classes with GWT's UiBinder?

    - by David
    I've been using the in-line styles approach as recommended by GWT's UiBinder documentation. I'm puzzled, though, about how to use CSS pseudo-classes with UiBinder; for example, suppose I would otherwise (without UiBinder) have this CSS rule: #myLink:hover { background:blue } Can I implement that rule in UiBinder?

    Read the article

  • Where is the source archive for my Websphere portal classes?

    - by cringe
    I'm pretty new to Websphere application development and I'm missing the source attachment for all the classes in the com.ibm.wps.* packages in my IBM Rational Application Developer setup. For example the class com.ibm.wps.engine.Command from JAR wp.engine.impl.jar has no source attached. Do I have to install another package with the sources or where can I find it? Also, excuse the question if it is so trivial and stupid... :-}

    Read the article

< Previous Page | 49 50 51 52 53 54 55 56 57 58 59 60  | Next Page >