Search Results

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

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

  • Delphi 5: Ideas for simulating "Obsolete" or "Deprecated" methods?

    - by Ian Boyd
    i want to mark a method as obsolete, but Delphi 5 doesn't have such a feature. For the sake of an example, here is a made-up method with it's deprecated and new preferred form: procedure TStormPeaksQuest.BlowHodirsHorn; overload; //obsolete procedure TStormPeaksQuest.BlowHodirsHorn(UseProtection: Boolean); overload; Note: For this hypothetical example, we assume that using the parameterless version is just plain bad. There are problems with not "using protection" - which have no good solution. Nobody likes having to use protection, but nobody wants to not use protection. So we make the caller decide if they want to use protection or not when blowing Hodir's horn. If we default the parameterless version to continue not using protection: procedure TStormPeaksQuest.BlowHodirsHorn; begin BlowHodirsHorn(False); //No protection. Bad! end; then the developer is at risk of all kinds of nasty stuff. If we force the parameterless version to use protection: procedure TStormPeaksQuest.BlowHodirsHorn; begin BlowHodirsHorn(True); //Use protection; crash if there isn't any end; then there's a potential for problems if the developer didn't get any protection, or doesn't own any. Now i could rename the obsolete method: procedure TStormPeaksQuest.BlowHodirsHorn_Deprecatedd; overload; //obsolete procedure TStormPeaksQuest.BlowHodirsHorn(UseProtection: Boolean); overload; But that will cause a compile error, and people will bitch at me (and i really don't want to hear their whining). i want them to get a nag, rather than an actual error. i thought about adding an assertion: procedure TStormPeaksQuest.BlowHodirsHorn; //obsolete begin Assert(false, 'TStormPeaksQuest.BlowHodirsHorn is deprecated. Use BlowHodirsHorn(Boolean)'); ... end; But i cannot guarantee that the developer won't ship a version without assertions, causing a nasty crash for the customer. i thought about using only throwing an assertion if the developer is debugging: procedure TStormPeaksQuest.BlowHodirsHorn; //obsolete begin if DebugHook > 0 then Assert(false, 'TStormPeaksQuest.BlowHodirsHorn is deprecated. Use BlowHodirsHorn(Boolean)'); ... end; But i really don't want to be causing a crash at all. i thought of showing a MessageDlg if they're in the debugger (which is a technique i've done in the past): procedure TStormPeaksQuest.BlowHodirsHorn; //obsolete begin if DebugHook > 0 then MessageDlg('TStormPeaksQuest.BlowHodirsHorn is deprecated. Use BlowHodirsHorn(Boolean)', mtWarning, [mbOk], 0); ... end; but that is still too disruptive. And it has caused problems where the code is stuck at showing a modal dialog, but the dialog box wasn't obviously visible. i was hoping for some sort of warning message that will sit there nagging them - until they gouge their eyes out and finally change their code. i thought perhaps if i added an unused variable: procedure TStormPeaksQuest.BlowHodirsHorn; //obsolete var ThisMethodIsObsolete: Boolean; begin ... end; i was hoping this would cause a hint only if someone referenced the code. But Delphi shows a hint even if you don't call actually use the obsolete method. Can anyone think of anything else?

    Read the article

  • Deserialize complex JSON (VB.NET)

    - by Ssstefan
    I'm trying to deserialize json returned by some directions API similar to Google Maps API. My JSON is as follows (I'm using VB.NET 2008): jsontext = { "version":0.3, "status":0, "route_summary": { "total_distance":300, "total_time":14, "start_point":"43", "end_point":"42" }, "route_geometry":[[51.025421,18.647631],[51.026131,18.6471],[51.027802,18.645639]], "route_instructions": [["Head northwest on 43",88,0,4,"88 m","NW",334.8],["Continue on 42",212,1,10,"0.2 km","NW",331.1,"C",356.3]] } So far I came up with the following code: Dim js As New System.Web.Script.Serialization.JavaScriptSerializer Dim lstTextAreas As Output_CloudMade() = js.Deserialize(Of Output_CloudMade())(jsontext) I'm not sure how to define complex class, i.e. Output_CloudMade. I'm trying something like: Public Class RouteSummary Private mTotalDist As Long Private mTotalTime As Long Private mStartPoint As String Private mEndPoint As String Public Property TotalDist() As Long Get Return mTotalDist End Get Set(ByVal value As Long) mTotalDist = value End Set End Property Public Property TotalTime() As Long Get Return mTotalTime End Get Set(ByVal value As Long) mTotalTime = value End Set End Property Public Property StartPoint() As String Get Return mStartPoint End Get Set(ByVal value As String) mStartPoint = value End Set End Property Public Property EndPoint() As String Get Return mEndPoint End Get Set(ByVal value As String) mEndPoint = value End Set End Property End Class Public Class Output_CloudMade Private mVersion As Double Private mStatus As Long Private mRSummary As RouteSummary 'Private mRGeometry As RouteGeometry 'Private mRInstructions As RouteInstructions Public Property Version() As Double Get Return mVersion End Get Set(ByVal value As Double) mVersion = value End Set End Property Public Property Status() As Long Get Return mStatus End Get Set(ByVal value As Long) mStatus = value End Set End Property Public Property Summary() As RouteSummary Get Return mRSummary End Get Set(ByVal value As RouteSummary) mRSummary = value End Set End Property 'Public Property Geometry() As String ' Get ' End Get ' Set(ByVal value As String) ' End Set 'End Property 'Public Property Instructions() As String ' Get ' End Get ' Set(ByVal value As String) ' End Set 'End Property End Class but it does not work. The problem is with complex properties, like route_summary. It is filled with "nothing". Other properties, like "status" or "version" are filled properly. Any ideas, how to define class for the above JSON? Can you share some working code for deserializing JSON in VB.NET? Thanks,

    Read the article

  • What are the Jena methods used to access an ontology?

    - by amoosh
    Hello I'm new to ontologies, my assignment is to create an ontology using Protege V4.0.2, (which I've done) and to create a website over that ontology(which I'm working on), i just need the basics on how to search the ontology using the Jena library I dont have any specifics because i haven't yet started. but i'm in a time crunch, and i need to now exactly how i'm goning to do it

    Read the article

  • Netbeans GUI building on pre-defined code

    - by deliriumtremens
    I am supposed edit some code for an assignment, and he gave us the framework and wants us to implement code for it. I load the project into netbeans and can't figure out how I'm supposed to edit the swing components. I don't see how to edit source vs. design. import javax.swing.*; import java.util.*; import java.io.*; public class CurrencyConverterGUI extends javax.swing.JFrame { /************************************************************************************************************** insert your code here - most of this will be generated by NetBeans, however, you must write code for the event listeners and handlers for the two ComboBoxes, the two TextBoxes, and the Button. Please note you must also poulate the ComboBoxes withe currency symbols (which are contained in the KeyList attribute of CurrencyConverter CC) ***************************************************************************************************************/ private CurrencyConverter CC; private javax.swing.JTextField Currency1Field; private javax.swing.JComboBox Currency1List; private javax.swing.JTextField Currency2Field; private javax.swing.JComboBox Currency2List; private javax.swing.JButton jButton1; private javax.swing.JPanel jPanel1; } class CurrencyConverter{ private HashMap HM; // contains the Currency symbols and conversion rates private ArrayList KeyList; // contains the list of currency symbols public CurrencyConverter() { /************************************************** Instantiate HM and KeyList and load data into them. Do this by reading the data from the Rates.txt file ***************************************************/ } public double convert(String FromCurrency, String ToCurrency, double amount){ /*************************************************************************** Will return the converted currency value. For example, to convert 100 USD to GBP, FromCurrency is USD, ToCurrency is GBP and amount is 100. The rate specified in the file represent the amount of each currency which is equivalent to one Euro (EUR). Therefore, 1 Euro is equivalent to 1.35 USD Use the rate specified for USD to convert to equivalent GBP: amount / USD_rate * GBP_rate ****************************************************************************/ } public ArrayList getKeys(){ // return KeyList } } This is what we were given, but I can't do anything with it inside the GUI editor. (Can't even get to the GUI editor). I have been staring at this for about an hour. Any ideas?

    Read the article

  • Is there a Rails authentication library which separates users from login methods?

    - by Gareth
    In my mental model of authentication, a user should be distinct from the way they log in. So for example, a User could have an associated EmailLogin (with an email/password), or they could have many (or none). Similarly they could have 0..* associated OpenIDLogin credentials. Are there any existing authentication libraries for Rails which use this method? Alternatively, is this a really terrible idea?

    Read the article

  • Simplest way to automatically alter "const" value in Java during compile time

    - by Michael Mao
    Hi all: This is a question corresponds to my uni assignment so I am very sorry to say I cannot adopt any one of the following best practices in a short time -- you know -- assignment is due tomorrow :( link to Best way to alter const in Java on StackOverflow Basically the only task (I hope so) left for me is the performance tuning. I've got a bunch of predefined "const" values in my single-class agent source code like this: //static final values private static final long FT_THRESHOLD = 400; private static final long FT_THRESHOLD_MARGIN = 50; private static final long FT_SMOOTH_PRICE_IDICATOR = 20; private static final long FT_BUY_PRICE_MODIFIER = 0; private static final long FT_LAST_ROUNDS_STARTTIME = 90; private static final long FT_AMOUNT_ADJUST_MODIFIER = 5; private static final long FT_HISTORY_PIRCES_LENGTH = 10; private static final long FT_TRACK_DURATION = 5; private static final int MAX_BED_BID_NUM_PER_AUC = 12; I can definitely alter the values manually and then compile the code to give it another go around. But the execution time for a thorough "statistic analysis" usually requires over 2000 times of execution, which will typically lasts more than half an hour on my own laptop... So I hope there is a way to alter values using other ways than dig into the source code to change the "const" values there, so I can automatically distributed compiled code to other people's PC and let them run the statistic analysis instead. One other reason for a automatically value adjustment is that I can try using my own agent to defeat itself by choosing different "const" values. Although my values are derived from previous history and statistical results, they are far from the most optimized values. I hope there is a easy way so I can quickly adopt that so to have a good sleep tonight while the computer does everything for me... :) Any hints on this sort of stuff? Any suggestion is welcomed and much appreciated.

    Read the article

  • JavaScript DOM dimension properties (height, width) vs. jQuery dimension methods

    - by powerboy
    Take height for example. JQ height() <=> JS height // WITHOUT padding, border and margin, including invisible areas JQ innerHeight() <==> JS ??? // WITH padding, WITHOUT border and margin, including invisible areas JQ outerHeight(false) <==> JS ??? // WITH padding and border, WITHOUT margin, including invisible areas JQ outerHeight(true) <==> JS ??? // WITH padding, border and margin, including invisible areas JQ ??? <=> JS offsetHeight // WITH padding and border, WITHOUT margin, NOT including invisible areas JQ ??? <=> JS clientHeight // WITH padding, WITHOUT border and margin, NOT including invisible areas Please help me to correct and complete the list.

    Read the article

  • What methods are used to visualize a 4-dimensional Array?

    - by Atomiton
    An Array ( a row of elements ): [ ][ ][ ][ ][ ][ ] A 2-D Array ( a table ): [ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ] A 3-D Array: //Imagine the above table as a cube ( a table with depth ) How does one visualize a 4-D array? The closest I can come is multiple cubes, so for int[,,,] [5,10,2,7] would be cube 5, row 10, column 2, layer(depth) 7. I'm not sure if this is the best way to visualize a 4-D array, though... and I'm not sure it's the best way to teach it... however it does have the advantage of being extensible ( a row cubes, a table of cubes, a cube of cubes ( 6-d array ) Cubes through time is another way that I can think of it. Am I on the right track here?

    Read the article

  • Overloading framework methods in objective-c, or retaining local changes with framework updates.

    - by Jeff B
    I am using cocos2d to build an iPhone game. It's mostly done, but along the way I came across some things that I would like to handle better. I am fairly new to Objective C, and honestly I do more Perl scripting in my day-to-day job than anything, so my C skills are a little rusty. One of them is the fact that I have modified cocos2d files for some specific cases in my game. However, when I update to a new version, I have to manually pull my changes forward. So, the question is, what is the best way to deal with this? Some options I have thought of: Overload/redefine the cocos2d classes. I was under the impression that I cannot overload existing class functions, so I don't think this will work. Create patches that I re-apply after library updates. I don't think this will work as the new files won't necessarily be the same as the old ones, and if they were, I could just copy the whole file forward. Turn in my changes to Cocos2d. Not an option as my changes are very specific to my application. Am I missing something obvious? UPDATE: I will explain what I am doing to be more clear. Cocos2d has a CCNode object, which can contain children, etc. I added a shadow, which is very similar to a child, but handled a little differently. The shadow has an offset from the parent, and translates with it's parent, rotates around it's own center when the parent rotates, etc. The shadow is not included as a true child, however, so given the correct z-index, the shadows can render under ALL other objects, but still move with the parent. To do this I added addShadow functions to CCNode, and modified the setPosition and setRotate functions to move the shadowSprite: CCNode.m: -(id) init { if ((self=[super init]) ) { ... shadowSprite_ = nil; ... } } ... -(BOOL) addShadow: (CCNode*) child offset: (CGPoint) offset { shadowSprite_ = child; shadowSprite_.position = CGPointMake(position_.x+offset.x, position_.y+offset.y); return YES; } ... -(void) setRotation: (float)newRotation { rotation_ = newRotation; isTransformDirty_ = isInverseDirty_ = YES; if(shadowSprite_) { [shadowSprite_ setRotation: newRotation]; } } There is more, of course, including the prototypes in the .h file, but that is the basics. I don't think I need shadowSprite to be a property, because I don't need to access it after it has been added.

    Read the article

  • Is it possible to unit test methods that rely on NHibernate Detached Criteria?

    - by Aim Kai
    I have tried to use Moq to unit test a method on a repository that uses the DetachedCriteria class. But I come up against a problem whereby I cannot actually mock the internal Criteria object that is built inside. Is there any way to mock detached criteria? Test Method [Test] [Category("UnitTest")] public void FindByNameSuccessTest() { //Mock hibernate here var sessionMock = new Mock<ISession>(); var sessionManager = new Mock<ISessionManager>(); var queryMock = new Mock<IQuery>(); var criteria = new Mock<ICriteria>(); var sessionIMock = new Mock<NHibernate.Engine.ISessionImplementor>(); var expectedRestriction = new Restriction {Id = 1, Name="Test"}; //Set up expected returns sessionManager.Setup(m => m.OpenSession()).Returns(sessionMock.Object); sessionMock.Setup(x => x.GetSessionImplementation()).Returns(sessionIMock.Object); queryMock.Setup(x => x.UniqueResult<SopRestriction>()).Returns(expectedRestriction); criteria.Setup(x => x.UniqueResult()).Returns(expectedRestriction); //Build repository var rep = new TestRepository(sessionManager.Object); //Call repostitory here to get list var returnR = rep.FindByName("Test"); Assert.That(returnR.Id == expectedRestriction.Id); } Repository Class public class TestRepository { protected readonly ISessionManager SessionManager; public virtual ISession Session { get { return SessionManager.OpenSession(); } } public TestRepository(ISessionManager sessionManager) { } public SopRestriction FindByName(string name) { var criteria = DetachedCriteria.For<Restriction>().Add<Restriction>(x => x.Name == name) return criteria.GetExecutableCriteria(Session).UniqueResult<T>(); } } Note I am using "NHibernate.LambdaExtensions" and "Castle.Facilities.NHibernateIntegration" here as well. Any help would be gratefully appreciated.

    Read the article

  • Why ruby object has two to_s and inspect methods that (looks like) do the same thing?

    - by prosseek
    The p calls inspect, and puts/print calls to_s for representing its object. If I run class Graph def initialize @nodeArray = Array.new @wireArray = Array.new end def to_s # called with print / puts "Graph : #{@nodeArray.size}" end def inspect # called with p "G" end end if __FILE__ == $0 gr = Graph.new p gr print gr puts gr end I get G Graph : 0Graph : 0 Then, why does ruby has two functions do the same thing? What makes the difference between to_s and inspect? And what's the difference between puts/print/p? If I comment out the to_s or inspect function, I get as follows. #<Graph:0x100124b88>#<Graph:0x100124b88>

    Read the article

  • Why do LINQ to Entities does not recognize certain Methods?

    - by Luiscencio
    Why cant I do this: usuariosEntities usersDB = new usuariosEntities(); foreach (DataGridViewRow user in dgvUsuarios.Rows) { var rowtoupdate = usersDB.usuarios.Where( u => u.codigo_usuario == Convert.ToInt32(user.Cells[0].Value) ).First(); rowtoupdate.password = user.Cells[3].Value.ToString(); } usersDB.SaveChanges(); And have to do this: usuariosEntities usersDB = new usuariosEntities(); foreach (DataGridViewRow user in dgvUsuarios.Rows) { int usercode = Convert.ToInt32(user.Cells[0].Value); var rowtoupdate = usersDB.usuarios.Where(u => u.codigo_usuario == usercode).First(); rowtoupdate.password = user.Cells[3].Value.ToString(); } usersDB.SaveChanges(); I must admint it is a more readable code but why cant this be done?

    Read the article

  • Other than UDP Broadcast or Multicast, what other methods can I use on a WiFI network to discover co

    - by Gubatron
    I've implemented a simple ping/pong protocol to discover other computers connected to the same WiFI router. This works fine on many routers, but it seems some public routers have UDP traffic blocked or disabled. What other options do I have to discover the computers connected to the router? I was thinking of brute forcing TCP attempts (trying to open connections to all possible IPs on my subnetwork) but this would be very costly and I would have to cycle several times and still not find every machine that's recently connected to the network.

    Read the article

  • Can I add custom methods/attributes to built-in Python types?

    - by sfjedi
    For example—say I want to add a helloWorld() method to Python's dict type. Can I do this? JavaScript has a prototype object that behaves this way. Maybe it's bad design and I should subclass the dict object, but then it only works on the subclasses and I want it to work on any and all future dictionaries. Here's how it would go down in JavaScript: String.prototype.hello = function() { alert("Hello, " + this + "!"); } "Jed".hello() //alerts "Hello, Jed!" Here's a useful link with more examples— http://www.javascriptkit.com/javatutors/proto3.shtml

    Read the article

  • How to store some of the entity's values in another table using hibernate?

    - by nimcap
    Hi guys, is there a simple way to persist some of the fields in another class and table using hibernate. For example, I have a Person class with name, surname, email, address1, address2, city, country fields. I want my classes to be: public class Person { private String name; private String surname; private String email; private Address address; // .. } public class Address { private Person person; // to whom this belongs private String address1; private String address2; private String city; private Address country; // .. } and I want to store Address in another table. What is the best way to achieve this? Edit: I am using annotations. It does not have to be the way I described, I am looking for best practices. PS. If there is a way to make Address immutable (to use as a value object) that is even better, or maybe not because I thought everything from wrong perspective :)

    Read the article

  • How to create custom exception handler for custom controls or extension methods.

    - by Shantanu Gupta
    I am creating an extension method in C# to retrieve some value from datagridview. Here if a user gives column name that doesnot exists then i want this function to throw an exception that can be handled at the place where this function will be called. How can i achieve this. public static T Value<T>(this DataGridView dgv, int RowNo, string ColName) { if (!dgv.Columns.Contains(ColName)) throw new ArgumentException("Column Name " + ColName + " doesnot exists in DataGridView."); return (T)Convert.ChangeType(dgv.Rows[RowNo].Cells[ColName].Value, typeof(T)); }

    Read the article

  • custom attribute changes in .NET 4

    - by Sarah Vessels
    I recently upgraded a C# project from .NET 3.5 to .NET 4. I have a method that extracts all MSTest test methods from a given list of MethodBase instances. Its body looks like this: return null == methods || methods.Count() == 0 ? null : from method in methods let testAttribute = Attribute.GetCustomAttribute(method, typeof(TestMethodAttribute)) where null != testAttribute select method; This worked in .NET 3.5, but since upgrading my projects to .NET 4, this code always returns an empty list, even when given a list of methods containing a method that is marked with [TestMethod]. Did something change with custom attributes in .NET 4? Debugging, I found that the results of GetCustomAttributesData() on the test method gives a list of two CustomAttributeData which are described in Visual Studio 2010's 'Locals' window as: Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute("myDLL.dll") Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute() -- this is what I'm looking for When I call GetType() on that second CustomAttributeData instance, however, I get {Name = "CustomAttributeData" FullName = "System.Reflection.CustomAttributeData"} System.Type {System.RuntimeType}. How can I get TestMethodAttribute out of the CustomAttributeData, so that I can extract test methods from a list of MethodBases?

    Read the article

  • Entity Framework query builder methods: why "it" and not lambdas?

    - by nlawalker
    I'm just getting started with EF and a query like the following strikes me as odd: var departmentQuery = schoolContext.Departments.Include("Courses"). OrderBy("it.Name"); Specifically, what sticks out to me is "it.Name." When I was tooling around with LINQ to SQL, pretty much every filter in a query-builder query could be specified with a lambda, like, in this case, d = d.Name. I see that there are overrides of OrderBy that take lambdas that return an IOrderedQueryable or an IOrderedEnumable, but those obviously don't have the Execute method needed to get the ObjectResult that can then be databound. It seems strange to me after all I've read about how lambdas make so much sense for this kind of stuff, and how they are translated into expression trees and then to a target language - why do I need to use "it.Name"?

    Read the article

  • Javascript / Flash : When exactly are flash external callback methods triggered ?

    - by felace
    I have a flash application using callbacks to javascript functions (eg. when it receives some data over a socket, it'll call a js script which would change the content of a div according to that given data). Afaik, there is no actual mutual exclusion in javascript so I'm not sure if I can/need to simulate something like : callbackFunc() { lock(mutex1) foo unlock(mutex1) } ... someOtherFunc() { lock(mutex1) bar unlock(mutex1) } So, the question is, when are those callbacks called ? Are they simply queued to be executed right after the browser finishes its task or are they triggered randomly ?

    Read the article

  • How do I format and apply rails methods to output of Ruport?

    - by Angela
    I am creating a report from Ruport and want to be able to take the grouping heading, in this case the ID for the class Email, and wrap a method around it and a link_to to link to the Email view based on the email_id: @table = ContactEmail.report_table(:all, :conditions => ['date_sent >= ? and date_sent <= ?', @monday, @friday]) @grouping = Grouping(@table, :by => "email_id") How do I do that? It feels as if I have little control over the output.

    Read the article

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