parameters

Two functions, or one function with different params?

This is a very generic 'best practice' question, but here's an example. Let's say I have a movie cataloging app. I want to give my users the chance to specify, say, IMDb or Metacritic for their synopsis/ rating info. Do I do this: if (preferredSupplier == "imdb"){ getIMDbRating(movieName); }else{ getMetacriticRating(movieN...

Why is my NSInteger changing from 12345 to -1758050543 when I pass it as an argument in an Obj-C method call?

Here's the code in AlertTableView: - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSInteger index = 12345; NSLog(@"AlertTableView: selecting row at index %d", index); [self.caller didSelectRowAtIndex:index withContext:self.context]; } In self.caller: - (void)didSelectRowAtIndex:(NS...

OAuth - lexicographical byte value ordering in c#

I have written an Service Provider implementation for OAuth and one of the Devs found a bug in the way the implementation was ordering query parameters. I totally missed the lexicographical ordering requirement in the OAuth spec and was just doing a basic string sort on the name value parameters Given the following URI request from the...

AS3: declaring an "undefined" parameter for int, uint or Number

I'd like to implement the following logic: function setMyValue (myVar:int = undefined):void { if (myVar == undefined) { /* Generate a value for myVar */ } else { /* Use the supplied value for myVar */ } } So if the value is supplied, use it. If not, generate it. Seems simple enough. Problem is that A...

What is the best method in passing a large number of parameters in SQL Server

I'm trying to work out what the best method to passing a large number of parameters into a stored procedure. Some methods i was thinking about are; Create the relevant database objects, including a parameter object for each item and invoke the command object Pass in an XML document and have the stored procedure unpack it. (The app wil...

DateTime nullable exception as a parameter

I have a Search Form that can search by a few different fields. The problem field is birthDate. On the form it is a string. In the SQL 2005 db it is a DateTime that can be null. The code below is sequential as far as declaring the variable on the form and then setting it. Then the call to the BLL and then the call to the DAL. On ...

Use of "this" keyword in formal parameters for static methods in C#

I've come across several instances of C# code like the following: public static int Foo(this MyClass arg) I haven't been able to find an explanation of what the this keyword means in this case. Any insights? ...

In C#, what happens when you call an extension method on a null object?

Does the method get called with a null value or does it give a null reference exception? MyObject myObject = null; myObject.MyExtensionMethod(); // <-- is this a null reference exception? If this is the case I will never need to check my 'this' parameter for null? ...

Can you pass a class (not an object) is a parameter to a method in python?

I want to do something like the following class A: def static_method_A(): print "hello" def main(param=A): param.static_method_A() I want this to be equivalent to A.static_method(). Is this possible? ...

Passing arrays as parameters in VB6

The following code kills VB6 (sp6) with an 'unhandled exception fault in VB.exe' on two machines in the office on the line marked. ''# Form1.frm Option Explicit Private ArrayHolder As Class2 Private Sub Command1_Click() Set ArrayHolder = New Class2 Dim arr(3) As Long arr(0) = 1 arr(1) = 2 arr(2) = 3 ArrayHolde...

How to pass a method as parameter without declaring a delegate in .NET

No matter how I try, I cannot mimic the clean syntax of Rhino Mocks, without declaring a delegate. Example: Expect.Call(service.HelloWorld("Thanks")) Do you have any idea on how to do this? Thanks. ...

Why can't I pass a direct reference to a dictionary value to a function?

Earlier today I asked a question about passing dictionary values to a function. While I understand now how to accomplish what I was trying to accomplish the why question (which was not asked) was never answered. So my follow up is why can't I def myFunction(newDict['bubba']): some code to process the parameter Is it simply beca...

How to get request parameter to an array in Java, in the style of PHP and Rails?

The situation is as follows: page.jsp?var[0]=foo&var[1]=bar How can this be retrieved in an array in Java? The following: page.jsp?var=foo&var=bar I know can be retrieved using request.getParameterValues("var") Any solutions for the above though? ...

(N is unknown) $controller->$action($param1, $param2, $param3... $paramN);

(N is unknown) $controller->$action($params); must be $controller->$action($param1, $param2, $param3... $paramN); ...

SSAS/SSRS remove parameter from cube report destroys report

Group, We built a data cube using SSAS and are now building SSRS reports off of that cube. Not sure if anyone has come across this, but when you build the report using the wizard and include parameters all looks fine. However if you are in the report after the wizard is compete, and you decide you want to remove one of the parameters y...

JSP, Parameter Passing without use of HTML Forms

I have done some research, and majority of the examples I have found use forms (obviously for user input) to collect data which is then passed to another JSP page through the request object. My question is: "Is it possible to pass a parameter between JSP pages IF the parameter hasn't been set in HTML tags?" Thankyou, Lucas ...

Problems passing in a UserControl as a parameter in VB6

I have a COM-visible method which looks something like the following: Public Sub SomeMethod(someControl as Object) On Error Goto ErrHandler Dim someSpecificControl as SpecificControl MsgBox TypeOf someControl is Control MsgBox TypeOf someControl is SpecificControl On Error Resume Next Set someSpecificControl = someCon...

Rails CRUD Parameters Issue

So my background is in Java web services, but I'm trying to make the move to ROR. I'm using FlexImage to handle image uploading and thumbnail generation. I followed the guide and CRUD behavior was working fine at one point. However, at some point, CRUD behavior for one of my models (Images) was broken. The error code I'm getting back...

MySQL : When stored procedure parameter name is the same as table column name

Hello, Let's say a have a stored procedure SetCustomerName which has an input parameter Name, and I have a table customers with column Name. So inside my stored procedure I want to set customer's name. If I write UPDATE customers SET Name = Name; this is incorrect and I see 2 other ways: UPDATE customers SET Name = `Name`; UPDATE cu...

MySQL : When stored procedure parameter name is the same as table column name [continue]

Hello, Let's say a have a stored procedure SetCustomerName which has an input parameter Name, and I have a table customers with column Name. So inside my stored procedure I want to set customer's name. If I write UPDATE customers SET Name = Name; this is incorrect and I have to write (for example) UPDATE customers SET `Name` = Name;...