methods

Should I use regex when trying to write a tokenizer?

I've written a small and simple tokenizer but without use of regular expressions. I starts at first index and iterates through every character until end and creates the required tokens. I showed it to a colleague that said it would've been much simpler to do /that/ with regex without going into any depths. So should I rewrite and e...

Weird idea: C# - declare a method insinde another method.

Okay, in python one can do this: def foo(monkeys): def bar(monkey): #process and return new monkey processed_monkeys = list() for monkey in monkeys: processed_monkeys += bar(monkey) return processed_monkeys (This is just a stupid example) I sometimes miss this functionality of declaring a method inside ...

What is the difference in Python between a class call and a method call?

Being probably one of the worst OOP programmers on the planet, I've been reading through a lot of example code to help 'get' what a class can be used for. Recently I found this example: class NextClass: # define class def printer(self, text): # define method self.message = text ...

How to use pass-by-reference arguments of template type in method templates?

Hello everyone, I am currently struggling to get the following code to compile. First the header file containing a class with a method template: // ConfigurationContext.h class ConfigurationContext { public: template<typename T> T getValue(const std::string& name, T& default) const { ... } } Somew...

Database trigger or a common method in code?

I have a table where I want to Log activities of some part of my application. A record will be inserted (may be updated in future) in this table when record inserted/updated in some other table. E.g. If record is inserted in Orders table an entry will be inserted in Log table. If record is inserted in Booking table an entry will be in...

Objective C Method signatures problem

Hi I have declared a method in one of my classes called HttpWorker. The method declaration is -(void) setRequestParameters:(NSString *)parameters iRequestCode:(double)iRequestCode initialSleep:(long)initialSleep; I am using trying to call this method from another class called NetManager. I wrote following code for this NSString *par...

Objective-C: my class with static methods "does not implement methodSignatureForSelector: -- trouble ahead"

Hi! I have a utility class which has only static methods, so it is not inheriting from NSObject (No need right?) There are no warnings at all when compiling. The problem comes when running on the iPhone simulator. It crashes with warning "does not implement methodSignatureForSelector: -- trouble ahead" Well, I like that "trouble ahead...

distinct Objective-C type Problem

Hi I am having a problem. I have declared a method in my NetManager class with following signatures -(void) getLiveMatchesListScreen:(AutumnViewController *)dataListener initialSleep:(long)initialSleep { Where AutumnViewController is my custom UIViewController. @interface AutumnViewController : UIViewController { } Now I am trying ...

What are the Database replication methods used in your projects? If you are using CDC, how is it useful and what are the challenges?

This is a question for most of the DBA's / Information experts at product level. I need the solution for as many different databases as possible. So please provide the details of the replication methods used. For e.g: Database: Oracle 11i Replication method: Oracle ODI-EE with GoldenGate Pros: Can be integrated with any databases, etc...

calling methods dynamically inside a controller

Hi All, I have the following scenario I want to add methods dynamically to a controller. All my method names are in a table . Please refer the following example -table (method_names)- 1 - Walk 2 - Speek 3 - Run and I have a controller class UsersController < ApplicationController def index end end Inside this index act...

How can I output a calculated value using .detect in Ruby on Rails? (or alternative to .detect)

I currently have the following code: events.detect do |event| #detect does the block until the statement goes false self.event_status(event) == "no status" end What this does is output the instance of event (where events is a string of different Models that all collectively call Events) when the event_status method outputs a "no ...

Create function to loop through properties of a method in C#?

What I am trying to do is create a function that will be called from each method within a .cs file to then get all of the property names and values that are passed to the method and create a string of them. This will be used for a debug log to show what the value of each property was when the error occurred as an alternative to manually...

Implement an Indirect Connectivity Test for Java Graph class

I'm writing a class in Java to represent a Graph data structure. This is specific to an undirected, unweighted graph and it's purpose is mainly for edge testing (is node A connected to node B, either directly or indirectly). I need help implementing the indirectEdgeTest method. In the code below, I've only commented this method and I'...

how to call methods within a class in python - TypeError problem

I have a python class and within the class I call 2 different methods from one of the other methods. One works and one gives me a TypeError: get_doms() takes exactly 1 argument (2 given) : def start(self,cursor): recs = self.get_recs(cursor) # No errors here doms = self.get_doms(cursor) # I get a TypeError here def g...

C#4 Intercept method call

I have this class: public class MyClass { public string GetText() { return "text"; } } What I want is to have a generic caching method. If GetText is called, I want to intercept this call, something like; public T MethodWasCalled<T>(MethodInfo method) { if(Cache.Contains(method.Name)) { return Cache[met...

LINQPad [extension] methods

Does anyone have a complete list of LINQPad extension methods and methods, such as .Dump() SubmitChanges() Much appreciated! ...

Java List type parameter

hi, I have a method which looks like this public void setDayIntervals(Days day, List<HourRange> ranges) { int hourMask = 0; for (HourRange intRange : ranges) { int Start= intRange.getStart(); int end = intRange.getEnd(); } } } I have to pass List of Rang...

Overriding a Javascript method only if it does not exist

My goal here is to override a method if it isn't found, otherwise use the original method (for backwards compatibility of a library I can't alter). This is what I have so far, but am still struggling with: this.grid.getDataSource = function(){ if (typeof this.grid.getDataSource.getDataSource == "undefined") return t...

trying to update an array element in java

I'm trying to update an array element in Java. Some sort of a database like program, but using an array to store data temporarily. The code seems to be working only on the first array element which is 0. If I try to search for other records, it cannot find them. I don't know why. boolean blnFound=false; String strP=getString("Inpu...

Django: Update Field Value Based on Other Fields

I am not sure this is even possible without modifying the Admin interface. I have a model called "Quote" that can contain multiple "Product" models. I connect the two using an intermediate model "QuoteIncludes". Here are the three models as they currently stand: class Product(models.Model): name = models.CharField(max_length=100) ...