we do not speak of frames any longer...
The Big Programming Thread - Page 204
Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
tofucake
Hyrule18947 Posts
we do not speak of frames any longer... | ||
Blisse
Canada3710 Posts
On November 28 2012 01:57 FreezingAssassin wrote: We are currently working in HTML where we use a <a href> to link two pages together as you all know. But What my question is my instructor said there was a possible way for us to link pages without copying and pasting all the a href tags to every single page just to make it work. He said there was a way to link them from another source and it would make it that much easier. So my question is what is the other way to link them? Static Site Generation? link Whoa, 10k! | ||
nakam
Sweden245 Posts
Of course not. It would be terrible if they teach that stuff, but it basically does that. Oh, and you are damn close a big number of posts. | ||
Shield
Bulgaria4824 Posts
On November 27 2012 16:37 phar wrote: I don't really understand what you're trying to do.
That lets you use 'client' and 'out' anywhere in the scope of the class. If you need to use 'out' from another class, make a method to access it: public class Foo { Instantiate foo, call foo.writeString. Really hard to give more specific advice without knowing the situation more. But in general, you should reserve static references from outside a class into another (e.g. Preconditions.checkNotNull) for things that do not rely on any state that can change. It's ok for helper methods that rely only on constants and arguments passed in directly to the method, but it's really not kosher to have it reference something from a constructor. What happens when someone calls that static method without having previously called the constructor? Probably lots of NPEs (if you're lucky), or random wonky shit. There are other reasons to use or avoid static variables or static methods, but they're probably out of scope for what you need to know now. Thanks. It works now. | ||
phar
United States1080 Posts
| ||
white_horse
1019 Posts
for (i = stepsToTry; ((i > 0) && (atHome == false)); i = i - 1) in matlab code? For loops in matlab don't let you have conditionals like the "((i > 0) && (atHome == false))" so I'm kind of stuck with where to start. | ||
CecilSunkure
United States2829 Posts
On November 28 2012 11:02 white_horse wrote: How do I write the c++ code for (i = stepsToTry; ((i > 0) && (atHome == false)); i = i - 1) in matlab code? For loops in matlab don't let you have conditionals like the "((i > 0) && (atHome == false))" so I'm kind of stuck with where to start. Those are called "logical operators". So in matlab you use words instead of the C symbols. The greater and lesser are "relational operators", or comparison operators. So in all you need to google: matlab logical operators matlab comparison operators matlab for loop | ||
Jadoreoov
United States76 Posts
for i=1:10 %loop end Is a loop where i is 1 for the first iteration, then 2, etc. Note there isn't a conditional here. Also, the data range is saved when the loop is first entered, so: x=5; for i=1:x x = x+1 end This loop will only loop 5 times since when the loop is entered the data range of i is set to 1:5 (the initial value of x) The only way to do what you wanted to do is: i = stepsToTry; while (i>0) && (atHome == 0) %do stuff i=i-1 end Note that there is no true or false in Matlab, just 0=false and non-0=true. (There technically is an internal boolean type, but there is no true and false keywords). Also instead of checking atHome==0 you could just check ~atHome (~ is logical not in Matlab) The only thing you have to be careful of this while construction is that the i=i-1 step will be done one extra time compared to the c++ for-loop. | ||
Millitron
United States2611 Posts
| ||
zhurai
United States5660 Posts
On November 28 2012 01:57 FreezingAssassin wrote: We are currently working in HTML where we use a <a href> to link two pages together as you all know. But What my question is my instructor said there was a possible way for us to link pages without copying and pasting all the a href tags to every single page just to make it work. He said there was a way to link them from another source and it would make it that much easier. So my question is what is the other way to link them? Server Side Includes if that's possible is another way than frames + Show Spoiler + also if your instructor is actually seriously trying to get you guys to use iframes... needs to be fired. >_># frames are out of date and really stupid. frames are stupid. | ||
Craton
United States17222 Posts
try Right now I'm working on rebuilding (from scratch) something of mine around best-practices. I've already got a functional version of what I need to use in the interim, so I can take my time with this. I've written this section of code and would like feedback with regard to how better to do it or if it should be left alone. | ||
tec27
United States3690 Posts
But some things anyway:
So I would probably rewrite this something like: using(var connection = new OracleConnection(s3ConnString)) { | ||
Deleted User 101379
4849 Posts
On November 28 2012 16:24 tec27 wrote: Your code doesn't really make much sense, because if you don't have an exception you return a value, but if you do you don't? Tough to see how this would actually fit into a codebase. But some things anyway:
So I would probably rewrite this something like: using(var connection = new OracleConnection(s3ConnString)) { I agree about the exceptions only for exceptional cases and not using catch(Exception..) - basically if you don't know which exception it is, it is most likely something that you want to handle a few levels higher. However, i don't agree about var. I dislike that form since i think it removes readability. The first statement you used is a lot more readable than the second since i know what type it is from the first word, i don't have to scan the line to determine what i'm using there. It introduces a bad habit where suddenly every variable gets declared as "var", just because people are too lazy to write the 5 characters more. You don't even have to write it again because Visual Studio will automatically show you the type after writing the "= new " if you specified the type first, you just have to press autocomplete. Also, C# throws a compile time error if you try to use "using" for something that doesn't implement IDisposable, so it's impossible to use it unneccessarily. | ||
phar
United States1080 Posts
Is it ever possible for OracleDataAdapter to yield a null dataSet.Tables prop? If you're not 100% sure it will always be non-null (and will always be non-null forever), you should probably do a quick null check. As an aside, there are some cases where it's a good idea to catch Exception, but they are few and far between (and likely not here). | ||
Tobberoth
Sweden6375 Posts
That said, it's obviously better for readability and maintanence to stay away from exceptions unless you specifically need to handle them. | ||
tec27
United States3690 Posts
On November 28 2012 17:05 Morfildur wrote: I agree about the exceptions only for exceptional cases and not using catch(Exception..) - basically if you don't know which exception it is, it is most likely something that you want to handle a few levels higher. However, i don't agree about var. I dislike that form since i think it removes readability. The first statement you used is a lot more readable than the second since i know what type it is from the first word, i don't have to scan the line to determine what i'm using there. It introduces a bad habit where suddenly every variable gets declared as "var", just because people are too lazy to write the 5 characters more. You don't even have to write it again because Visual Studio will automatically show you the type after writing the "= new " if you specified the type first, you just have to press autocomplete. Also, C# throws a compile time error if you try to use "using" for something that doesn't implement IDisposable, so it's impossible to use it unneccessarily. Its not about laziness, its about decreasing the amount of code on the screen and focusing on the right issues. When you right out code to enumerate a list, is the important part of that code the enumeration or the type of the list? When you right out code to perform an action on an object, is the important part the type of that object, or the fact that it is able to perform that action? Static typing in its original intentions was meant to protect you from making mistakes, not to make it so you have to demonstrate to the compiler that you're not stupid over and over again. Using var in most cases gets you much closer to that ideal. Along with this, it makes your code focus more on variable naming, and encourages better naming therein. Decreasing redundancy in your code is a good thing. Decreasing line length without decreasing information is a good thing. You should give it a try instead of just running away from it because you're not used to it. And if you're worried about people "being too lazy", you should perhaps think about having a code review process or not working with people that you can't trust, instead of marking good language features as verboten. | ||
AmericanUmlaut
Germany2572 Posts
try | ||
zatic
Zurich15307 Posts
On November 22 2012 20:56 zatic wrote: Thanks guys. "Change" should be enough, I won't need to keep entered but unfinished text elements before they change focus. AmericanUmlaut: Yeah what I am afraid is that their UI uses tons of Javascript already and might do some of the changes to form elements programmatically. I'll know more when I am onsite. The change() thing wasn't really feasible because the form already had all sorts of event handlers on every element that interfered with what I was trying to do. I ended up extending the JS function that submits the form to include the timestamp I needed. + Show Spoiler +
Reminded me how much fun coding is and how much fun Javascript is. Also how much unfun MSIE is | ||
AmericanUmlaut
Germany2572 Posts
On November 28 2012 22:38 zatic wrote: The change() thing wasn't really feasible because the form already had all sorts of event handlers on every element that interfered with what I was trying to do. I ended up extending the JS function that submits the form to include the timestamp I needed. + Show Spoiler +
Reminded me how much fun coding is and how much fun Javascript is. Also how much unfun MSIE is Yeah, when I teach my daughter to code, I'm going to tell her bedtime stories about IE6. I'm so glad I'm working on projects that don't have to support IE<9 any more. I'm curious why you wrapped the redefinition of sendSubmit in a self-executing anonymous function? As far as I can tell, there's no difference between doing that and just putting the same block of code into global namespace. You don't have any variables in there that will expire when the context created by the function dies. Did you intend to declare zsendSubmit inside the function? | ||
tofucake
Hyrule18947 Posts
| ||
| ||