Search Results

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

Page 15/962 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Automatic testing of GUI related private methods

    - by Stein G. Strindhaug
    When it comes to GUI programming (at least for web) I feel that often the only thing that would be useful to unit test is some of the private methods*. While unit testing makes perfect sense for back-end code, I feel it doesn't quite fit the GUI classes. What is the best way to add automatic testing of these? * Why I think the only methods useful to test is private: Often when I write GUI classes they don't even have any public methods except for the constructor. The public methods if any is trivial, and the constructor does most of the job calling private methods. They receive some data from server does a lot of trivial output and feeds data to the constructor of other classes contained inside it, adding listeners that calls a (more or less directly) calls the server... Most of it pretty trivial (the hardest part is the layout: css, IE, etc.) but sometimes I create some private method that does some advanced tricks, which I definitely do not want to be publicly visible (because it's closely coupled to the implementation of the layout, and likely to change), but is sufficiently complicated to break. These are often only called by the constructor or repeatedly by events in the code, not by any public methods at all. I'd like to have a way to test this type of methods, without making it public or resorting to reflection trickery. (BTW: I'm currently using GWT, but I feel this applies to most languages/frameworks I've used when coding for GUI)

    Read the article

  • How do app servers inject into private fields?

    - by cibercitizen1
    I saw this question http://stackoverflow.com/questions/2021716/inject-into-private-package-or-public-field-or-provide-a-setter about how to manually inject into annotated private fields (The way is adding setters or through a constructor) But, the point is how do an application server (like glassfish, axis2, jboss, ...) is able to inject into a final private field (without adding setters or constructors to the user class)? Quoting the cited question: public SomeClass { @Inject private SomeResource resource; } Do they use a customized JVM (not the standard one) that allows to access private fields? Thanks

    Read the article

  • C# coding standards for private member variables [closed]

    - by Sasha
    I saw two common approaches for coding standards for private member variables: class Foo { private int _i; private string _id; } and class Foo { private int m_i; private string m_id; } I believe the latter is coming from C++. Also, many people specify type before the member variable: double m_dVal -- to indicate that is is a nonconstant member variable of the type double? What are the conventions in C#?

    Read the article

  • dUnit Testing in Delphi (how to test private methods)

    - by Charles Faiga
    I have a class that I am unit testing into with dUnit It has a number of methods some public Methods & Private Methods type TAuth = class(TDataModule) private procedure PrivateMethod; public procedure PublicMethod; end; In order to write a unit test for this class I have to make all the methods public. Is there a differt way to declare the PrivateMethods so that I can still unit test them but they are not Public ?

    Read the article

  • Datamapper, defining your own object methods, how?

    - by Dublinclontarf
    So lets say I have a class like below class List include DataMapper::Resource property :id, Serial property :username, String def self.my_username return self[:username] end end list=List.create(:username=>,'jim') list.my_username When I run this it tells me that the method cannot be found, and on more investigation that you can only define class methods(not object methods) and that class methods don't have access to objects data. Is there any way to have these methods included as object methods and get access to object data? I'm using Ruby 1.8.6 and the latest version of datamapper.

    Read the article

  • Unit test complex classes with many private methods

    - by Simon G
    Hi, I've got a class with one public method and many private methods which are run depending on what parameter are passed to the public method so my code looks something like: public class SomeComplexClass { IRepository _repository; public SomeComplexClass() this(new Repository()) { } public SomeComplexClass(IRepository repository) { _repository = repository; } public List<int> SomeComplexCalcualation(int option) { var list = new List<int>(); if (option == 1) list = CalculateOptionOne(); else if (option == 2) list = CalculateOptionTwo(); else if (option == 3) list = CalculateOptionThree(); else if (option == 4) list = CalculateOptionFour(); else if (option == 5) list = CalculateOptionFive(); return list; } private List<int> CalculateOptionOne() { // Some calculation } private List<int> CalculateOptionTwo() { // Some calculation } private List<int> CalculateOptionThree() { // Some calculation } private List<int> CalculateOptionFour() { // Some calculation } private List<int> CalculateOptionFive() { // Some calculation } } I've thought of a few ways to test this class but all of them seem overly complex or expose the methods more than I would like. The options so far are: Set all the private methods to internal and use [assembly: InternalsVisibleTo()] Separate out all the private methods into a separate class and create an interface. Make all the methods virtual and in my tests create a new class that inherits from this class and override the methods. Are there any other options for testing the above class that would be better that what I've listed? If you would pick one of the ones I've listed can you explain why? Thanks

    Read the article

  • Unit test helper methods?

    - by Aly
    Hi, I have classes which prviously had massive methods so i subdivided the work of this method into 'helper' methods. These helper methods are declared private to enforce encapsulation - however I want to unit test the big public methods, is it good to unit test the helper methods too as if one of them fail the public method that calls it will also fail - but this way we can identify why it failed. Also in order to test these using a mock object I would need to change their visibility from private to protected, is this desirable?

    Read the article

  • What's the meaning of the angle brackets on LINQ methods in Intellisense? (Contains<>, Count<>, Dis

    - by user312758
    They usually involve generics. But some methods with generics don't have them, and not all extension methods have them. They've just "been there" since day one, we've all seen them; but I realized I still don't know what they mean, and I can't find the answer anywhere. Now it's really bugging me. Google just turns up results that are about XML, etc. Is this officially documented anywhere? Thanks. EDIT: Well that's just great. Since I just created an account to make my first Stack Overflow post, to get an answer for this burning question; I'm not allowed to post my pretty Intellisense picture, or create a new tag "angle-brackets". I love Stack Overflow, but... what a welcome! Maybe my problem is that they aren't actually called "angle brackets"... ?? Anyway, I guess if you really want to see my beautiful screenshot you could manually go to: http://www.freeimagehosting.net/uploads/6a6c2f3268.png Bump me up please so I can include it in the post, thanks. ;)

    Read the article

  • How to queue and call actual methods (rather than immediately eval) in java?

    - by alleywayjack
    There are a list of tasks that are time sensitive (but "time" in this case is arbitrary to what another program tells me - it's more like "ticks" rather than time). However, I do NOT want said methods to evaluate immediately. I want one to execute after the other finished. I'm using a linked list for my queue, but I'm not really sure how/if I can access the actual methods in a class without evaluating them immediate. The code would look something like... LinkedList<Method> l = new LinkedList<Method>(); l.add( this.move(4) ); l.add( this.read() ); l.removeFirst().call(); //wait 80 ticks l.removeFirst().call(); move(4) would execute immediately, then 80 ticks later, I would remove it from the list and call this.read() which would then be executed. I'm assuming this has to do with the reflection classes, and I've poked around a bit, but I can't seem to get anything to work, or do what I want. If only I could use pointers...

    Read the article

  • Methods of learning / teaching programming

    - by Mark Avenius
    When I was in school, I had a difficult time getting into programming because of a catch-22 in the learning process: I didn't know how to write anything because I didn't know what keywords and commands meant. For example (as a student, I would think), "what does this using namespace std; thing do anyway? I didn't know what keywords and commands meant because I hadn't written anything. This basically led me to spending countless long night cursing the compiler as I made minor tweaks to my assignments until they would compile (and hopefully perform whatever operation they were supposed to). Is there a teaching/learning method that anyone uses that gets around this catch-22? I am trying to make this non-argumentative, which is why I don't want to know the 'best' method, but rather which methods exist.

    Read the article

  • Methods to Manage/Document "one-off" Reports

    - by Jason Holland
    I'm a programmer that also does database stuff and I get a lot of so-called one-time report requests and recurring report requests. I work at a company that has a SQL Server database that we integrate third-party data with and we also have some third-party vendors that we have to use their proprietary reporting system to extract data in flat file format from that we don't integrate into SQL Server for security reasons. To generate many of these reports I have to query data from various systems, write small scripts to combine data from the separate systems, cry, pull my hair, curse the last guy's name that made the report before me, etc. My question is, what are some good methods for documenting the steps taken to generate these reports so the next poor soul that has to do them won't curse my name? As of now I just have a folder with subfolders per project with the selects and scripts that generated the last report but that seems like a "poor man's" solution. :)

    Read the article

  • Languages/Methods to Learn for Scientific Computing?:

    - by Zéychin
    I'm a second-semester Junior working towards a Computer Science degree with a Scientific Computing concentration and a Mathematics degree with a concentration on Applied Discrete Mathematics. So, number crunching and such rather than a bunch of regular expressions, interface design, and networking. I've found that I'm not learning new relevant languages from my coursework and am interested in what the community would recommend me to learn. I know as far as programming methods go, I need to learn more about parallelizing programs, but if there's anything else you can recommend, I would appreciate it. Here's a list of the languages with which I am very experienced (web technologies omitted as they barely apply here). Any recommendations for additional languages I should learn would be very much appreciated!: Java C C++ Fortran77/90/95 Haskell Python MATLAB

    Read the article

  • Methods of ordering function definitions in code

    - by xralf
    When I work on some programming project (usually command line application in Python with many switches), I'm usually creating about 30 and more functions. Most of the functions are in one file (except some helpers that I utilize in more projects). Some of the functions are called on particular switch (like -p or --print) but many functions do some helper computations, print operations or database operations because I don't want to main functions be too large. When I have an idea for a new functionality I often put new functions randomly to the file. Should I think more about it and place it to some particular place? Are there some methods for this?

    Read the article

  • Java - What methods to put in an interface and what to keep out

    - by lewicki
    I'm designing a file handler interface: public interface FileHandler { public void openFileHandler(String fileName); public void closeFileHandler(); public String readLine(); public String [] parseLine(String line); public String [] checkLine(String line[]); public void incrementLineCount(); public void incrementLineSuccessCount(); public void incrementLineErrorCount(); public int getLineCount(); public int getLineSuccessCount(); public int getLineErrorCount(); } It is soon apparent to me that these methods can't be made private. I don't want incrementLineCount to be public. What is proper way to design an interface like this?

    Read the article

  • What are the most effective learning methods?

    - by BuckWoody
    After I got done speaking at the SQL Server 2008 R2 Launch Event yesterday I came back to the hotel room for a web-meeting with some of the other teachers at the University of Washington. As teachers we are always looking to improve the knowledge transfer to our students – and the Program Director found an interesting study that I thought I might share here. Below is an un-labeled chart showing the effectiveness of learning methods according to a recent study. At the top are the labels. (“Teaching” here means students teaching each other). Try the experiment we did: place the labels where you think they’ll go. I’ll post the completed chart tomorrow. Share this post: email it! | bookmark it! | digg it! | reddit! | kick it! | live it!

    Read the article

  • Graphic card for parallel programming vs traditional methods

    - by Sambatyon
    With a simple search in amazon one can see that the modern approach for parallel programming is to use your graphic card. However I am still a little bit skeptical about it. My last computer has an 8 core CPU which I need is enough for basic all my parallel needs, if I need more I will probably use MPI through a network using my old machines. All in all, Why and/or when should I use CUDA or another method which uses my graphic card instead of traditional methods like pthreads, java threads, boost threads or the new C++ 11 threads? What about using processes?

    Read the article

  • Problem with Update(GameTime) Methods and Pause implementation

    - by Adam
    I have the pause function implemented and it works correctly in that it dims the player screen and stops updating the gameplay. The problem is that GameTime continues to increase while it is paused, so my method that checks gameTime versus previousSpawnTime before spawning another enemy gets messed up and if the game is paused too long it is noticeable that the next enemy draws far too early. Here is my code for the enemy update. private void UpdateEnemies(GameTime gameTime) { // Spawn a new enemy every 1.5 seconds if (gameTime.TotalGameTime - previousSpawnTime > enemySpawnTime) { previousSpawnTime = gameTime.TotalGameTime; // Add an Enemy AddEnemy(); } ... I also have other methods that depend on gameTime. I've tried getting the total pause time and subtracting that from the total game time, but I can't seem to get it to work correctly if that is the way I should go about solving this. If you need to see any other code let me know. Thank you.

    Read the article

  • deny-uncovered-http-methods in Servlet 3.1

    - by reza_rahman
    Servlet 3.1 is a relatively minor release included in Java EE 7. However, the Java EE foundational API still contains some very important changes. One such set of features are the security enhancements done in Servlet 3.1 such as the new deny-uncovered-http-methods option. Servlet 3.1 co-spec lead Shing Wai Chan outlines the use case for the feature and shows you how to use it in a recent code example driven post. You can also check out the official specification yourself or try things out with the newly released Java EE 7 SDK.

    Read the article

  • Should HTTP Verbs Be Used Semantically?

    - by Xophmeister
    If I'm making a web application which integrates with a server-side backend, would it be considered best practice to use HTTP methods semantically? That is, for example, if I'm fetching data (e.g., to populate a menu, etc.), I would use GET, but to update data (e.g., save a record), I would use POST. (I realise there are other methods that may be even more appropriate, but we need to consider browser support.) I can see the benefits of this in the sense that it's effectively a RESTful API, but at a slightly increased development cost. In my previous projects, I've POST'd everything: Is it worth switching to a RESTful mindset simply for the sake of best practice?

    Read the article

  • How to implement rank structure

    - by Luke101
    What is the best way to implement a rank system: here is the code i will use public class MyRank { private int LevelOneMaxPoints = 100; private int LevelTwoMinPoints = 200; private int LevelTwoMaxPoints = 299; private int LevelThreeMinPoints = 300; private int LevelThreeMaxPoints = 399; private int LevelFourMinPoints = 400; private int LevelFourMaxPoints = 599; private int LevelFourPlusMinPoints = 600; private int LevelFourPlusMaxPoints = 999; private int LevelFiveMinPoints = 1000; private int LevelFiveMaxPoints = 1299; private int LevelSixMinPoints = 1300; private int LevelSixMaxPoints = 2699; private int LevelSevenMinPoints = 2700; private int LevelSevenMaxPoints = 3999; private int LevelEightMinPoints = 4000; private int LevelEightMaxPoints = 5499; private int LevelEightPlusMinPoints = 5500; private int LevelEightPlusMaxPoints = 7499; private int LevelNineMinPoints = 7500; private int LevelNineMaxPoints = 9999; private int LevelTenMinPoints = 10000; private string LevelOneName = "Private"; private string LevelTwoName = "PV2"; private string LevelThreeName = "Private Fist Class"; private string LevelFourName = "Specialist"; private string LevelFourPlusName = "Corporal"; private string LevelFiveName = "Sergeant"; //private string LevelSixName = "Staff Sergeant"; private string LevelSevenName = "Sergeant First Class"; private string LevelEightName = "Master Sergeant"; private string LevelEightPlusName = "First Sergeant"; private string LevelNineName = "Sergeant Major"; //private string LevelTenName = "Sergeant Major of the Answers"; private int points = 0; public string RankName { get; private set; } public MyRank(int points) { this.points = points; RankName = GetRankName(); } private string GetRankName() { if (points >= Int32.MinValue && points <= LevelOneMaxPoints) return LevelOneName; else if (points >= LevelTwoMinPoints && points <= LevelTwoMaxPoints) return LevelTwoName; else if (points >= LevelThreeMinPoints && points <= LevelThreeMaxPoints) return LevelThreeName; else if (points >= LevelFourMinPoints && points <= LevelFourMaxPoints) return LevelFourName; else if (points >= LevelFourPlusMinPoints && points <= LevelFourPlusMaxPoints) return LevelFourPlusName; else if (points >= LevelFiveMinPoints && points <= LevelFiveMaxPoints) return LevelFiveName; else if (points >= LevelSixMinPoints && points <= LevelSixMaxPoints) return LevelFiveName; else if (points >= LevelSevenMinPoints && points <= LevelSevenMaxPoints) return LevelSevenName; else if (points >= LevelEightMinPoints && points <= LevelEightMaxPoints) return LevelEightName; else if (points >= LevelEightPlusMinPoints && points <= LevelEightPlusMaxPoints) return LevelEightPlusName; else if (points >= LevelNineMinPoints && points <= LevelNineMaxPoints) return LevelNineName; else if (points >= LevelNineMinPoints && points <= LevelNineMaxPoints) return LevelNineName; else if (points >= LevelTenMinPoints) return LevelFourName; else return "No Rank"; } } Do you think this is the most efficient way to do this?

    Read the article

  • Abstract Methods in "Product" - Factory Method C#

    - by Regina Foo
    I have a simple class library (COM+ service) written in C# to consume 5 web services: Add, Minus, Divide, Multiply and Compare. I've created the abstract product and abstract factory classes. The abstract product named WS's code: public abstract class WS { public abstract double Calculate(double a, double b); public abstract string Compare(double a, double b); } As you see, when one of the subclasses inherits WS, both methods must be overridden which might not be useful in some subclasses. E.g. Compare doesn't need Calculate() method. To instantiate a new CompareWS object, the client class will call the CreateWS() method which returns a WS object type. public class CompareWSFactory : WSFactory { public override WS CreateWS() { return new CompareWS(); } } But if Compare() is not defined as abstract in WS, the Compare() method cannot be invoked. This is only an example with two methods, but what if there are more methods? Is it stupid to define all the methods as abstract in the WS class? My question is: I want to define abstract methods that are common to all subclasses of WS whereas when the factory creates a WS object type, all the methods of the subclasses can be invoked (overridden methods of WS and also the methods in subclasses). How should I do this?

    Read the article

  • Creation of Objects: Constructors or Static Factory Methods

    - by Rachel
    I am going through Effective Java and some of my things which I consider as standard are not suggested by the book, for instance creation of object, I was under the impression that constructors are the best way of doing it and books says we should make use of static factory methods, I am not able to few some advantages and so disadvantages and so am asking this question, here are the benefits of using it. Advantages: One advantage of static factory methods is that, unlike constructors, they have names. A second advantage of static factory methods is that, unlike constructors, they are not required to create a new object each time they’re invoked. A third advantage of static factory methods is that, unlike constructors, they can return an object of any subtype of their return type. A fourth advantage of static factory methods is that they reduce the verbosity of creating parameterized type instances. I am not able to understand this advantage and would appreciate if someone can explain this point Disadvantages: The main disadvantage of providing only static factory methods is that classes without public or protected constructors cannot be subclassed. A second disadvantage of static factory methods is that they are not readily distinguishable from other static methods.I am not getting this point and so would really appreciate some explanation. Reference: Effective Java, Joshua Bloch, Edition 2, pg: 5-10 Also, How to decide to use whether to go for Constructor or Static Factory Method for Object Creation ?

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >