|
|
Jeremy Falcon wrote: 42 Although that is true, my comment was actually an inside "joke" with Mark.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
He'd have to prove the existence of the variables.
|
|
|
|
|
Extrapolation will be required, however, publicly traded companies file periodic reports from which ballpark data can be obtained. If you're lucky, privately held companies have one or more publicly held competitors and those competitors usually mention some of their competition's numbers in their filings. See here:
SEC.gov | EDGAR | Search Tools:
http://www.sec.gov/edgar/searchedgar/webusers.htm
Once you know when the company started, for example, you might still be able to find old business articles about them on the Internet.
Good luck!
Rick
|
|
|
|
|
Perfect: thanks.
|
|
|
|
|
I'm not interested in submitting a tip, just felt a need to share. This code is nothing really special, but is kind of cool.
I'm working on an app at work that requires me to sum and average certain properies of objects in a list, one property at a time. These values can be either int or double. I wasn't looking forward to writing a method for each possible property, so I decided to use reflection to help.
In order to black-box as much of the code as possible and minimize the apparent exposed footprint of the list, I implemented a series of overloaded methods which the programmer can call without being concerned (beyond catching/ignoring an exception regarding the type of the property being summed.
Once case where an exception might be thrown is if the specified property does not exist in the target class. For this, I implemented a simple InvalidType class.
public class InvalidType
{
}
Next, I created a method that retreives the named propertys type:
private Type GetPropertyType(string propertyName)
{
Type type = typeof(InvalidType);
try
{
type = typeof(MyItemClass).GetProperty(propertyName).PropertyType;
}
catch (Exception)
{
}
return type;
}
Then I created the overloaded methods. The gist is that I want to sum a property in bunch of items in a list, and then (optionally) average the total. This called for four public overloads that look something like this:
public int GetMonthValues(string column, int year, int month, out int total)
{
double average;
double dblTotal;
int count = 0;
total = 0;
count = GetMonthValues(column, year, month, out total, out dblTotal, out average);
return count;
}
These public overloads take care of validating the that the property type matches the intended total parameter's type. The three remaining overloads have the following prototypes:
public int GetMonthValues(string column, int year, int month, out double total)
public int GetMonthValues(string column, int year, int month, out int total, out double average)
public int GetMonthValues(string column, int year, int month, out double total, out double average)
Since most of you are honest-to-god programmers, I don't feel a need to show you the bodies of those methods and assume you can interpolate their contents.
Finally, I have a private overload of GetMonthValues that does all of the heavy lifting. I made it private because I could think of no valid reason that the programmer would need both an integer and a double version of the same totalled property.
private int GetMonthValues(string column, int year, int month, out int intTotal, out double dblTotal, out double average)
{
int count = 0;
intTotal = 0;
dblTotal = 0d;
average = 0d;
List<MyItemClass> itemList = GetItems(month, year);
count = itemList.Count;
Type propertyType = GetPropertyType(column);
if (propertyType == typeof(int))
{
intTotal = itemList.Sum(x => (int)(x.GetType().GetProperty(column).GetValue(x, null)));
average = ((double)intTotal / count);
}
else if (propertyType == typeof(double))
{
dblTotal = itemList.Sum(x => (double)(x.GetType().GetProperty(column).GetValue(x, null)));
average = (dblTotal / count);
}
else
{
throw new Exception("Specified property name either does not exist or of an unsupported type.");
}
return count;
}
Caveat: I have not yet tested this code, but it does compile, and I would be kinda surprised if it didn't work the first time.
I could abstract this out even more and make a method or two static, but I am essentially pretty lazy (which is also why this wasn't submitted as a tip) and won't do it unless it becomes obvious that it would be "better" to do it that way.
Maybe later, I'll share my simple WPF Wizard control...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
modified 10-Oct-14 10:58am.
|
|
|
|
|
John Simmons / outlaw programmer wrote: just felt a need to share
That's the lot of us programmers : we sometimes do miracles, and there is nobody around who could even start to understand why that piece of code is a treasure.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
Entropy isn't what it used to.
|
|
|
|
|
Hmmm, after looking at the code, I relealized I don't need to validate the property type in the public methods, and can simply handle it in the private method...
EDIT============
Fixed the original message to reflect this change.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
John Simmons / outlaw programmer wrote: I have not yet tested this code, but it does compile
Ship it!
|
|
|
|
|
Slacker007 wrote: Ship it! ...to a mission critical process... located on the other side of the world... run by people who do not speak your language.
Government is not reason; it is not eloquent; it is force. Like fire, it is a dangerous servant and a fearful master. ~ George Washington
|
|
|
|
|
Exactly.
|
|
|
|
|
Implement the go live on a Friday afternoon at 1 minute to leaving time......then run quickly.
|
|
|
|
|
..again?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
Not a common question to you?
|
|
|
|
|
|
This campaign[^] is to get students pissing in the shower each morning to save water.
Something I've been doing for years.
But I can't help but think the final image they used in the story is somewhat unfortunate.
Some men are born mediocre, some men achieve mediocrity, and some men have mediocrity thrust upon them.
|
|
|
|
|
I have no clue about the answer to this, but wouldn't running the shower for an extra 20 seconds (or however long it takes one to relieve) waste more water than a low-flow toilet flush? Or are they actually expecting students of all people - especially in the morning - to multitask?
|
|
|
|
|
In the UK 30% of the clean water piped into the average home gets flushed down the toilet.
Showers use around 9 litres a minute.
Some men are born mediocre, some men achieve mediocrity, and some men have mediocrity thrust upon them.
|
|
|
|
|
that is why new houses ( and all renovated houses) need to have greywater[^] systems for toilets.
I'd rather be phishing!
|
|
|
|
|
|
Wee assume that the drains are in good working order.
Marc
|
|
|
|
|
If they're not, urine for a surprise.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
Urethra going to see it drain or stand in it.
Government is not reason; it is not eloquent; it is force. Like fire, it is a dangerous servant and a fearful master. ~ George Washington
|
|
|
|
|
You're not kidney.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|