To remove one level of nested if's you can negate first condition and return empty list
if (! ListItems.Any())
return nodes;
One more thing which wasn't mention yet is
if (item.key.Equals(initialCrs))
{
child.Children.Add(grandChild);
}
else
{
initialCrs = item.key;
parent....
Hey @Robert! Nice to see you here! Glad you are getting everything squared away!
Great answer by @Malachi. Let's talk about performance.
Variables
You have lots of variables and this can slow it down. I see at least two that could be completely eliminated:
SET @Now = getdate()
SET @Today = DATEADD(dd, 0, DATEDIFF(dd, 0, @Now))
There is not really a point in setting a va...
I am wondering what is the best way of returning data to a client where the data is similar in some way. We have a requirement to allow clients to connect to our software via a SOAP method, and we will return all the 'events' which have happened to a particular object.
For example in an online s...
Yeah. I tend to stick to KISS as much as possible. What he's trying to do is very convoluted, if he posted example result set I would start from the ground up.
We are proceeding with the burnination process for some of the meta tags. If you'd like, you may help out by retagging any questions here with non-meta tags.
Just the ones with tags that will be burninated. Questions without a tag automatically receive untagged. If a question just simply cannot use a non-meta tag, it may be subject to deletion.
What materials have you read (or in another way learned from) that make you a better reviewer?
1 item per answer, please. Let the good ones get the votes.
I've noticed a tendency towards two styles of conditionally executing methods:
Conditional before the call
def foo(thing)
puts thing
end
if thing
foo(thing)
end
Conditional within the call
def foo(thing)
return unless thing
puts thing
end
foo(thing)
Pros of 1:
Method is concis...
Let's suppose I have some sort of form that automatically performs a copy procedure when the user either focuses on a textbox, or highlights some text.
Let's suppose that the user has a preference of copying on focus or copying on highlight. By default, it copies on highlight... which leads us t...
Let's say I'm writing a method which can return two very different things based on parameters. I could write that bit of code like this:
function getMyThing(a) {
if (a == 0) {
// Do some stuff
return b;
} else {
// Do some stuff
return c;
}
}
This pi...
I'll start by breaking the code down into different files. There are a many #define and const int here. If I am correct that will definitely grow with your project. Having all the constants in a different file is always a good idea if you are considering making it even moderately big. So to your ...
@ckuhn203 my bet is on C++, but you shouldn't trust that
The rules are as follows:
60+ days must pass between when the post is created and when it is deleted for the rep to "stick"
The score must be 3 or higher at at the time the post was deleted (since the score can't change while it's deleted, that's the same as current score)
This code reads names and ages from an array and prints them.
Then it increments all of the ages and re-prints the names and ages.
This was written in a new and innovative anti-functional, anti-OO paradigm.
It is the pinnacle of all modern C++ code.
#include <iostream>
using namespace std ;
co...
This is a good cleanup. I've come across a question needing a new language tag.
Okay, I've cleaned up these questions quite a bit. Some still have meta tags, but I don't think any will become untagged after the first round of burnination.
Closing this post because it is apparent that there will be no right answers for this question. If the language is so new, and revolutionary, there is just one expert in it, and would thus be entirely opinion-based as to what a reasonable answer would be. — rolfl ♦1 min ago
I have a form that allows the user to select a server. This will execute the exact same query just on a different server.
private void QueryButton_Click(object sender, EventArgs e)
{
switch (this.FindByComboBox.SelectedIndex)
{
case 0:
ByTargetVDN();
brea...
@rolfl Once upon a time, most of us did (in BASIC, and before that in FORTRAN). If you look back far enough, we even used things like if x 100, 200, 300, which meant "goto 100 if x is negative, 200 if x is 0, and 300 if x is positive".
This code reads names and ages from an array and prints them.
Then it increments all of the ages and re-prints the names and ages.
This was written in an anti-functional, anti-OO paradigm.
#include <iostream>
using namespace std ;
const int size = 3 ;
const char * names [] = {"Bob", "Alice", "...
@rolfl I don't doubt it for a moment (as I recall, you're only about 10 years younger than I am). Most days I manage to forget that stuff though...
Point is: with enough persistence, even a beginner can twist his mind enough to code that way and get things to work--but, of course, doing so is a pretty crappy idea, so I quite agree that the question is pointless.
I have a form that allows the user to select a server. This will execute the exact same query just on a different server.
private void QueryButton_Click(object sender, EventArgs e)
{
switch (this.FindByComboBox.SelectedIndex)
{
case 0:
ByTargetVDN();
brea...
I am using this script to get the admin pages via this query string ?page= once the admin is logged in.
Just needing a review, opinions
Function:
// GET PAGE FROM QUERY STRING
public function page_select($page) {
$ext = '.php';
$file = 'pages/'.$page.$ext;
if(file_exists($file)) {
...
I am using this script to get the admin pages via this query string ?page= once the admin is logged in.
Just needing a review, opinions
Function:
// GET PAGE FROM QUERY STRING
public function page_select($page) {
$ext = '.php';
$file = 'pages/'.$page.$ext;
if(file_exists($file)) {
...
What I don't get is why he's filling different datasets? You can't get around having a different source assignment, but after that all code should be reusable.
If you have multiple lines, use shift-enter and, on the second line, you get a new `fixed font` button, which, if you select it will indent all your input with 4 spaces, and it will be code.
I was searching for a pseudo-random number generator for C# and stumbled upon Tales from the CryptoRandom by Stephen Toub and Shawn Farkas, so I tried to implement a variation of their code.
The main difference with their implementation is mine returns inclusive ranges (e.g [0,1] and [min,max] i...