Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
tk
Dec 10, 2003

Nap Ghost

ManlyWeevil posted:

So, I'll be graduating I'm May with a CS degree. I have an on site interview coming up for Microsoft for a Program Manager position. I know its not strictly (at all) a programming position, but how different is it? My two concerns are: if i do get offered the position and i decide in a few years that I hate the design, coordination aspect, am I screwing myself over for a coding position in the future, and the second issue is how different is this from any of my formal training and what could I do to prepare?

As far as how different PM is from a programming position, I would have to say "very". It's still in the software development world though, and if for some reason I lost my ability to write code, PM would probably be my first career choice.

If you haven't found it yet, here is a post from Steven Sinofsky (now president of the Windows division) on PM. It's long, and a bit old, but worth a read: http://blogs.msdn.com/b/techtalk/archive/2005/12/16/504872.aspxi

I can't speak to how anybody in charge of hiring a dev would look at PM time. Personally, I think a couple years in PM would give you some valuable experience in areas that a lot of devs are terrible at. You would have to find a way to keep your coding skills up to snuff though.

tk fucked around with this message at 09:16 on Mar 4, 2012

Adbot
ADBOT LOVES YOU

Chasiubao
Apr 2, 2010


I've heard of technical PMs, there's no reason why you can't be one of those. Hell I'd prefer a PM who would have some idea of code so that I can explain why his feature is going to take twice as long as his estimates :argh:

Drape Culture
Feb 9, 2010

But it was all right, everything was all right, the struggle was finished. He had won the victory over himself. He loved Big Brother.

The End.
So overall, not a huge mistake in that it's impossible to get to coding if I dislike it? The recruiters I talked to seemed to think it was relatively easy to switch INTO PM, but not out, and but that may just be the way it's structured.

tk
Dec 10, 2003

Nap Ghost

ManlyWeevil posted:

So overall, not a huge mistake in that it's impossible to get to coding if I dislike it? The recruiters I talked to seemed to think it was relatively easy to switch INTO PM, but not out, and but that may just be the way it's structured.

If you're dead set on wanting to code, it's would probably be best to let your recruiter know. They may be able to help you get a look at an SDE or SDET position.

If the PM role interests you, there's no harm in going through the process. Try to use your interviews to find out what things would be like. You can always turn down an offer if you decide you want to go another way.

It's probably true that it's easier to switch in to PM than out of. Most of the PMs I work with are ex-SDE(T)s that either realize they'll never be tops at their current role or just enjoy the work that the PMs are doing more.

tk fucked around with this message at 17:34 on Mar 4, 2012

oRenj9
Aug 3, 2004

Who loves oRenj soda?!?
College Slice

Safe and Secure! posted:


I'd like to implement a search engine at some point, but I don't really know anything about them right now. I've also been looking for open source projects to which to contribute, but haven't found anything that caught my interest. XFCE seems promising, though, so I'll look at that carefully and see what I can do/am interested in doing development-wise.

You should be looking into Lucene. That way, you kill two birds with one stone. You'll get to work with a search engine and contribute to an OSS project.

Contra Duck
Nov 4, 2004

#1 DAD

ManlyWeevil posted:

So overall, not a huge mistake in that it's impossible to get to coding if I dislike it? The recruiters I talked to seemed to think it was relatively easy to switch INTO PM, but not out, and but that may just be the way it's structured.

They're right, it will be difficult. Seeing a resume where a developer has moved into another role (BA, PM, etc) is a red flag because there's a thought that they may have been pushed into those roles because they're not very good at development. That doesn't mean it's impossible to go back, but it might not be easy.

Master_Odin
Apr 15, 2010

My spear never misses its mark...

ladies
So I'm preparing for an interview "Global Wealth Management Technology" intern program at Bank of America/Merrill Lynch. Is there any tips out of the ordinary that I should be brushing up on, considering I have no financial background whatsoever and most news story talks about financial stuff (BoA is doing terribly! :toot:) or is just misc. stuff about what some analyst say, how does one do research?

For more general intern interview stuff though:
What do I do if they ask a question where I can't come up with an answer. Example question from a site "Give me an example of when you took a risk to achieve a goal. What was the outcome?". I cannot think of an example of "taking a risk" in my school projects as I'd obviously not want to risk a bad grade. What would be a proper answer to this? Something like, due to lack of experience I cannot answer your question sounds like something that would reflect poorly.

What are good questions to ask at the end of an interview? I'd rather not freeze on the spot when they ask. Also, what's the thought on consistency of questions between interviews? I've got three for BoA and should I ask the same questions at each or try for different questions for each?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Contra Duck posted:

