I have an interface class MyFunction. There are three functions in this class with the following signatures:
virtual bool Eval(int& iReturnVal, size_t szArgumentCount, list<Param> lParameterList) = 0;
virtual bool Eval(double& dReturnVal, size_t szArgumentCount, list<Param> lParameterList) = 0;
virtual bool Eval(char*& zReturnVal, size_...
I wrote this today and I'm ashamed. What do I need to do to make this chaotic stuff more accurate and readable amongst others?
switch ((RequestReportsCalculatingStoredProcedures.RequestReportStoredProcedureType)Enum.Parse(typeof(RequestReportsCalculatingStoredProcedures.RequestReportStoredProcedureType), ihdType.Value))
{
...
In the linked SO answer, Eric illustrates a way to call a subroutine, which accepts arrays by reference as arguments, and use the prototypes to allow the caller code to pass the array names without using reference operator \@; the way built-ins like push @array, $value do.
# Original code:
sub Hello { my ($x_ref, $y_ref) = @_; ...}
Hell...
How did it become convention that there is no whitespace in the declaration of a method?
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
It seems like everyone does it, 90% of the examples I see, the generated templates, other people's code, etc., etc. I suspect it's just another vi/e...
I think making code self-explanatory, without need for comments all around the place, is a big advantage. But could you suggest methods and techniques how to reduce the amount of code, make it more readable and understandable.
Also what do you think are the good techniques for reducing big if statements and nested for loops and other st...
We all know the basic rules for static array:
int size = 20;
char myArray[size];
is not legal.
And.
const int size = 20;
char myArray[size];
is OK.
But, what about this.
int f(const int size)
{
char myArr[size];
}
void main()
{
f(2);
f(1024);
}
MSVC says it is an error, gcc seems to compile and execute it fine.
Obvi...
I'mm writing gtk code. I often have short callbacks that don't need to be closures, as they are passed all the parameters they need. For example, I have this in a loop when creating some gtk.TreeViewColumns:
def widthChanged(MAINCOL, SPEC, SUBCOL, expandable):
if expandable: return
w = MAINCOL.get_width()
SUBCOL.set_fixed_wi...
For example, what piece of code is considered better styled? If I show my code to a professional developer and ask if my code is good or not, will using the second style be probably considered as a (minor, but...) minus or a plus to my code quality?
I myself tend to like the second style but would prefer to comply to the most common opi...
I'm currently seeing a lot of questions which are tagged C++ and are about handling arrays.
There even are questions which ask about methods/features for arrays which a std::vector would provide without any magic.
So I'm wondering why so much developers are chosing arrays over std::vector in C++?
...
I am working on a C assignment for uni, and I've been coding in TextMate and compiling in the command line.
But TextMate wont (or cant) format C code, as it would for say, HTML, Ruby or PHP (using SHIFT + CTRL + F).
Is there a plugin or some other tool I can use to fix my indenting and curly braces for .c files?
...
I think every Python code has seen PEP 8. The part that sticks out to me is:
Limit all lines to a maximum of 79 characters.
I'm sitting here on a widescreen monitor and coding right across the screen. I'm not coding in a terminal and don't plan on coding in a terminal. I therefor have no problems with character-line limits.
How many ...
Hi everyone!
I'm trying to write down some concrete ideas for a light framework (on PHP5), with the purpose to handle a lot of requests and to make it scale well in terms of high traffic eventualities.
I've already started it, but I'm not really satisfied about the coding style, which is basically composed by simple classes and helpers,...
Hello,
I'm considering the option of using anonymous { } code blocks to logically distinguish "code blocks" inside the same method call, something that (theoretically) should improve readability of the code.
I'm wondering which of the following 2 code segments is better to your eyes?
Also, are the 2 code segments compile to the same b...
Consider the following code:
def localize(value, localize=None):
# do something with the localize argument
The localize variable contains information whether the global localization setting should be respected or not. It is called by the same name through three layers of code. What's the lesser evil,
shadow the function name wi...
I am coming across situations such as this:
if(x == NULL)
{
printf(" The value of X is Null, exiting..");
return -1;
}
and this "situation" gets repeated many , many times..... laziness aside is there a better way to write this ?
Cheers!
...
In many programs a #define serves the same purpose as a constant. For example.
#define FIELD_WIDTH 10
const int fieldWidth = 10;
I commonly see the first form preferred over the other, relying on the pre-processor to handle what is basically an application decision. Is there a reason for this tradition?
...
As you can see in the MSDN StringValidator documentation, the Validate method returns void.
If validation doesn't succeed the Validate method throws ArgumentException.
I thought that "You only throw an exception when something exceptional happens".
Surely a validator that failed to validate isn't exceptional..
Why not return bool? What a...
I often have functions which take a parameter, set an instance variable to that parameter, and then do other things, e.g.:
def updateFoo(self, foo):
self.foo = foo
fooProcessor1(foo)
fooProcessor2(self.foo)
Do you prefer to pass the parameter itself, as in fooProcessor1, or the newly-set instance variable, as in fooProcess...
What are some of the bad practices you have seen in C# or .NET in general, there are plenty of posts on "good" practices, but I have not seen one on bad practices.
If this is OT then please delete.
...
I have a persistence related java-ee code which I need to rewrite to make the app work on the Google App Engine and its data storage. When I use java-ee persistence providers, I generate persistence entities with my IDE and I keep them the way they are in case I need to regenerate them. However autogenerating entity classes for app-engin...