I tried doing this
It does it's function as an or
but when I try displaying the data it also shows the "||" along with it
Can someone please help me on how to solve this the right way. Thank you in advance
I would use two variables, one for each entity. Later, in the response, I would then combine the two variables with an OR. It is a cleaner design and you could reuse the variable values in other places, too.
I have custom rules (CustomRules.js) from where I can do anything, but... when I use the Autoreponder I can't add a double codition like this but not this in same clause.
I really think that this cannot be done by design of that feature, but wanna be sure before leaving it.
Note: I know I can add two conditions, one per field/rule, what I want is to use any kind of operator like URLWithBody that has 2 strings on it. I suspect that is a special function accepting 2 arguments.
Im not english, not that few words may be misstyped.
To make a somewhat long story short, I'm trying to do this:
#define MY_MACRO(x) id myObjectx;
to create myObject1 and myObject2 and so on. I have a lot of these, and the real situation is a little more complicated than just declaring the object and that's it, I need it to repeat a few different things with that number, and copy-paste is getting ugly.
Note: I understand that with the information I've given you you'll be tempted to suggest I just use an array, so I'll explain - I need a bunch of separate KVO properties, and they can't all go in a to-many because the amount of change notifications would get out of hand.
As bmargulies said, you can use ## in the macro:
#define MY_MACRO(x) id myObject##x;
bmargulies, why don't you add your comment as an answer...?
is it possible to use some kind of reflection on parameters in T-SQL module (function,procedure)?
procedure x(#foo nvarchar(max),#bar nvarchar(max)) ...
set #foo = isnull(#foo,0);
set #bar = isnull(#bar,0);
would it be possible to iterate over my parameters and set their values in a loop? Or do I need to use SQLCLR for this?
If you've so many parameters that you need to programatically enumerate them then you probably have too many parameters! Maybe switching to an alternative data structure such as a table valued parameter or an XML document would give you a cleaner way to get such complex data into your procedures/functions?
However, if you have some very special need for this then take a look at sys.parameters (assuming you're using SQL Server 2005 or later).
I don't know of any direct way, but you might find procedure
sp_executesql
useful, its like the exec function in most interpretted languages (run code from 'string'). Probably not the safest or most popular answer, but it could be powerful. What exactly are you trying to do? I can't really be too much more specific (or even sure this will help!) with what you've said so far.
Link
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
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 opinion in this case.
1
val foo : Int = -1
val bar : Int = 1
val yohoho : Double = NaN
2
val foo : Int = -1
val bar : Int = 1
val yohoho : Double = NaN
Did you change your tags? I see several answers referring to Python but the only language tag I see is Scala. If you're interested in Scala I would refer to the unofficial Scala Style Guide. Based on the style guide I would suggest your example should look like this:
val foo = -1
val bar = 1
val yohoho = Double.NaN
The second style will get messed up when variables are renamed using refactoring tools.
It's just my humble opinion, but I personally just hate indentation like the second variant in any programming language. Some claim that "it looks nice" but I find it completely impractical. For example in order to rename the variable yohoho you have to realign all the other variables around (and most editors won't help you with that).
Whatever suits you, you're the coder. The first one just looks funny to me really.
Python's PEP 8 (which is the "Style Guide for Python Code") requests that you don't use whitespace to align code:
Pet Peeves
Avoid extraneous whitespace in the following situations:
....
- More than one space around an assignment (or other) operator to
align it with another.
Yes:
x = 1
y = 2
long_variable = 3
No:
x = 1
y = 2
long_variable = 3
I've tried this with Python, for instance in Django model declarations.
It becomes an OCD inducing pain when you're modifying the code later on. For instance, what if you add a var called yoohoohoey in the 2nd example? You have to go back and add spaces to each line to align it to the new length.
So, I prefer to do things the first way.
Scala doesn't force you to work in either style, but the first is generally preferred because it can really play havoc with diff tools if you have to add a new line and then respace everything else...
On the other hand, if your code/algorithm is much more readable when it's aligned, then align it! Readability trumps all other concerns, as per the agile manifesto:
Individuals and interactions over processes and tools
i.e. It's more important to keep other programmers happy than to keep diff tools happy.
I use the second way, if necessary. Is time consuming to do, but with a bit of time you can configure the auto formatting to make it automatically.
But this is a matter of preference.
The Scala Style Guide is silent on the subject, but I haven't seen vertically align declarations in Scala code, so I'd go with the first choice.
If your goal is to conform to community guidelines, probably the first is more common. But are you looking to fit in -- or to stand out by the quality of your code? Learning what works for you is extremely important.
I suggest you try both styles -- then see how you find working with both. For me, aligning variables is a pain, but it's very helpful when working with larger code files. It's also a nice bit of busy work when I'm stuck on some particular aspect of code and want a little time to let my ideas percolate.
Along this same line of thought, I find that when working with, say, JavaScript, pushing the first line of a function to the far left allows me to scan code very rapidly. That breaks normal indentation rules -- but it's helped me read code far better than nicely indented code.
Whatever suits you is only good enough if you work on your own. If you're part of a group of developers, you should vote and stick to one way. Keep a list of coding standards and enforce it in code reviews.
How often do you have multiple initialized val or var declarations in a Scala file anyway? Top level vals and vars in classes should mostly be primary constructor parameters, if possible. Top level vals in traits will likely be abstract, and thus not initialized. Vals and vars inside methods should absolutely not be padded, as reordering is entirely too likely.
I just searched through a 200 class Scala project, and only found one class where this issue even arises (a "cake pattern" module, where the vals declare the components of my application). It's a non-issue.
Whatever suits you, you're the coder. The second one just looks funny to me really.
Whatever suits you, you're the coder. I find the second one is more of a pain to edit.
I can't speak for Python, but in general you will find both examples across all different languages. In my experience, the first example is more common, but it's a matter of personal taste and I don't believe that another developer would think poorly of you for using either style.
I greatly prefer the first example and agree with others who have commented on the maintainability of the second example. With syntax highlighting available in all IDEs and most quality text editors these days, I don't think the latter style is necessary to keep things readable.
From a usability standpoint while reading, the second is akin to a table layout and it helps you scan it vertically to quickly see that there're two Ints and one Double, but it's also slightly harder to connect the horizontal extremes to see that bar is 1.
The first one makes the individual rows take focus and is easier to scan horizontally to see that bar is 1 but it's harder to quickly see that there're two Ints and one Double.
Expand the example with a lot more lines and it might be easier to "feel" this - but which one to use would be up to which is more important and of course what style is used in the project, team, workplace or best practice for the language in question.
Also, why limit table layouts to only left-aligned columns? ^^
val foo : Int = -1
val bar : Int = 1
val yohoho : Double = NaN
Second style giving headache when you need to search for specific text. When code file grows large sometime you need to seek for specific text, If you coding with custom spaces it is hard to find.
We had bad experience with large XML files holding TSQL scripts, Coders before me using style 2 as in your example, end whenever We added new rule or upgrade old one it is painful to search trough files which is codded with custom spaces.
This kind of indentation is useful when someone reads the code, but it is quite up to you to decide.
My answer is don't use it, you will save some time, and you really want to use it, make some text editor that does it, or maybe do yourself some compiler that interpret printed html code, because it's worthless to do it on a text file, which I'll remind you, is a plain long line of bytes reorganized with tabs, space and return carriages.