I have often pondered this one... its probably an idiot question but here goes.
Say I have this class:
public class SomeClass
{
public int AProperty { get; set; }
public void SomeMethod()
{
DoStuff(AProperty);
}
}
Is there any advantage to doing this:
public class SomeClass
{
public int AProperty { get; ...
Let me start by saying, I am new to Java programming. I have coded something out that performs in the manner that I want it to. However, it is not very well written.
Here is my code:
import java.lang.Math;
public class Advisor_Score {
public static void main(String[] args){
double p1_1[] = {101,1,1,1.5,.5};
do...
Let's say I have a class that looks like this:
public class CallByAttribute
{
[CodeName("Foo")]
public string MyProperty { get; set; }
[CodeName("Bar")]
public string MyMethod(int someParameter)
{
return myDictionary[someParameter];
}
}
How would I call these two properties or methods, using CodeName ...
... like "Swype settings" in this picture. Been searching for hours on how to do this. Going to go insane. Help appreciated.
...
Hi there,
I'm a newbee about jQuery's workflow and I would like to setup a javascript class that uses an internal method to make an AJAX request. When the request returns with success, the jQuery AJAX callback should invoke a method owned by the class itself. That's the code:
function IXClock()
{
this.m_intervalID = 0;
this.sta...
Is it possible to convert a number of methods (defined in an interface and implemented in a class) to run as non-blocking threads?
Certainly, i can wrap each single method in the run() method of a thread class. But perhaps there exists a more sophisticated way to warp several different methods in one step, i.e. by a single thread class...
Something like:
public static void Estimate ( params string [ ] names, params int[] numbers )
{ }
where you could use it like:
Estimate ( "Eric", "Simpson", "Jon", 1, 2, 3, 4, 5 )
...
I get the following error:
Delayed::Job SomeMailJob# (NoMethodError) "undefined method `subject' for #<YAML::Object:0x2b0a191f4c78>"
This comes from the following code which references the SombMailJob above:
class SomeMailJob < Struct.new(:contact, :contact_email)
def perform
OutboundMailer.deliver_campaign_email(contact,co...
I have a class called Cell:
class Cell:
def __init__(self, value, color, size):
self._value = value
self._color = color
self._size = size
# and other methods...
Cell._value will store a string, integer, etc. (whatever I am using that object for). I want all default methods that would normally use the ...
What is the best / good way to implement method calls.
For eg: From the below which is generally considered as best practice. If both are bad, then what is considered as best practice.
Option 1 :
private void BtnPostUpdate_Click(object sender, EventArgs e)
{
getValue();
}
private void getValue()
{
...
I have something like this:
void MethodToBreak()
{
// do something
if(something)
{
MethodThatBreaks();
return;
}
// do something
}
void MethodThatBreaks()
{
// do something
}
So, I was wondering: is it possible to break execution from: MethodThatBreaks()? Then, I would have: if(something) Met...
Hi,
I'm wondering when private/protected methods should work on the class it's variables (like $this->_results) and when such methods should be used as if they were functions (like $this->_method($results)). Examples below:
Work on class properties
<?php
class TestA
{
protected $_results;
public function getResults()
{
...
Is there any way to use extension methods on a class that has been dynamically created using Relection.Emit? For example:
class somewhere
{
somewhere()
{
// define the type here using ReflectionEmit, etc.
Type tableType = CreateTableType(...table parameters...);
var table = Activator.CreateInstan...
Hi all !
I am currently implementing a django app, for this I try to use a syntax that is consistent with Django's...
So here is what I am trying :
class Blablabla(Model):
#this contains Blablabla's options
class Meta:
sort_key = lambda e: e
sort_key is a key function (for sorting purposes), but of course, it is und...
After filling a list with the the needed strings, if the list won't be further appended, should trimexcess be called?
...
I'm creating a doubly-linked list in Objective-C. I would like my node class to include an instance method that allows me to add another node after the target node, like so:
// start <-> nodeA <-> nodeB <-> nodeC <-> end
Node * newNode = [Node node];
[NodeB thisMethodNeedsAGoodName:newNode];
// start <-> nodeA <-> nodeB <-> newNode <-...
Hi guys
I'm working on a social networking site (basically a copy of facebook to be honest...) and I reused big parts of insoshi. But the feed of insoshi is not accurate enough for my likings. As in it doesnt support more specialized messages. You will see what I mean in the following
code:
item = activity.item
relationship = relation...
I have to catch an event from a parent dialog that uses a method from a static class to update an array.
From this dialog I call a child dialog that shows the array in a list.
I know with a variable if the current dialog is the child or the parent dialog, but from the method in the static class how can I call the method inside the chil...
This is the error I get:
ContactPostalcardsController#skip (NoMethodError) "undefined method `status=' for #<ContactPostalcard:0x2b21433d64b0>"
This is the code calling it and trying to assign a value to the status attribute for ContactPostalcard (the Model):
def skip
@contact_postalcard = ContactPostalcard.new(params[:contact...
For consistency, I've always applied comments (in the form of a JavaDoc) to all methods and classes, even if they are simple getters and setters methods or very small wrapper classes. But I'm also striving to write self-documenting code which often makes comments superfluous; i.e. write comments only where needed (and before doing that, ...