They're right, it will be difficult. Seeing a resume where a developer has moved into another role (BA, PM, etc) is a red flag because there's a thought that they may have been pushed into those roles because they're not very good at development. That doesn't mean it's impossible to go back, but it might not be easy.

Or, in other cases, it's because they ended up pushed into the role because they were the most qualified person to take the position, but they hate it. I was in that position; I ended up as, essentially, the CTO of a small company, and I wanted nothing more than to get back to writing code. On the plus side, it gave me a really easy answer to the question "why are you looking to leave your current position?"

I don't mind being a technical lead, but I hate dealing with HR crap.

Master_Odin posted:

What are good questions to ask at the end of an interview? I'd rather not freeze on the spot when they ask. Also, what's the thought on consistency of questions between interviews? I've got three for BoA and should I ask the same questions at each or try for different questions for each?

If the interviewer is a peer:
- Why do you like working here? / What's your favorite thing about working here? If you ask that to multiple people and they all have a hard time answering, or if they all seem beaten down/unenthusiastic about the job, the job might suck. I've had people more or less mouth "GET OUT NOW" at me.
- Technology questions that weren't fully answered in the body of the interview (specific technologies used)
- Joel test questions (if you think they're worth asking!)

If the interviewer is your potential boss:
- What would you have me working on my first month?
- Why should I work here?
- HR questions, if it seems like it went well and they're interested in hiring (vacation, benefits, etc)

New Yorp New Yorp fucked around with this message at 14:46 on Mar 5, 2012

Drape Culture
Feb 9, 2010

But it was all right, everything was all right, the struggle was finished. He had won the victory over himself. He loved Big Brother.

The End.

Ithaqua posted:

Or, in other cases, it's because they ended up pushed into the role because they were the most qualified person to take the position, but they hate it. I was in that position; I ended up as, essentially, the CTO of a small company, and I wanted nothing more than to get back to writing code. On the plus side, it gave me a really easy answer to the question "why are you looking to leave your current position?"

I don't mind being a technical lead, but I hate dealing with HR crap.

It's not so much that I think I'll hate it, otherwise I would have insisted on a SDE(T) interview. It seems very interesting, but it's also not what I expected when I went into CS. Mostly its a "I don't want to burn bridges" thing than I actually expect to dislike it.

The only thing I really can't figure out is what to expect in the interviews. My on-campus was a long discussion of my senior project with the interviewer making up "well, what if..." situations.

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
Hey Goons, I've been having trouble breaking into the field or programming / website programming.

Anyone think you could let me know what I'm missing (besides a degree)?

Here's my portfolio:

quote:

Web Portfolio:
http://www.pluswebhost.com/
Designed everything, programmed all but billing area.

http://www.davisopticalinc.com/
Designed, and currently host this website for local client.

http://www. thetordb.com
This website is a work in progress; here's a relatively completed page:
code:
http://www.thetordb.com/NPC/For'Sen_Lorme
(copy paste, not ready for bots). Programmed website in PHP, programmed full-text database search (AJAX), programmed cookie based login system (AJAX), programmed page edit system Wiki style (AJAX). Programmed comment system (AJAX). jQuery was the only framework used.

http://www.sierramoonartwork.com/
Designed, and currently host this website for a local client.

http://www.pluswebhost.com/calc/calc2.html (not the client's website)
Programmed the AJAX calculator with Google Maps integration to calculate distance between two points. Designed this calculator per client specs.

All of my work has been either contractual or personal.

Software Portfolio:
http://codepad.org/2oWQIQD3
http://codepad.org/BlwTf5f8

Resume:
http://imgur.com/9PCCH

Please note that the C++ code above doesn't have the best programming practices (vars a b c etc), but my C#.NET program has better practices (string thisIsAString, etc.)

I'm having problems even getting an interview (looking both in and outside my current city), so any help would be appreciated!

Knyteguy fucked around with this message at 01:49 on Mar 8, 2017

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Knyteguy posted:

Hey Goons, I've been having trouble breaking into the field or programming / website programming.

Anyone think you could let me know what I'm missing (besides a degree)?

Here's my portfolio:


Please note that the C++ code above doesn't have the best programming practices (vars a b c etc), but my C#.NET program has better practices (string thisIsAString, etc.)

I'm having problems even getting an interview (looking both in and outside my current city), so any help would be appreciated!

What kind of jobs are you applying to?

Edit:
Just at a quick glance, your entire resume needs to be reorganized and restructured. Particularly, "advanced loops", "logical solutions to problems" are kind of bullshit bullet points and some of those programming skills are not programming skills at all, and are just basic skills. Also your 2nd bullet point under your experience, "Protected code and forms... Not a single attack " sounds really weird. What is wrong with just writing, "Protected sites from malicious attacks such as SQL Inject, XSS vulnerabilities..." etc.

Least of all there's no mention of any algorithms classes you took. Any decent software company (aka the one's you actually want to work for) are going to be looking for some general understanding of algorithms and data structures.

Also, writing 2 Project Euler programs in C doesn't really demonstrate that you can do actual work in C. I can probably do those examples in any programming language, but that doesn't really show or represent that I'm proficient in C. I suppose it "proves" that you can program but no one knows if you just copy and pasted that code.

And I think nearly all companies now use some form of version control. What do you use for your sites?

Strong Sauce fucked around with this message at 22:43 on Mar 8, 2012

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Strong Sauce posted:


Also, writing 2 Project Euler programs in C doesn't really demonstrate that you can do actual work in C. I can probably do those examples in any programming language, but that doesn't really show or represent that I'm proficient in C. I suppose it "proves" that you can program but no one knows if you just copy and pasted that code.


I haven't done C since college, but I'd take one look at those and go "Great, he can write unreadable code with useless variable names" and pass.

[edit]
Sorry if that came off as mean! I'm just big on readable code with good, descriptive variable names. I get a kneejerk "gently caress this code" reaction any time I see variables named a, b, and c.

New Yorp New Yorp fucked around with this message at 22:58 on Mar 8, 2012

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

Strong Sauce posted:

What kind of jobs are you applying to?

Pretty much everything under the sun besides simple 'web design' titles when it comes to development. Web programmer, software engineer, software programmer, etc. While I have a decent amount of experience (especially on the web programming side, which I've been doing on a business/personal basis since 1998), I've been completely unable to actually land a job doing any of it.

Strong Sauce posted:

Edit:
Just at a quick glance, your entire resume needs to be reorganized and restructured. Particularly, "advanced loops", "logical solutions to problems" are kind of bullshit bullet points and some of those programming skills are not programming skills at all, and are just basic skills. Also your 2nd bullet point under your experience, "Protected code and forms... Not a single attack " sounds really weird. What is wrong with just writing, "Protected sites from malicious attacks such as SQL Inject, XSS vulnerabilities..." etc.

Thanks I'll make some changes. I was using lots of resume writing tips from around the internet. Resume services are expensive for my wife and I at this point in time.

Least of all there's no mention of any algorithms classes you took. Any decent software company (aka the one's you actually want to work for) are going to be looking for some general understanding of algorithms and data structures.

As far as algorithms go, I'm not extremely knowledgeable on the subject. I've taken some college math classes (and did very well) but that's about the extent of my algorithm knowledge.

Also, writing 2 Project Euler programs in C doesn't really demonstrate that you can do actual work in C. I can probably do those examples in any programming language, but that doesn't really show or represent that I'm proficient in C. I suppose it "proves" that you can program but no one knows if you just copy and pasted that code.

I haven't actually used this in any portfolio or resume I've sent out, so this reaffirms my decision. C# is definitely my most knowledgeable programming language thus far, as I have a 2,000+ line application (I know this doesn't mean a whole lot) written in C# that runs wonderfully.

And I think nearly all companies now use some form of version control. What do you use for your sites?

Unfortunately I have absolutely no knowledge of version control.

Thanks for taking the time to help me out. It looks like I should improve my algorithm knowledge (does anyone have any resources?), start using version control, and clean up my resume. Any other tips?

Knyteguy fucked around with this message at 02:11 on Mar 9, 2012

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

Ithaqua posted:

I haven't done C since college, but I'd take one look at those and go "Great, he can write unreadable code with useless variable names" and pass.

[edit]
Sorry if that came off as mean! I'm just big on readable code with good, descriptive variable names. I get a kneejerk "gently caress this code" reaction any time I see variables named a, b, and c.

I can take mean if it's constructive. Project Euler was pretty much my reintroduction to C++, and I've since moved to much more readable code (thanks to a link here on better programming habits).

Edit: Example of some c# code I've just written up: http://pastebin.com/w0Y0yfu7

Knyteguy fucked around with this message at 23:58 on Mar 8, 2012

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Knyteguy posted:

I can take mean if it's constructive. Project Euler was pretty much my reintroduction to C++, and I've since moved to much more readable code (thanks to a link here on better programming habits).

Edit: Example of some c# code I've just written up: http://pastebin.com/w0Y0yfu7

There are a lot of things wrong in general with your code and what you're actually trying to accomplish if the first line comment is actually what the program is suppose to do.

There are also thing wrong with the code in general that isn't syntactically wrong but would not get you hired at a company where I was the engineer looking at your code.

The biggest thing though is even if your program runs, its not returning the right result. Look at your loops and look at 'primeFactorNumber' and then look at the problem you're trying to solve. Then also look at ways that are causing your program to run way longer than it should.

