User Profile
Collapse
-
Oh, I don't hate it (I try never to hate anything; causes too much grief in this world). In fact, I am considering moving to it, but as a relatively new coder, I like to have my braces and brackets line up so that I do not forget to close them. It makes for easy bug fixing IMHO. Helps when you forget to open one too, or am I the only person that ever does that? =D... -
LOL, I stopped reading after I saw the JAVA code. I gotta stop jumping to conclusions. :-)...Leave a comment:
-
Wait a sec...is this the right forum to post this question? I was wondering why you were using "private" and "public" -- that's JAVA not JavaScript. Looks like you got your answer, but I wonder if this post shouldn't be moved to the Languages - JAVA forum instead.Leave a comment:
-
There is only one situation I have come across where the opening brace absolutely had to be on the same line as the opening statement...
[code=javascript]
var EventCache = function()
{
var listEvents = [];
return { // This brace must be on the same line or it errors
listEvents : listEvents,
( ... )
[/code]
I don't know why this is the case....Leave a comment:
-
-
LOL! There are so many levels of amateur, professional, and guru between me and Douglas...I just bow to everyone to be safe. =D
Now you're just being contrary. ;-)
Um...
Maybe this is why you're stuck using the same ugly old style...short memory. =D...Leave a comment:
-
So you align your brackets with the initial statement, but you are not using brackets with the for loop? Interesting. Is that reliable?
[code=javascript]
function myFunc()
{
var a = "Hello", b = "world";
for (var i = 0; i < 3; i++)
alert(a + " " + b);
};
[/code]
Is that about right? What if there is additional code after...Leave a comment:
-
Immediately, I see some redundancy in the code. I would want to create a new function that automatically created these vars above, like this:
[code=javascript]
function createNavVars()
{
for (var i = 0; i < pageName[i].length; i++)
{
var pageName[i] = 'new NavButton(' + pageName[i] + ')';
};
};
[/code]
Or something to that...Leave a comment:
-
Feel free to email me an example, if you don't mind! Like you, I don't like K&R for the same reasons you supplied.
Currently, I am partial to either of the two methods below, but would be interested to see yours as well.
[code=javascript]
function myFunc()
{
var a = "Hello";
var b = "world";
for (var i = 0; i < 3; i++)
{
...Leave a comment:
-
Re-coding from structured to OOP code
I've read through the volumes of information on MDC, Douglas Crawford's site, and many other websites on OOP, and now I am ready to try some conversion on my own code. I understand the principals (I think), but I haven't a clue where to start. So here's some of my existing code, and now I need some suggestions of where to go with this.
[code=javascript]
/*
* capitalize() does exactly what it says
* mouseHover()... -
-
Well, at least you're consistent. =D Funny, when I get code that looks the way you write it, with opening bracket on the same line, closing bracket inline with the function statement, I change it to look the way I prefer.
But unsightly!? C'mon, even a blind man can see my way looks waaaay prettier. =D
It seems that I am not, after all, alone on this point....Leave a comment:
-
I stated coding with Notepad and now with Notepad+. N+ highlights the code blocks with red lines when they are directly inline with one another, but only highlights the brackets themselves when they are indented differently.
[code=javascript]
// With Notepad+, brackets inline
{ // All these lines are
| (...) // highlighted when
} // brackets are inline.
...Leave a comment:
-
Incrementing Vars Preferred Method?
Yet another inane question...but I am looking for coding "best practices" here.
I have always used i++ to increment vars, but have recently found that some well-respected JS coders such as Douglas Crawford use a different method i += 1.
When incrementing by a single integer (1), is the += method still preferred? I can see if you wanted to increment by a value greater than 1 (i.e. i += 2, 3, ... infinity), but... -
RMWChaos started a topic Probably an inane question, but why do we use the current JS coding patterns?in JavascriptProbably an inane question, but why do we use the current JS coding patterns?
Not to go against the grain or anything (or disagree with Douglas Crawford), but why is this considered the de-facto JS coding pattern:
[code=javascript]
// The "Crawford" pattern
function myFunc() {
var a = "Hello";
var b = "world";
for (var i = 0; i < 3; i++) {
alert(a + " " + b);
};
};
[/code]
... -
Well, this answer is ambiguous:
Some people may argue that certain compilers like SmallEiffel convert polymorphic calls into conditionals and that conditionals are faster and better than polymorphic calls. From a technical side it should be noticed that with polymorphic methods, the number of classes will not impact the performance whereas with nested conditionals the more classes that have to be type-checked, the more penalty you get. Then,...Leave a comment:
-
Now to be controversial, I'm not yet convinced that OOP and refactoring are the best ways to program. (Don't laugh at my naiveté!)
What I mean is that I see the benefits to OOP and refactoring as they apply to maintaining code, particularly as code grows to huge proportions. So it is good for developers to read, share, and modify.
However, I am not sure that OOP and refactoring are good for code functionality. Does...Leave a comment:
-
Head spinning, brain hemorrhaging, losing all knowledge of programming...J ava-what? What's a script?
Ugh.
Just had a crash-course in OOP, refactoring, and many, Many, MANY other concepts. Now what to do with it all...
Refactoring if conditional statements with polymorphism is a good thing!? AH!!!
I think you are testing my fortitude.Leave a comment:
-
Okay, YES, I have heard of Object Oriented Programming before, but not exactly what that means or what it does--my background is in BASIC and COBOL, which are not OOP languages. Just in reading the explanation of what OOP is, I can already tell it is essentially what I was trying to accomplish with my "modular" code, and what you have been urging me to do all along with util-methods.
So I think you are correct, OOP is going...Leave a comment:
-
Why would it be such a good idea? Just on principal to follow strict coding-guide, or because I am doing something fundamentally wrong with my current code? I really don't mind redoing my code. So far, this has just been a fun learning experience; although, I do have a purpose for the final website. No rush because it is a personal project.
No, I haven't looked at that yet. Still understanding some JS basic structures...Leave a comment:
No activity results to display
Show More
Leave a comment: