Search Results

Search found 24043 results on 962 pages for 'private methods'.

Page 101/962 | < Previous Page | 97 98 99 100 101 102 103 104 105 106 107 108  | Next Page >

  • Is there a jquery List plugin that will auto-sort items and has robust add/remove methods?

    - by Breadtruck
    I have been googling for hours looking for something to handle my situation. I am not skilled enough to write my own jquery plugin ..YET!! The plugin should auto-sort the list, not as important as being able to add/remove items from the list easily. Themeroller capable would be a plus. I would basically use anything as long as I could add a item to the list (or any other container for that matter), item is coming from a modal popup that is using ajax to search for the item. Once the item is found I want to click that item and have it added to the list and it would put it into the correct order based on alphabetic sort. I think where I am losing sight is the complexity of the item and needing to have the item contain: The name of the item a hidden value, [the int id of the item], one or two checkboxes for turning on/off a feature for that item. I am really open to any ideas, suggestions on a better process, or a pointer to a plugin that might get me close.

    Read the article

  • android bindservice

    - by mnish
    hi, I get null pointer exception at line mService.start() when i try to bind to an already started service. I do the same thing from different activity(where the service gets started) everythig goes right. All these activities are part of one application. What do you think I do wrong? public class RouteOnMap extends MapActivity{ private static final int NEW_LOCATION = 1; private static final int GPS_OFF = 2; private MapView mMapView; private ILocService mService; private boolean mServiceStarted; private boolean mBound; private Intent mServiceIntent; private double mLatitude, mLongitude; private ServiceConnection connection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder iservice) { mService = ILocService.Stub.asInterface(iservice); mBound = true; } public void onServiceDisconnected(ComponentName className) { mService = null; mBound = false; } }; public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.mapview); mMapView = (MapView) findViewById(R.id.mapview); mMapView.setBuiltInZoomControls(true); mServiceIntent = new Intent(); mLatitude = 0.0; mLongitude = 0.0; mBound = false; } @Override public void onStart(){ super.onStart(); mServiceIntent.setClass(this, LocationService.class); //startService(mServiceIntent); if(!mBound){ mBound = true; this.bindService(mServiceIntent, connection, Context.BIND_AUTO_CREATE); } } @Override public void onResume(){ super.onResume(); try { mService.start(); } catch (RemoteException e) { e.printStackTrace(); } } @Override public void onPause(){ super.onPause(); if(mBound){ this.unbindService(connection); } } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } }

    Read the article

  • What are some methods to debug Javascript inside of a UIWebView?

    - by bpapa
    I'm trying to figure out why something with Javascript isn't working inside of a UIWebView. To my knowledge, there is no way to set a breakpoint inside of XCode for a js file. No problemo, I'll just go back to 2004 and use alert statemen-- oh wait they don't seem to work inside of a UIWebView either! The only thing I could think of is by exporting my HTML And JS files to my desktop and then just doing my debugging inside of Safari. And that works! But of course, the bug I'm fighting with in the UIWebView doesn't occur in Safari. Are there any other ways for debugging inside of a UIWebView, or any tricks that I can use akin to using the old-school alert method?

    Read the article

  • Should all public methods of an API be documented?

    - by cynicalman
    When writing "library" type classes, is it better practice to always write markup documentation (i.e. javadoc) in java or assume that the code can be "self-documenting"? For example, given the following method stub: /** * Copies all readable bytes from the provided input stream to the provided output * stream. The output stream will be flushed, but neither stream will be closed. * * @param inStream an InputStream from which to read bytes. * @param outStream an OutputStream to which to copy the read bytes. * @throws IOException if there are any errors reading or writing. */ public void copyStream(InputStream inStream, OutputStream outStream) throws IOException { // copy the stream } The javadoc seems to be self-evident, and noise that just needs to be updated if the funcion is changed at all. But the sentence about flushing and not closing the stream could be valuable. So, when writing a library, is it best to: a) always document b) document anything that isn't obvious c) never document (code should speak for itself!) I usually use b), myself (since the code can be self-documenting otherwise)...

    Read the article

  • How can i do this using a Python Regex?

    - by uberjumper
    I am trying to properly extract methods definitions that are generated by comtypes for Com Interfaces using a regex. Furthermore some of them are blank which causes even more problems for me. Basically i have this: IXMLSerializerAlt._methods_ = [ COMMETHOD([helpstring(u'Loads an object from an XML string.')], HRESULT, 'LoadFromString', ( ['in'], BSTR, 'XML' ), ( ['in'], BSTR, 'TypeName' ), ( ['in'], BSTR, 'TypeNamespaceURI' ), ( ['retval', 'out'], POINTER(POINTER(IUnknown)), 'obj' )), ] class EnvironmentManager(CoClass): u'Singleton object that manages different environments (collections of configuration information).' _reg_clsid_ = GUID('{8A626D49-5F5E-47D9-9463-0B802E9C4167}') _idlflags_ = [] _typelib_path_ = typelib_path _reg_typelib_ = ('{5E1F7BC3-67C5-4AEE-8EC6-C4B73AAC42ED}', 1, 0) INumberFormat._methods_ = [ ] I want to extract both the IXMLSerializerAlt and INumberFormat methods definitions however i cant figure out a proper regex. E.g. for IXMLSerializer i want to extract this: IXMLSerializerAlt._methods_ = [ COMMETHOD([helpstring(u'Loads an object from an XML string.')], HRESULT, 'LoadFromString', ( ['in'], BSTR, 'XML' ), ( ['in'], BSTR, 'TypeName' ), ( ['in'], BSTR, 'TypeNamespaceURI' ), ( ['retval', 'out'], POINTER(POINTER(IUnknown)), 'obj' )), ] This regex in my mind this should work: ^\w+\._methods_\s=\s\[$ (^.+$)* ^]$ Im checking my regex's using kodos however i cannot figure out a way to make this work.

    Read the article

  • How do I create interface methods using .tlb types in VS C++?

    - by Steven
    Background: The .TLB file contains interfaces written in language 'X'. I don't have .h, .idl, .tlh, or any other header files - just the .TLB file. Language 'X' does not export compatible .h, .idl, etc. I use the VS wizard to add an ATL simple object to my ATL project. I want to add a method to the interface of my simple ATL object that uses one of the .TLB defined types for a parameter. // Something like the following in the .idl file: interface ISomeInterface : IUnknown { HRESULT SomeMethod([in] ITypeFromTLB* aVal); // ITypeFromTLB declared in .TLB file. }; How can I do this? I'm hoping for a wizard, or a line in the .idl interface declaration that would bring in the .tlb information. midl's include (no .tlb), import (no tlb), and importlib (library only) don't seem to provide a solution (I need proxy/stub to be working, so I cannot put this inside the library declaration with the importlib command). Thanks.

    Read the article

  • Any way to identify a redirect when using jQuery's $.ajax() or $.getScript() methods?

    - by Bungle
    Within my company's online application, we've set up a JSONP-based API that returns some data that is used by a bookmarklet I'm developing. Here is a quick test page I set up that hits the API URL using jQuery's $.ajax() method: http://troy.onespot.com/static/3915/index.html If you look at the requests using Firebug's "Net" tab (or the like), you'll see that what's happening is that the URL is requested successfully, but since our app redirects any unauthorized users to a login page, the login page is also requested by the browser and seemingly interpreted as JavaScript. This inevitably causes an exception since the login page is HTML, not JavaScript. Basically, I'm looking for any sort of hook to determine when the request results in a redirect - some way to determine if the URL resolved to a JSONP response (which will execute a method I've predefined in the bookmarklet script) or if it resulted in a redirect. I tried wrapping the $.ajax() method in a try {} catch(e) {} block, but that doesn't trap the exception, I'm assuming because the requests were successful, just not the parsing of the login page as JavaScript. Is there anywhere I could use a try {} catch(e) {} block, or any property of $.ajax() that might allow me to hone in on the exception or otherwise determine that I've been redirected? I actually doubt this is possible, since $.getScript() (or the equivalent setup of $.ajax()) just loads a script dynamically, and can't inspect the response headers since it's cross-domain and not truly AJAX: http://api.jquery.com/jQuery.getScript/ My alternative would be to just fire off the $.ajax() for a period of time until I either get the JSONP callback or don't, and in the latter case, assume the user is not logged in and prompt them to do so. I don't like that method, though, since it would result in a lot of unnecessary requests to the app server, and would also pile up the JavaScript exceptions in the meantime. Thanks for any suggestions!

    Read the article

  • 3 methods for adding a "Product" through Entity Framework. What's the difference?

    - by Kohan
    Reading this MSDN article titled "Working with ObjectSet (Entity Framework)" It shows two examples on how to add a Product.. one for 3.5 and another for 4.0. http://msdn.microsoft.com/en-us/library/ee473442.aspx Through my lack of knowledge I am possibly completely missing something here, but i never added a Product like this: //In .NET Framework 3.5 SP1, use the following code: (ObjectQuery) using (AdventureWorksEntities context = new AdventureWorksEntities()) { // Add the new object to the context. context.AddObject("Products", newProduct); } //New in .NET Framework 4, use the following code: (ObjectSet) using (AdventureWorksEntities context = new AdventureWorksEntities()) { // Add the new object to the context. context.Products.AddObject(newProduct); } I would not have done it either way and just used: // (My familiar way) using (AdventureWorksEntities context = new AdventureWorksEntities()) { // Add the new object to the context. context.AddToProducts(newProduct); } What's the difference between these three ways? Is "My way" just another way of using an ObjectQuery? Thanks, Kohan

    Read the article

  • Why can't I call methods within a class that explicitly implements an interface?

    - by tyrone302
    Here's the story. I created and interface, IVehicle. I explicitly implemented the interface in my class, Vehicle.cs. Here is my interface: Interface IVehicle { int getWheel(); } here is my class: class Vehicle: IVehicle { public int IVehicle.getWheel() { return wheel; } public void printWheel() { Console.WriteLine(getWheel()); } } Notice that "getWheel()" is explicitly implemented. Now, when I try to call that method within my Vehicle class, I receive an error indicating that getWheel() does not exist in the current context. Can someone help me understand what I am doing wrong?

    Read the article

  • Should I supress CA1062: Validate arguments of public methods?

    - by brickner
    I've recently upgraded my project to Visual Studio 2010 from Visual Studio 2008. In Visual Studio 2008, this Code Analysis rule doesn't exist. Now I'm not sure if I should use this rule or not. I'm building an open source library so it seems important to keep people safe from doing mistakes. However, if all I'm going to do is throw ArgumentNullException when the parameter is null, it seems like writing useless code since ArgumentNullException will be thrown even if I won't write that code. Should I remove that rule or fix the violations?

    Read the article

  • good books on numerical computation with C

    - by yCalleecharan
    Hi, I've read the post "What is the best book on numerical methods?" and I wish to ask more or less the same question but in relation to C programming. Most of the time, C programming books on numerical methods are just another version of the author's previous Fortran book on the same subject. I've seen Applied numerical methods in C by Nakamura, Shoichiro and the C codes are not good programming practice. I've heard bad comments about Numerical Recipes by Press. Do you know good books on C that discusses numerical methods. It's seem better for me to ask about good books on C discussing numerical methods than rather asking books on numerical methods that discusses C. I've heard about Numerical Algorithms with C by Giesela Engeln-Müllges and A Numerical Library in C for Scientists and Engineers bu Lau but haven't read them. Good books will always have algorithms implemented in the programming language in a smart way. Thanks a lot...

    Read the article

  • How to serialize a protected property in wcf

    - by Denis Rosca
    Hello, i need some help with wcf serializing. I have two classes Person and Address. The Address class looks like this: public class Adresa : IExtensibleDataObject { private Guid _id; [DataMember] protected virtual Guid Id { get { return _id; } set { _id = value; } } private ExtensionDataObject _extensionData; [DataMember] public virtual ExtensionDataObject ExtensionData { get { return _extensionData; } set { _extensionData = value; } } private string _street; [DataMember] public virtual string Street { get { return this._cUTAM; } set { this._cUTAM = value; } } private string _number; [DataMember] public virtual string Number { get { return this._number; } set { this._number = value; } } private string _postalCode; [DataMember] public virtual string PostalCode { get { return this._postalCode; } set { this._postalCode = value; } } // and some other stuff related to the address } The Person class looks like this: public class PersoanaFizica :IExtensibleDataObject { private Guid _id; [DataMember] protected virtual Guid Id { get { return _id; } set { _id = value; } } private ExtensionDataObject _extensionData; [DataMember] public virtual ExtensionDataObject ExtensionData { get { return _extensionData; } set { _extensionData = value; } } private string _firstName; [DataMember] public virtual string FirstName { get { return this._firstName; } set { this._firstName = value; } } private string _lastName; [DataMember] public virtual string LastName { get { return this._lastName; } set { this._lastName = value; } } } The problem is that when the wcf client the data the Id properties are set to a bunch of zeros ( something like 000000-0000-000000-0000000). Any ideas on why this is happening? Thanks, Denis.

    Read the article

  • mvvm-light: Should we merge Cleanup methods in locator?

    - by mark smith
    Hi there, when creating a new ViewModel within the locator class using the snippet it creates a Cleanup Method but there is already one available from the Main so hence an error.... Should we merge them all?? Or should we be renaming the method to Cleanup[Name of viewmodel] for example. I am a little confused here Another question i would like to ask is regards to the naming conventions. I tried to follow the naming convention used with "MAIN"... hence i have CreateLogin, ClearLogin, Login (non static property for binding) etc etc.. Would it not be better to use CreateLoginViewModel, ClearLoginViewModel etc?? Just curious Thanks

    Read the article

  • Serialization Performance and Google Android

    - by Jomanscool2
    I'm looking for advice to speed up serialization performance, specifically when using the Google Android. For a project I am working on, I am trying to relay a couple hundred objects from a server to the Android app, and am going through various stages to get the performance I need. First I tried a terrible XML parser that I hacked together using Scanner specifically for this project, and that caused unbelievably slow performance when loading the objects (~5 minutes for a 300KB file). I then moved away from that and made my classes implement Serializable and wrote the ArrayList of objects I had to a file. Reading that file into the objects the Android, with the file already downloaded mind you, was taking ~15-30 seconds for the ~100KB serialized file. I still find this completely unacceptable for an Android app, as my app requires loading the data when starting the application. I have read briefly about Externalizable and how it can increase performance, but I am not sure as to how one implements it with nested classes. Right now, I am trying to store an ArrayList of the following class, with the nested classes below it. public class MealMenu implements Serializable{ private String commonsName; private long startMillis, endMillis, modMillis; private ArrayList<Venue> venues; private String mealName; } And the Venue class: public class Venue implements Serializable{ private String name; private ArrayList<FoodItem> foodItems; } And the FoodItem class: public class FoodItem implements Serializable{ private String name; private boolean vegan; private boolean vegetarian; } IF Externalizable is the way to go to increase performance, is there any information as to how java calls the methods in the objects when you try to write it out? I am not sure if I need to implement it in the parent class, nor how I would go about serializing the nested objects within each object.

    Read the article

  • How do I imply code contracts of chained methods to avoid superfluous checks while chaining?

    - by Sandor Drieënhuizen
    I'm using Code Contracts in C# 4.0. I'm applying the usual static method chaining to simulate optional parameters (I know C# 4.0 supports optional parameters but I really don't want to use them). The thing is that my contract requirements are executed twice (or possibly the number of chained overloads I'd implement) if I call the Init(string , string[]) method -- an obvious effect from the sample source code below. This can be expensive, especially due to relatively expensive requirements like the File.Exists I use. public static void Init(string configurationPath, string[] mappingAssemblies) { // The static contract checker 'makes' me put these here as well as // in the overload below. Contract.Requires<ArgumentNullException>(configurationPath != null, "configurationPath"); Contract.Requires<ArgumentException>(configurationPath.Length > 0, "configurationPath is an empty string."); Contract.Requires<FileNotFoundException>(File.Exists(configurationPath), configurationPath); Contract.Requires<ArgumentNullException>(mappingAssemblies != null, "mappingAssemblies"); Contract.ForAll<string>(mappingAssemblies, (n) => File.Exists(n)); Init(configurationPath, mappingAssemblies, null); } public static void Init(string configurationPath, string[] mappingAssemblies, string optionalArgument) { // This is the main implementation of Init and all calls to chained // overloads end up here. Contract.Requires<ArgumentNullException>(configurationPath != null, "configurationPath"); Contract.Requires<ArgumentException>(configurationPath.Length > 0, "configurationPath is an empty string."); Contract.Requires<FileNotFoundException>(File.Exists(configurationPath), configurationPath); Contract.Requires<ArgumentNullException>(mappingAssemblies != null, "mappingAssemblies"); Contract.ForAll<string>(mappingAssemblies, (n) => File.Exists(n)); //... } If however, I remove the requirements from that method, the static checker complains that the requirements of the Init(string, string[], string) overload are not met. I reckon that the static checker doesn't understand that there requirements of the Init(string, string[], string) overload implicitly apply to the Init(string, string[]) method as well; something that would be perfectly deductable from the code IMO. This is the situation I would like to achieve: public static void Init(string configurationPath, string[] mappingAssemblies) { // I don't want to repeat the requirements here because they will always // be checked in the overload called here. Init(configurationPath, mappingAssemblies, null); } public static void Init(string configurationPath, string[] mappingAssemblies, string optionalArgument) { // This is the main implementation of Init and all calls to chained // overloads end up here. Contract.Requires<ArgumentNullException>(configurationPath != null, "configurationPath"); Contract.Requires<ArgumentException>(configurationPath.Length > 0, "configurationPath is an empty string."); Contract.Requires<FileNotFoundException>(File.Exists(configurationPath), configurationPath); Contract.Requires<ArgumentNullException>(mappingAssemblies != null, "mappingAssemblies"); Contract.ForAll<string>(mappingAssemblies, (n) => File.Exists(n)); //... } So, my question is this: is there a way to have the requirements of Init(string, string[], string) implicitly apply to Init(string, string[]) automatically?

    Read the article

  • Accessing Singleton Instance Variable in Class Methods Throws Warning?

    - by Ross
    Hello, I've using the Objective-C singleton from here at stackoverflow. The singleton in the class method accesses it's instance variable, which works, but throws a complie warning. How should I be doing this? Is there a way to do this without accessing the sharedInstance: in each class method? for example here is my class method: + (NSString *)myClassMethods { [instanceDateFormatter setFormat:@"MM"]; return [instanceDateFormatter stringWithDate:somedate]; } line 2 will have the complie warning. Thanks, Ross

    Read the article

  • Is this a good way to expose generic base class methods through an interface?

    - by Nate Heinrich
    I am trying to provide an interface to an abstract generic base class. I want to have a method exposed on the interface that consumes the generic type, but whose implementation is ultimately handled by the classes that inherit from my abstract generic base. However I don't want the subclasses to have to downcast to work with the generic type (as they already know what the type should be). Here is a simple version of the only way I can see to get it to work at the moment. public interface IFoo { void Process(Bar_base bar); } public abstract class FooBase<T> : IFoo where T : Bar_base { abstract void Process(T bar); // Explicit IFoo Implementation void IFoo.Process(Bar_base bar) { if (bar == null) throw new ArgumentNullException(); // Downcast here in base class (less for subclasses to worry about) T downcasted_bar = bar as T; if (downcasted_bar == null) { throw new InvalidOperationException( string.Format("Expected type '{0}', not type '{1}'", T.ToString(), bar.GetType().ToString()); } //Process downcasted object. Process(downcasted_bar); } } Then subclasses of FooBase would look like this... public class Foo_impl1 : FooBase<Bar_impl1> { void override Process(Bar_impl1 bar) { //No need to downcast here! } } Obviously this won't provide me compile time Type Checking, but I think it will get the job done... Questions: 1. Will this function as I think it will? 2. Is this the best way to do this? 3. What are the issues with doing it this way? 4. Can you suggest a different approach? Thanks!

    Read the article

  • C# - Angle between two 2d vectors, diff between two methods?

    - by Sean Ochoa
    Hey all. I've got this code snippet, and I'm wondering why the results of the first method differ from the results of the second method, given the same input? public double AngleBetween_1(vector a, vector b) { var dotProd = a.Dot(b); var lenProd = Len*b.Len; var divOperation = dotProd/lenProd; return Math.Acos(divOperation) * (180.0 / Math.PI); } public double AngleBetween_2(vector a, vector b) { var dotProd = a.Dot(b); var lenProd = Len*b.Len; var divOperation = dotProd/lenProd; return (1/Math.Cos(divOperation)) * (180.0 / Math.PI); }

    Read the article

  • Help regarding composite pattern with hibernate

    - by molleman
    Hello, So i am stuck, i am creating a gwt web application, i will be using a tree(gwt Tree and TreeItems) structure to show a list of folders(class Folder) and files(class FileLocation), the folder and filelocation class will all implement a Hierarchy interface basing the classes on the composite pattern. but i am using hibernate to store my data , and i am using annotations for the mapping of the data to the database. my trouble is i do not know how to annotate my interface. have any of you guys used the composite pattern while persisting the data with hibernate public interface Hierarchy(){ // a few abstract methods that will be implemented by the sub classes } @Entity @Table() public class Folder extends Hierarchy implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "folder_id", updatable = false, nullable = false) private int id; @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER) @JoinTable(name = "FOLDER_FILELOCATION", joinColumns = { @JoinColumn(name = "folder_id") }, inverseJoinColumns = { @JoinColumn(name = "file_information_id") }) private List<Hierarchy> children = new ArrayList<Hierarchy>() ; @Column(name = "folder_name") private String folderName; @Column(name = "tree_item") private TreeItem item; @Column (name = "parent") private Hierarchy parent; @Entity @Table(name = "FILE_INFORMATION_TABLE") public class FileInformation extends Hierarchy implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "file_information_id", updatable = false, nullable = false) private int fiId; @Column (name = "location") private String location; @Column(name = "tree_item") private TreeItem item; @Column (name = "parent") private Hierarchy parent;

    Read the article

  • How do people prove the correctness of Computer Vision methods?

    - by solvingPuzzles
    I'd like to pose a few abstract questions about computer vision research. I haven't quite been able to answer these questions by searching the web and reading papers. How does someone know whether a computer vision algorithm is correct? How do we define "correct" in the context of computer vision? Do formal proofs play a role in understanding the correctness of computer vision algorithms? A bit of background: I'm about to start my PhD in Computer Science. I enjoy designing fast parallel algorithms and proving the correctness of these algorithms. I've also used OpenCV from some class projects, though I don't have much formal training in computer vision. I've been approached by a potential thesis advisor who works on designing faster and more scalable algorithms for computer vision (e.g. fast image segmentation). I'm trying to understand the common practices in solving computer vision problems.

    Read the article

  • Is it possible to utilize internal methods on controllers to reduce duplication?

    - by Maslow
    in a partial view I have the following: <%Html.RenderAction(MVC.User.GetComments(Model.UserGroupName)); %> can I render a Controller's PartialViewResult in a View without going through routing so I can pass arguments directly from the model so that the arguments I'm passing to the controller never get sent to the user or seen by the user? Currently the method I'm showing at the top throws an exception because no overload is public. I've got it marked as internal so that a user can not access it, only the rendering engine was my intent.

    Read the article

  • Can you declare <canvas> methods within a template in javascript?

    - by Binarytales
    Not entirely sure I posed the question in the best way but here goes... I have been playing around with the HTML5 canvas API and have got as far as drawing a shape in the canvas and getting it to move around with the arrow keys. I then tried to move my various variables and functions to a template so I could spawn multiple shapes (that would eventually be controlled by different keys). This is what I have: function player(x, y, z, colour, speed){ this.lx = x; this.ly = y; this.speed = 10; this.playerSize = z; this.colour = colour; } playerOne = new player(100, 100, 10, "#F0F"); function persona(z, colour){ zone.fillStyle = colour; offset = 0 - (z / 2); zone.fillRect(offset, offset, z, z); } function move(x, y){ playerOne.lx = playerOne.lx + x; playerOne.ly = playerOne.ly + y; zone.clearRect(0, 0, 500, 500); zone.save(); zone.translate(playerOne.lx, playerOne.ly); persona(playerOne.playerSize, playerOne.colour); zone.restore(); } window.onkeydown = function() { var direction = this.event.keyCode; var s = playerOne.speed; // Arrow Keys if( direction == 38 && playerOne.ly >= 10){ // Up move(0,-s); } if( direction == 40 && playerOne.ly <= 490){ // Down move(0,s); } if( direction == 37 && playerOne.lx >= 10){ // Left move(-s,0); } if( direction == 39 && playerOne.lx <= 490){ // Right move(s,0); } }; window.onload = function() { zone = document.getElementById('canvas').getContext('2d'); zone.save(); zone.translate(playerOne.lx, playerOne.ly); persona(playerOne.playerSize, playerOne.colour); zone.restore(); }; So what I tried to do was move the persona function into the player template like this: function player(x, y, z, colour, speed){ this.lx = x; this.ly = y; this.speed = 10; function persona(){ zone.fillStyle = colour; var offset = 0 - (z / 2); zone.fillRect(offset, offset, z, z); } } And then where before it said persona(playerOne.playerSize, playerOne.colour); it now just says playerOne.persona(); But this is just totally flaking out and not working and I can't figure out why. I'm probably going about it all the wrong way and I think the problem is that I'm trying to manipulate the canvas.context (call zone in my script) from within a object/template. Perhaps its nothing to do with that at all and I an just not declaring my persona functions properly in the context of the template. Documentation for the canvas API is very thin on the ground and any hint in the right direction will be very much appreciated.

    Read the article

  • When should I use Dependency Injection and when utility methods?

    - by Roman
    I have a Java EE project with Spring IoC container. I've just found in Utils class static method sendMail(long list of params). I don't know why but I feel that it would look better if we had separate class (Spring bean with singleton scope) which will be responsible for sending email. But I can't find any arguments which can prove my position. So, are there any pros (or cons) in using DI in this (rather general) situation?

    Read the article

  • My abstract class implements an interface but doesn't implement some of its methods. How do I make i

    - by Stefan Monov
    interface ICanvasTool { void Motion(Point newLocation); void Tick(); } abstract class CanvasTool_BaseDraw : ICanvasTool { protected abstract void PaintAt(Point location); public override void Motion(Point newLocation) { // implementation } } class CanvasTool_Spray : CanvasTool_BaseDraw { protected abstract void PaintAt(Point location) { // implementation } public override void Tick() { // implementation } } This doesn't compile. I could add an abstract method "Tick_Implementation" to CanvasTool_BaseDraw, then implement ICanvasTool.Tick in CanvasTool_BaseDraw with a one-liner that just calls Tick_Implementation. Is this the recommended workaround?

    Read the article

  • Best practice Unit testing abstract classes?

    - by Paul Whelan
    Hello I was wondering what the best practice is for unit testing abstract classes and classes that extend abstract classes. Should I test the abstract class by extending it and stubbing out the abstract methods and then test all the concrete methods? Then only test the methods I override and the abstract methods in the unit tests for objects that extend my abstract class. Should I have an abstract test case that can be used to test the methods of the abstract class and extend this class in my test case for objects that extend the abstract class? EDIT: My abstract class has some concrete methods. I would be interested to see what people are using. Thanks Paul

    Read the article

< Previous Page | 97 98 99 100 101 102 103 104 105 106 107 108  | Next Page >