I have to goto a class and I'll be back in 2.5 hours, maybe someone else will tell you before but until then you should take a hard look at your code and try to figure out why it is wrong.

oRenj9
Aug 3, 2004

Who loves oRenj soda?!?
College Slice
Just a few things:

Try to avoid negating names, this is more difficult to read than the alternative.
code:
  // What you have
  bool notAPrime = false;
  ...
  if(!notAPrime) { ... }

  // More readable
  bool prime = true;
  if(prime) { ... }
You're using
pre:
!notAPrime
in nearly all of your logic statements, which means that you are really just looking for the opposite of not a prime, which is a prime.

Think long and hard about the logic in this statement. The last part of the statement is completely useless. i is initialized to 2 and is never decremented.

code:
if (i % numberToWorkWith == 0 && i != numberToWorkWith && i != 0)
Regarding your resume:

What do you mean by "next-generation" database solutions?
WTF is an "advanced loop"?

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Knyteguy posted:

I can take mean if it's constructive. Project Euler was pretty much my reintroduction to C++, and I've since moved to much more readable code (thanks to a link here on better programming habits).

Edit: Example of some c# code I've just written up: http://pastebin.com/w0Y0yfu7

here is a version of what you did that is less stab-inducing
code:
long factor = 600851475143;
bool isPrime = false;

while (isPrime == false)
{
   isPrime = true;
   for (long i = 2; i <= Math.Sqrt(factor); i++)
   {
         if (factor % i == 0)
         {
              factor /= i;
              isPrime = false;
              break;
         }                            
   }
}
Console.WriteLine("Finished.  Greatest prime factor is {0}", factor);
Console.ReadLine();

Bruegels Fuckbooks fucked around with this message at 05:31 on Mar 9, 2012

Contra Duck
Nov 4, 2004

#1 DAD
You can assume the people reading your code are other developers who know the syntax and standard idioms of the language. Comments like these:
code:
                    // Loop
                    while (numberToWorkWith < 10000 && !notAPrime)
code:
            // Declare Vars
            long primeFactorNumber = 600851475143;
            int finalNumber = 0;
Are completely unnecessary and only serve to clutter up the code and make it more difficult to read.

Nippashish
Nov 2, 2005

Let me see you dance!

Knyteguy posted:

Edit: Example of some c# code I've just written up: http://pastebin.com/w0Y0yfu7

I'm really loving // numberToWorkWith should equal 2 to save cycles. If you're going to loop up to 100000 the most important optimization is definitely starting at 2 so you only loop 99999 times to save cycles.

So this post isn't completely useless: your comments are not very clear, for instance these comments
code:
// Use variable i for calculations until reasonable estimated number, i should equal 2 to save cycles
// Set instanced vars that I can work with
// numberToWorkWith should equal 2 to save cycles
don't actually explain anything. Use i for what calculations? What work are you going to do with these vars? What is numberToWorkWith used for?

The most useful comment in your code is this one:
code:
// Once finished, ensure program doesn't exit
Console.ReadLine();

etcetera08
Sep 11, 2008

Knyteguy posted:

Thanks for taking the time to help me out. It looks like I should improve my algorithm knowledge (does anyone have any resources?), start using version control, and clean up my resume. Any other tips?

http://forums.somethingawful.com/showthread.php?threadid=3471257

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
Since we're on the topic of thinking you make useful comments when you don't, I've always thought that my comments were sufficient to make my code readable. Confirm/deny? A method from my last homework assignment:

http://pastebin.com/17SrhJbe

As for general programming style, I've been thinking that blank lines between sections of code separated by comments only made my code more spread out and difficult to read, so I've mostly started to eliminate those. I still keep my variable declarations separated from the rest of the code, though. Until recently I was skipping lines before all those places you see comments in the main section.

I've also taken to assigning my variables as late as possible because I've noticed that initializing them unnecessarily upon declaration can sometimes result in hard-to-find bugs, and the only downside to late initialization seems to be that the code is more difficult read, but I think poor comments are the real culprit there. Thoughts?

Safe and Secure! fucked around with this message at 06:13 on Mar 9, 2012

baquerd
Jul 2, 2007

by FactsAreUseless

Safe and Secure! posted:

Since we're on the topic of thinking your make useful comments when you don't, I've always thought that my comments were sufficient to make my code readable. Confirm? A method from my last homework assignment:

http://pastebin.com/17SrhJbe

As for general programming style, I've been thinking that blank lines between sections of code separated by comments only made my code more spread out and difficult to read, so I've mostly started to eliminate those. I still keep my variable declarations separated from the rest of the code, though.

I've also taken to assigning my variables as late as possible because I've noticed that initializing them unnecessarily upon declaration can sometimes result in hard-to-find bugs, and the only downside to late initialization seems to be that the code is more difficult read, but I think poor comments are the real culprit there. Thoughts?

Your code still suffers from too many pointless comments. The best advice I've heard with comments is that they should describe greater purpose, not implementation details unless you are doing something "clever". Why does your code exist, what is the point of combining a bucket with its buddy. The code and variable names should speak for themselves for how you're doing what you're doing in most cases.

Initialization done before a variable is needed is not a great idea, except possibly in the case of class variables. It definitely does not make code harder to read.

Ensign Expendable
Nov 11, 2008

Lager beer is proof that god loves us
Pillbug
You have a lot of comments. Their content seems fine to me, but you shouldn't have quite so many on fairly simple code.

The declaration of variables and then their initialization looks weird to me. I guess it doesn't look that way to seasoned C programmers, but it just seems more lines of code for no benefit.

Also, you're using "this" everywhere.

Ensign Expendable fucked around with this message at 06:26 on Mar 9, 2012

Nippashish
Nov 2, 2005

Let me see you dance!

Safe and Secure! posted:

Since we're on the topic of thinking you make useful comments when you don't, I've always thought that my comments were sufficient to make my code readable. Confirm/deny?

Making good comments is hard. It's especially hard with homework assignments because you only look at the code for at most a couple weeks and then you never need to see it again. I only really started to understand the difference between a good comment and a bad comment when I started writing code that I had to come back to and edit a few months later.

Reading your own code when you don't remember what it does, and seeing a bunch of comments you wrote that don't shed any light on the issue is really frustrating.

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
I started out writing down a short list of steps to take to solve the problem (combining a bucket with its buddy). I then left each one in as a comment, because I figured that if it represents a separate "step" in my thinking, then it was probably worth explaining. So

quote:

check to see if we can combine
if so, first get the buddy
decrease depth of both buckets
store each buckets keys for later reinsertion
erase both buckets
save each bucket so that insertion can take place
reinsert the keys

in my notebook became what you see there. Is there a better "system" to follow or is it more of an experience/feedback thing? I haven't worked on much code with other people, so I don't really know how others are going to look it.

Also, I use "this" to make it obvious that I'm using a variable that belongs to the object, so that variables without "this" can be assumed to be local.

I know that prefacing instance variable names with m, or m_ would work, but I disliked how those required me to hold the shift key right afterward to capitalize the first letter of the rest of the variable name, or to type the underscore. Typing out "this." is just more comfortable to me than hitting shift.

baquerd
Jul 2, 2007

by FactsAreUseless

Safe and Secure! posted:

http://pastebin.com/17SrhJbe

Here I made a new pastebin:

http://pastebin.com/WBK6EYu4

Safe and Secure! posted:

I started out writing down a short list of steps to take to solve the problem (combining a bucket with its buddy). I then left each one in as a comment, because I figured that if it represents a separate "step" in my thinking, then it was probably worth explaining. So in my notebook became what you see there. Is there a better "system" to follow or is it more of an experience/feedback thing? I haven't worked on much code with other people, so I don't really know how others are going to look it.

I know that prefacing instance variable names with m, or m_ would work, but I disliked how those required me to hold the shift key right afterward to capitalize the first letter of the rest of the variable name, or to type the underscore. Typing out "this." is just more comfortable to me than hitting shift.

Experienced programmers don't care about your thought process on a low level, we care more about the higher level thoughts. With good variable name selection and occasional comments the code becomes easier to read than explaining every step of the way.

Don't use hungarian notation, use an IDE with syntax highlighting. Neither hungarian notation or excessive use of "this" is truly terrible though, more of a style choice.

baquerd fucked around with this message at 06:38 on Mar 9, 2012

Ensign Expendable
Nov 11, 2008

Lager beer is proof that god loves us
Pillbug
Yeah, prefacing variables with their type looks much weirder to me than using "this".

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
I see, so while I should stop putting comments before each chunk of low-level logic, separating them visually with a new line is also going to make it easier to read? As for the this/Hungarian/neither topic, I use Eclipse for Java and I didn't know it was an option to highlight instance variables differently from local variables.

Also, I had it return if the bucket couldn't be combined instead of throw an exception because the method calling it only wants it to combine if possible and do nothing otherwise:

code:
//now combine with buddy and collapse index as necessary
while(tryToCollapse){
	this.combine();
	this.loadData(this.index.getFilePointer());
	tryToCollapse = this.index.collapse();
}
I figured it would be better to check if we could combine before calling combine, but our assignment asked for a combine() method that did the checking internally.

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

oRenj9 posted:

Just a few things:

Try to avoid negating names, this is more difficult to read than the alternative.

You're using
pre:
!notAPrime
in nearly all of your logic statements, which means that you are really just looking for the opposite of not a prime, which is a prime.

Think long and hard about the logic in this statement. The last part of the statement is completely useless. i is initialized to 2 and is never decremented.

Regarding your resume:

What do you mean by "next-generation" database solutions?
WTF is an "advanced loop"?

Interesting about the notAPrime vs prime. I will try not to use negated variable names in the future. The i != 0 part was from an earlier iteration of the code (which is why I really made i=2 instead of 0), I actually meant to take that out but kept forgetting.

Re: resume - I suppose I was just trying a bit too hard there. The resume is actually about a month old so I will be going over it and correcting it per everyone's comments. Hopefully it will be enough to land me a (probably entry-level) job so I can use a resume writing service next time ;).

E: I'm not sure why i would be decremented though. It's used as a number to factor the long number. Decrementing anywhere would just lead to repetitiveness. Please correct me if I'm wrong though.

Nippashish posted:

I'm really loving // numberToWorkWith should equal 2 to save cycles. If you're going to loop up to 100000 the most important optimization is definitely starting at 2 so you only loop 99999 times to save cycles.

So this post isn't completely useless: your comments are not very clear, for instance these comments

don't actually explain anything. Use i for what calculations? What work are you going to do with these vars? What is numberToWorkWith used for?

The most useful comment in your code is this one:

Thank you :). This is actually the first input I've gotten on some of my code, and it's extremely helpful. For me it's kind of like how often we miss errors while proof reading our own work that others catch.

Contra Duck posted:

You can assume the people reading your code are other developers who know the syntax and standard idioms of the language. Comments like these:

Are completely unnecessary and only serve to clutter up the code and make it more difficult to read.

Thanks I'll remember this. I thought it was standard programming practice to add stuff like this :v:.



Thank you for this. I will be signing up.

Once again I appreciate the help. You guys are awesome. I'm very eager to make a career out of this, and stuff like this will greatly help.

Knyteguy fucked around with this message at 07:11 on Mar 9, 2012

baquerd
Jul 2, 2007

by FactsAreUseless

Safe and Secure! posted:

I see, so while I should stop putting comments before each chunk of low-level logic, separating them visually with a new line is also going to make it easier to read? As for the this/Hungarian/neither topic, I use Eclipse for Java and I didn't know it was an option to highlight instance variables differently from local variables.

Yes, that's the right idea. As you become more and more familiar with code, you will be able to read it practically like English if it's written well.

Variable name selection is huge! For example, if we call the new key array "combinedKeys" in a method commented to combine buckets, it's instantly obvious what the purpose is.

Some good commenting categories would be those that allow you to skip over blocks because they're doing something trivial (resetting bucket contents), explain complicated low-level logic (not present here), or explain higher-level purpose (method level comments).

I haven't used Eclipse in forever, but I would be incredibly surprised if you couldn't highlight instance variables differently.

Use new lines when they separate low level groups of logic or where it simply looks better. Experience will be a good guide, and there's no hard rules.

As an aside, you should check to see if the combined bucket keys would overflow the new bucket's maximum keys. Also and in the same vein, unless you have a good reason to use a fixed int array, use an ArrayList<Integer>.

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
I think I've got the rest, but why would you use ArrayList<Integer> here instead of a fixed array? Also, the canCombine() method checks, along with something else, whether the two bucket's combined keys will overflow the bucket into which they are combined. Should I have explained that in the comment before the check?

Thank you all for taking the time to explain, by the way.

Also,

oRenj9 posted:

You should be looking into Lucene. That way, you kill two birds with one stone. You'll get to work with a search engine and contribute to an OSS project.

I have looked into Lucene but it seems way more complicated than anything I've worked with before and I wasn't sure how to begin to approach it. I guess going through the documentation and maybe writing a couple of programs that actually use it might be a good start? Thanks for the suggestion!

Safe and Secure! fucked around with this message at 07:16 on Mar 9, 2012

dancavallaro
Sep 10, 2006
My title sucks

Knyteguy posted:

http://www. thetordb.com
This website is a work in progress; here's a relatively completed page:
code:

http://www.thetordb.com/NPC/For'Sen_Lorme

(copy paste, not ready for bots). Programmed website in PHP, programmed full-text database search (AJAX), programmed cookie based login system (AJAX), programmed page edit system Wiki style (AJAX). Programmed comment system (AJAX). jQuery was the only framework used.

This, combined with the fact that you've never used version control, tells me that you need to spend some time learning about the various tools and technologies out there. I'm not saying you have to hop on every bandwagon that comes along and learn the hottest new Ruby framework and NoSQL flavor of the day, but it really looks like you need to get out of your PHP/MySQL cave and learn what else is out there.

Want to develop a website in PHP? Check out CodeIgniter or Symfony. Full-text search? Check out Lucene. Cookie-based login system? Yeah, just use your framework for that.

Seriously, getting stuff like that right is hard, and there's no reason not to use existing solutions that have already been tested. I registered a few accounts all with the same password, and they all had the same PWTHETORDB value in the cookie. At 40 bytes it's probably SHA-1, but it looks like you're probably salting the passwords with a common salt. But that doesn't really matter, because I can keep trying account names by changing THETORDB in the cookie until I run across one that uses the same password as my original account, and now I'm logged in as them.

pigdog
Apr 23, 2004

by Smythe

Safe and Secure! posted:

I think I've got the rest, but why would you use ArrayList<Integer> here instead of a fixed array? Also, the canCombine() method checks, along with something else, whether the two bucket's combined keys will overflow the bucket into which they are combined. Should I have explained that in the comment before the check?
I'm presuming it's part of the specifications for your assignment to use fixed arrays in order to get familiar with them, but yeah, unless there are actual reasons why you'd really need a fixed array, you'd use Lists (ArrayLists) of items and not worry about overflows and all that boring crap. :)

The canCombine() method actually looks good to me. We needn't know what it actually does, we can make pretty clear assumption from its nice and obvious name.

I'd like to second what baquerd already said in that giving clear, descriptive, appopriate names to variables and methods is super, mega, ultra important and something that clearly separates good code from the bad. In fact choosing better names is one of the top three main processes in writing good code, beside removing duplication and keeping your tests passing.

You wouldn't need all those comments (which in your original sample register mostly as line noise, tbh) if it was clear from the names of the variables and methods as for what they were for. Don't be afraid to give long and descriptive names to your variables. Don't think terseness would make your code look cool and professional, the effect is actually the opposite. (Using i, j, ... for loop iterators is good convention though). Good code is usually readable and understandable without comments. You might also be surprised how much easier you'd find bugs in your code if stuff was named better.

If you can't think of a good name for a variable, use an extremely descriptive one, such as theThingThatCountsTheNumberOfKeysInBucket, until you can think of a better one that conveys the intent better. You can always safely rename the names of variables and methods when you can think of a better one. I don't know what the keystroke for the safe rename in Eclipse is because I don't use it, but I'm sure it's one of the first options in the Refactor menu, and it's one of the commands in an IDE you would be using the most. :) For how names in code ought to improve, see this picture.

Don't be afraid to group related functionality into separate, well named methods, either. Instead of

code:
public void makeBreakfast() {
// this part here breaks an egg
....
...
....
.....

// this part here cuts the bacon
...
....
....
...
}
you could do something like
code:
public void makeBreakfast() {
...
scrambledEggs = breakAnEgg(egg);
strips = cutBacon(bacon);
...
}

private ScrambledEgg breakAnEgg(Egg egg) {
....
}

private BaconStrips cutBacon(Bacon bacon) {
....
}

and as long as the code actually does what the names say, it's both clearer, potentially better reusable, and there's no need for comments. Modern IDEs make it easy to extract methods and otherwise move code around, too.

pigdog fucked around with this message at 10:11 on Mar 9, 2012

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

pigdog posted:


Don't be afraid to group related functionality into separate, well named methods, either.

God, yes. If I see a method longer than 15-20 lines of code, I start looking for where it's doing too much.

The advantage of having smaller methods is that they're easier to unit test and debug, in addition to just plain being easier to isolate visually and read. If I'm in the middle of a 300 line method, looking for one specific issue that I know is with a piece of logic, it's way easier if the 280 lines of irrelevant code are off somewhere else and I can focus on the 20 problematic lines.

As for variable names, we live in an amazing world of intellisense / code completion. I'd much rather see "bool canExecuteDeletionCommand = true;" than "bool del = true;". With code completion, it probably works out to the same number of keystrokes anyway :)

New Yorp New Yorp fucked around with this message at 14:44 on Mar 9, 2012

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

dancavallaro posted:

This, combined with the fact that you've never used version control, tells me that you need to spend some time learning about the various tools and technologies out there. I'm not saying you have to hop on every bandwagon that comes along and learn the hottest new Ruby framework and NoSQL flavor of the day, but it really looks like you need to get out of your PHP/MySQL cave and learn what else is out there.

Want to develop a website in PHP? Check out CodeIgniter or Symfony. Full-text search? Check out Lucene. Cookie-based login system? Yeah, just use your framework for that.

Seriously, getting stuff like that right is hard, and there's no reason not to use existing solutions that have already been tested. I registered a few accounts all with the same password, and they all had the same PWTHETORDB value in the cookie. At 40 bytes it's probably SHA-1, but it looks like you're probably salting the passwords with a common salt. But that doesn't really matter, because I can keep trying account names by changing THETORDB in the cookie until I run across one that uses the same password as my original account, and now I'm logged in as them.

Interesting, I had thought I covered most of the cookie security but hadn't even thought of a vulnerability like that...
code:
$sti = 'SALT';
$salt = md5($sti);
$password = mysql_real_escape_string(stripslashes($_POST['password']));
$password_array = str_split($password, 2);
$hash = sha1($password_array[0] . $salt . $password_array[1]);
$username = mysql_real_escape_string(stripslashes($_POST['username']));
$email = mysql_real_escape_string(stripslashes($_POST['email']));
The website will never go live (I've only opened it to use on my portfolio) so I suppose my methodology doesn't matter. I had only really thought of making sure it would make a rainbow table attack difficult.

I've heard of many of the things you've mentioned above (CodeIgniter, etc) but never really looked into them. I was thinking there would be more prestige in coding completely from scratch. Suppose I learn the tools above and create a useful new website using CodeIgniter and Lucene, would this help my career outlook at all? Are these tools an IDE like Visual Studio? Or is it more like Wordpress? Thanks for the help :) .

Knyteguy fucked around with this message at 20:27 on Mar 9, 2012

Ensign Expendable
Nov 11, 2008

Lager beer is proof that god loves us
Pillbug
Everyone uses libraries. While writing something from scratch shows you know how it works, you should first demonstrate that you can read documentation and use other people's code.

dancavallaro
Sep 10, 2006
My title sucks

Knyteguy posted:

Interesting, I had thought I covered most of the cookie security but hadn't even thought of a vulnerability like that...
code:
$sti = 'SALT';
$salt = md5($sti);
$password = mysql_real_escape_string(stripslashes($_POST['password']));
$password_array = str_split($password, 2);
$hash = sha1($password_array[0] . $salt . $password_array[1]);
$username = mysql_real_escape_string(stripslashes($_POST['username']));
$email = mysql_real_escape_string(stripslashes($_POST['email']));
The website will never go live (I've only opened it to use on my portfolio) so I suppose my methodology doesn't matter. I had only really thought of making sure it would make a rainbow table attack difficult.

I've heard of many of the things you've mentioned above (CodeIgniter, etc) but never really looked into them. I was thinking there would be more prestige in coding completely from scratch. Suppose I learn the tools above and create a useful new website using CodeIgniter and Lucene, would this help my career outlook at all? Are these tools an IDE like Visual Studio? Or is it more like Wordpress? Thanks for the help :) .

That's even worse than I thought; that means that I only need to find a username where the password matches just the first 4 characters(!!!!!) of mine in order to log in as them. Seriously, you should use a framework for stuff like this, there is no glory in reinventing cookie-based auth yourself, even if you get it right, which you won't.

I'll give you some more comments in a bit.

aBagorn
Aug 26, 2004

Ithaqua posted:

God, yes. If I see a method longer than 15-20 lines of code, I start looking for where it's doing too much.

I'm running into this problem in one of my applications, where there's a 30 line method, but 17 of the lines are controlling visual elements on the page, and there's a lot of "peekaboo" involved between methods.

I should probably be combining the visual elements of the webform into their own method(s), yes? (or rewrite the whole thing as an MVC, but that's for the .NET thread)

I want to get rid of stuff like this, right

code:
protected void SomeMethod()
{
    element2.Visible = false;
    element3.Visible = false;
    var foo = new LogicClass();
    var bar = logic.FunWithData(element5.Text)
    if (!bar.Any())
    {
        element8.Visible = true;
    }
    else
    {
        element4.Visible = true;
        element4.DataSource = bar;
        element6.Visible = true;
        element7.Visible = true;
    }
}

aBagorn fucked around with this message at 21:18 on Mar 9, 2012

pigdog
Apr 23, 2004

by Smythe

aBagorn posted:

I want to get rid of stuff like this, right

The answer is probably "yes".

MVC aside, can you think of a better name for SomeMethod() that would summarize what it is that running it would accomplish?

If it would be something like CloseThisOneWindowAndHaveFunWithDataAndThenDisplaySomethingElse(), then that's one easy way to tell if and how you should break it down. A method should usually do one thing. It may be a complex thing, it create many objects and call many other methods, but intuitively, it should do what the name implies it would do.

Adbot
ADBOT LOVES YOU

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

dancavallaro posted:

That's even worse than I thought; that means that I only need to find a username where the password matches just the first 4 characters(!!!!!) of mine in order to log in as them. Seriously, you should use a framework for stuff like this, there is no glory in reinventing cookie-based auth yourself, even if you get it right, which you won't.

I'll give you some more comments in a bit.

Hm so why is this so? Is there a name for this attack so I could do some research? I really like this kind of stuff. Thanks again.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply