hateradio
Member
(05-16-2012, 03:27 AM)

hateradio's Avatar
#751

Originally Posted by njr: View Post
"Organic" PHP, or PHP with all the frameworks and such? It's not bad at all, the problem with is that anyone can write it (I don't think there's anything bad with that though). If you look up frameworks such as Zend, CakePHP, or Symfony, it's much more cleaner than using PHP by itself. It's still object oriented and can perform just as well as any other dynamic language.

Put in short however, if you apply solid OOP practices (ex: SOLID principles), I think any OOP language can feel much better to use.
That's one of the best parts of PHP, that it's easy to learn.

However, it's a pain in the ass if you don't work with objects. I recently found my new love: Doctrine ORM. <3

I don't think I can live without it.

Originally Posted by usea: View Post
My coworker is opposed to the Single Responsibility Principle. Of course, he doesn't know it's called that because he doesn't understand OOP at all, even though we're working in C#. (he doesn't know what an interface is or what static means, just as an example).

. . .

I am just tired of it. He has 10 years of experience, which he loves to remind me of, and yet he still doesn't understand anything. He refuses to learn, because he thinks anything that he doesn't already understand is stupid. He has a really bad attitude (the definition of toxic employee fits him perfectly).

Sorry, had to rant. I feel better now.
Maybe this will make you feel better.




He sounds like a complete ignoramus.
Last edited by hateradio; 05-16-2012 at 03:30 AM.
Randolph Freelander
Member
(05-17-2012, 11:37 PM)

Randolph Freelander's Avatar
#752

Heh

Heh heh.

HAHAHAHAHAHAHAHAHA

I'm laughing so as not to cry.

Code review today. Dude shows his code.

Why is this line of code here?
-I don't know.
But you wrote it, right?
-Yes.
So what does it do?
-I'm not sure.
And you wrote it.
-Yes.
So where did it come from?
-I think I might have copied it.
So what does it do?
-I don't know.

:(

This dude is nice as can be. Good guy. Can't code. I can't trust him to write code. I can't trust him to read code. I can't trust him to have anything at all to do with code because he simply does not get code. He has probably programmed for ten years, but he is absolutely, 100% clueless. Cargo Cult to the extreme, and I think Cargo Cult programmers are better. They at least have a method to their madness. Maybe. This guy? Copy a little bit of this, a little bit of that, copy a whole bunch of what he doesn't need at all, copy, copy, copy, paste, done. So what does it do? "I don't know."
Zoe
(05-18-2012, 12:06 AM)

Zoe's Avatar
#753

Is there a description somewhere of how a typical code review is conducted? I've never had one :(
Randolph Freelander
Member
(05-18-2012, 12:29 AM)

Randolph Freelander's Avatar
#754

Originally Posted by Zoe: View Post
Is there a description somewhere of how a typical code review is conducted? I've never had one :(
I'm sure it is "typically" conducted in as many different ways as can be.

The first thing you probably want to have is a set of coding standards the team must abide by. Non-negotiable. (Except when you have to negotiate*.) If people violate those rules, you must kill them.

Then you simply want to delegate time as often as appropriate to go over the code. Our team devotes about 4 hours per week, and that is arguably not nearly enough. We are a distributed team, so we get together on a conference call, share our screens, and simply present our code. If your code is under review, you present it, driving the presentation to a large extent, although the questions can also drive it.

"Tell me about why you did this."
"Show me the unit tests."
"What do you mean there's no unit tests? I thought you said this was done."

That type of stuff. You show your code. People ask questions. People offer criticism and ways to improve the code. Suggested refactorings. We have also identified bugs in the code. (Proving the ineffectiveness of their testing efforts.) Whatever is identified in the review as needing improvement should be fixed and re-reviewed preferably as soon as possible, lest people forget and the code rots.

It certainly helps if you have people that are passionate about the profession and continual improvement.

------

*An example of a non-negotiable negotiable rule. We have a hard limit on lines of code inside a method. A smallish number. One that you must not go over, and you would preferrably not even come near. The caveat being that sometimes, you simply cannot avoid it. For example, say you have a method whose only responsibility is to new up an object and initialize some properties. Let's say your coding standard is X LOC in a method. The class has X + 1 properties. Obviously, to initialize this thing, you have to technically violate the standard. This is obviously allowed. However, the idea is centered around not having the method responsible for too much. So while the absolute letter of the law is violated, the spirit of the law is maintained as long as that method does not do anything else. The LOC limit is really just about setting a cap that immediately calls to attention when a method might be doing too much. Like I said, our standard is a smallish number (20). I try not to come anywhere close to that. "Uncle Bob's: head would spin at such a number, after all. 20!? More like 3!
Last edited by Randolph Freelander; 05-18-2012 at 05:54 AM.
usea
Member
(05-18-2012, 12:47 AM)

usea's Avatar
#755

Originally Posted by Randolph Freelander: View Post
This dude is nice as can be. Good guy. Can't code. I can't trust him to write code. I can't trust him to read code. I can't trust him to have anything at all to do with code because he simply does not get code. He has probably programmed for ten years, but he is absolutely, 100% clueless. Cargo Cult to the extreme, and I think Cargo Cult programmers are better. They at least have a method to their madness. Maybe. This guy? Copy a little bit of this, a little bit of that, copy a whole bunch of what he doesn't need at all, copy, copy, copy, paste, done. So what does it do? "I don't know."
:( I feel bad. For both of you. At least he admits that he doesn't know.

My coworker believes he knows what everything he's copying/pasting does. He copies and pastes code that isn't applicable to the situation, and then when it doesn't work right he starts blaming 1) the person who wrote the code he copied. and 2) our entire development team (except himself) for having a terrible development process that leads to him getting confused.

He has called more than one meeting trying to "fix" our process so that we do things "the same way, everywhere" so that he can copy and paste code and it will work right. We spend hours on this. It drives me insane.

Not trying to one-up your story. I just need to type it out somewhere before it eats me up. I am getting an ulcer or something..
Last edited by usea; 05-18-2012 at 12:49 AM.
Randolph Freelander
Member
(05-18-2012, 12:52 AM)

Randolph Freelander's Avatar
#756

Originally Posted by usea: View Post
:( I feel bad. For both of you. At least he admits that he doesn't know.

My coworker believes he knows what everything he's copying/pasting does. He copies and pastes code that isn't applicable to the situation, and then when it doesn't work right he starts blaming 1) the person who wrote the code he copied. and 2) our entire development team (except himself) for having a terrible development process that leads to him getting confused.

He has called more than one meeting trying to "fix" our process so that we do things "the same way, everywhere" so that he can copy and paste code and it will work right.

Not trying to one-up your story. I just need to type it out somewhere before it eats me up. I am getting an ulcer or something..
I feel you, man. I feel like a quote of my avatar is in order, when Hartman's character told Dave "why can't you be a man for once and take responsibility for my actions?"

We used to have a belligerent dude who thought his code was above reproach and would simply discard any critique. His standard for his code working was "it compiled." (If you ran the application, pulled up that screen, and it exploded, well, that was your problem.) When his code didn't meet the business need, he blamed the specification. So we would look at the requirement, see that it laid out exactly what the line of business wanted, saw that his code did nothing of the sort, and then he would blame a different specification. One he wrote. But it was still the LOB's fault. Right.
Randolph Freelander
Member
(05-18-2012, 01:03 AM)

Randolph Freelander's Avatar
#757

Speaking of ten years, it continually fascinates me just how many developers there are out there that absolutely cannot code. I've read all the blogs, the "199 out of 200 applicants cannot write code," all of that. Didn't believe it.

Then I started being involved in interviews. :/

I work in C#, .NET. There has been a lot of evolution in .NET over the past 10 years. Nearly every person I have interviewed has supposedly been involved in C# development for the better part of those 10 years. And nearly every person's skillsets are still mired in what wasn't even acceptable 10 years ago, let alone now. No OOP. No abstractions. Polymorphi-what? Collection of choice is still the ArrayList.

We talked to a guy. 20 years on his resume, with a lot of the recent years centered around C#, VB, and Java. He had on his resume that he taught a Java course at a community college. So I decide to, even though we're interviewing for C#, toss him a softball Java/C# compare/contrast question just to break the ice a bit. He cut me off. "I don't know Java." Thank you, drive through.

We talked to another guy. We typically slip them some code for them to talk about. The code will generally have some issues to improve. Maybe it needs some refactoring, maybe it needs a different abstraction, maybe there is even a COMPLETELY OBVIOUS bug. Small, small snippets of code. We just want them to talk about it and hopefully sound intelligent as they do so. We allow for nervousness. 9 out of 10 can't do that much. But this one guy literally snapped. "I don't want to do this. Maybe if I could take this home, I could do it, but I'm not doing it here." It is disheartening.

I keep thinking there is good code out there. After these interviews over the past few months, I am coming to grips that the cargo cultists have won.
Last edited by Randolph Freelander; 05-18-2012 at 05:53 AM.
usea
Member
(05-18-2012, 01:18 AM)

usea's Avatar
#758

Funny that you say that. The guy I mentioned above has stated that he would never analyze or produce code during an interview. He feels any shop who does that is just trying to get free consulting.

Which I am certain does happen. But come on, a single method? Really? Maybe if they asked you to write some fully functioning scheduling system or something.
Randolph Freelander
Member
(05-18-2012, 01:34 AM)

Randolph Freelander's Avatar
#759

"We are getting eaten alive by the competition. We really need to solve this FizzBuzz problem. Been trying for weeks. What if we were to... Bob, get this. Let's conduct interviews. Have those folks write this code, and then all we have to say is that we went with 'somebody else' for the hire. What do you think?"

"Jim, that's.... brilliant."
robox
Member
(05-18-2012, 04:34 AM)

robox's Avatar
#760

Originally Posted by Randolph Freelander: View Post
..Like I said, our standard is a smallish number (20). I try not to come anywhere close to that. "Uncle Bob's: head would spin at such a number, after all. 20!? More like 3!
hey dude, i really like reading your stories. and you keeping the thread alive.
it really makes me glad i don't have to deal with this kinda thing, as everyone around me have been fairly competent, including myself.

but wait... what? 20 lines max for a function???
that is such a tiny number that i cannot fathom. much of my stuff often exceed 20 lines. some of the biggest are a few hundreds, broken down into steps within, and where none of the steps really make sense to be exposed for others to use.


do you have a boss tech guy? someone that oversees all development and maintains order? someone who knows what good practices are and has the power to be intolerant of the bad. i think a fresh grad who's been through proper engineering training would be better, because then they'd have a good base of knowledge, and can be molded than the veterans who refuse to adapt. (that is, until the noobs become such stodgies)
Randolph Freelander
Member
(05-18-2012, 05:46 AM)

Randolph Freelander's Avatar
#761

Originally Posted by robox: View Post
hey dude, i really like reading your stories. and you keeping the thread alive.
it really makes me glad i don't have to deal with this kinda thing, as everyone around me have been fairly competent, including myself.

but wait... what? 20 lines max for a function???
that is such a tiny number that i cannot fathom. much of my stuff often exceed 20 lines. some of the biggest are a few hundreds, broken down into steps within, and where none of the steps really make sense to be exposed for others to use.


do you have a boss tech guy? someone that oversees all development and maintains order? someone who knows what good practices are and has the power to be intolerant of the bad. i think a fresh grad who's been through proper engineering training would be better, because then they'd have a good base of knowledge, and can be molded than the veterans who refuse to adapt. (that is, until the noobs become such stodgies)
20 is too many, to be honest. Way too many. The idea is that the code expresses itself via classes and methods. They tell you a story. When you have a long method, you really have a bunch of small methods you haven't identified, but you should. You might even have some objects dying to get out. As an example, say you have something like

(actual code I wrote years ago)

Code:
    private void SendCommentViaEmail()
    {
        string fromAddress = "info@whatever.com";
        var regex = new Regex(@"someEmailRegexPattern");
        if (regex.IsMatch(tbEmail.Text))
        {
            fromAddress = tbEmail.Text;
        }

        var client = new SmtpClient("someemailhost.net");
        var message = new MailMessage();
        message.To.Add(new MailAddress("foo@bar.com"));
        message.From = new MailAddress(fromAddress);
        message.Subject = "Comment posted on your website";
        message.Body = tbMain.Text;
        message.IsBodyHtml = false;
        client.Send(message);

        MailMessage messageToPhone = new MailMessage();
        messageToPhone.To.Add(new MailAddress("aphonenumber@phoneservice.com"));
        messageToPhone.From = new MailAddress(fromAddress);

        string body = "";

        if (tbMain.Text.Trim().Length <= 80)
        {
            body = "From: " + tbName.Text + " (" + tbEmail.Text + ")";
            body += " -- " + tbMain.Text.Trim();
        }
        else
        {
            body = "Comment posted on yourwebsite.com by " + tbName.Text + ", "
                + tbEmail.Text + " (too long)";
        }

        messageToPhone.Body = body;
        client.Send(messageToPhone);
    }
If I were to refactor that today, well, it wouldn't be happening right there in the codebehind of the web page. But forgetting that for a moment, and doing little more than using the simple "extract method" functionality available in Visual Studio, the first pass might look something like

Code:
    private void SendCommentViaEmail()
    {
        string fromAddress = GetSender();

        var client = new SmtpClient("someemailhost.net");
        var message = ComposeMessage(fromAddress, tbMain.Text);
        client.Send(message);        

        string messageBody = GetMessageBodyForPhone(tbName.Text, tbEmail.Text, tbMain.Text);
        MailMessage messageToPhone = ComposeMessageForPhone(fromAddress, messageBody);
        client.Send(messageToPhone);
    }

    private string GetSender()
    {
        string fromAddress = "info@whatever.com";
        var regex = new Regex(@"someEmailRegexPattern");
        if (regex.IsMatch(tbEmail.Text))
        {
            fromAddress = tbEmail.Text;
        }
        return fromAddress;
    }

    private MailMessage ComposeMessage(string fromAddress, string emailBody)
    {
        var message = new MailMessage();
        message.To.Add(new MailAddress("foo@bar.com"));
        message.From = new MailAddress(fromAddress);
        message.Subject = "Comment posted on your website";
        message.Body = emailBody;
        message.IsBodyHtml = false;
        return message;
    }


    private string GetMessageBodyForPhone(string name, string emailAddress, string messageBody)
    {
        if (messageBody.Trim().Length <= 80)
        {
            return "From: " + name + " (" + emailAddress + ") -- " + messageBody.Trim();
        }
        else
        {
            return "Comment posted on yourwebsite.com by " + name + ", " + emailAddress + " (too long)";
        }
    }

    private MailMessage ComposeMessageForPhone(string fromAddress, string messageBody)
    {
        MailMessage messageToPhone = new MailMessage();
        messageToPhone.To.Add(new MailAddress("aphonenumber@phoneservice.com"));
        messageToPhone.From = new MailAddress(fromAddress);
        messageToPhone.Body = messageBody;
        return messageToPhone;
    }
But it would be further refactored from there, because I still think there are too many ideas being expressed in the first method, and there are some objects that might need to be identified (beyond just moving this out of the codebehind). The general idea, however, is that each method should be responsible for one thing, and it should do that one thing well. As it turns out, things are small. As you see, not many things take 20 lines of code to express. And then, as I said earlier, the code should tell you a story. When you read that first method, and you see those subsequent method calls, you should feel like you know what those methods are doing without even looking at them. On that last point, I'm paraphrasing someone quoted in the book "Clean Code," and I'm not sure who it was, but I believe it.

So like I said, after my first refactoring pass, I feel better about the code, but I also see opportunity to clean it a bit more. Your mileage may vary.
Last edited by Randolph Freelander; 05-18-2012 at 05:51 AM.
ronito
got my tag in the OT
(05-18-2012, 05:52 AM)

ronito's Avatar
#762

Originally Posted by Zoe: View Post
Is there a description somewhere of how a typical code review is conducted? I've never had one :(
Depends. Some are setup for actually very good reasons (like making sure it fits in with current structure, proper error handling and all that) others are just opportunities for everyone to show their "e-peen"s .

I used to run code reviews and they went sorta like this:
- Have the developer explain what the problem their code is supposed to solve.
- Look through the code see if it actually solves the problem
- Look at the error handling make sure it's appropriate for what the code is doing
- Look for any "overlap" issues the code might cause downstream (this is the most important one)
- Look at unit test evidence
- Look at performance
- Make sure all objects are destroyed properly
- Look for redunancy or bad code. Now I'm not talking about shooting everything down it's not about style but literally we had instances where someone wanted to do something and they just kept copy/pasting the same code over and over. We told them to go back and use a function. Like real brain dead stuff like that.

Now I've sat in plenty of code reviews where people just sit there and beat up any developer unlucky enough to show up.
hateradio
Member
(05-18-2012, 06:15 AM)

hateradio's Avatar
#763

I'm currently volunteering some time to refactor a CMS code base, but the thing is fucked. It was coded in 2007 or so and it shows. It's in PHP, and practices of PHP4 are seen everywhere.

Class names are all in caps and use underscores, variables are okay since they're CamelCase, but methods and functions are lower cased with underscores. It's rare that variables and methods are declared private, protected, or public.

There are pages with tons of functions, classes that are unorganized, xHTML being processed by the PHP, no templates, no SQL abstraction. It works, but it's a total nightmare. There was a plan to restructure and to appropriate a framework last year, but it was killed after the devs decided it would be too much work.

They don't want to use a framework at this time because initializing their (the framework's) code takes a lot of resources.


Once I started using an MVC pattern, I really started to notice that my methods and functions were becoming smaller, at least in the controllers. It's interesting to see that your code becomes lighter as you create a nice chain of command and better interaction between your objects. This is especially why I am in love with Doctrine's ORM now. It's a life changer. ;_;
Last edited by hateradio; 05-18-2012 at 06:22 AM.
bluemax
Banned
(05-18-2012, 06:22 AM)
#764

Originally Posted by Oozinator: View Post
Why is graphics programming so complicated ? All current rendering technologies seem to me like just a collection of hacks to perform fast rendering on current cpus instead of creating simple elegant solutions for upcoming faster computers.
As someone recently tasked with porting a DirectX renderer to OpenGL, I couldn't agree more!

OpenGL is some arcane ass shit.


Originally Posted by BLSwagger10: View Post
finally done with both semesters on Java data structures. Fuck data structures.
Data structures is probably one of the 3 most important and useful classes you will take as an undergrad. The other two would be Algorithms and Operating Systems.

Unless you're gonna be a namby pamby web "programmer" than forget what I just said.


Originally Posted by Zoe: View Post
Is there a description somewhere of how a typical code review is conducted? I've never had one :(
There's an excellent book out there called Programming Interviews Exposed, I HIGHLY recommend it to anyone getting ready to graduate college. Obviously not all positions are equal, nor are all interviewers but in the 5 years I've been out of college I'd say 75% of interview material/structure was stuff that book covered. This goes moreso for entry level positions though, I think more recent interviews I've had have deviated a bit more and tend to be more about my professional experience.

I could probably write a decent sized guide on how to prepare for entry level job interviews as a programmer in the games industry.
Last edited by bluemax; 05-18-2012 at 06:29 AM.
Zoe
(05-18-2012, 12:49 PM)

Zoe's Avatar
#765

Originally Posted by bluemax: View Post
There's an excellent book out there called Programming Interviews Exposed, I HIGHLY recommend it to anyone getting ready to graduate college. Obviously not all positions are equal, nor are all interviewers but in the 5 years I've been out of college I'd say 75% of interview material/structure was stuff that book covered. This goes moreso for entry level positions though, I think more recent interviews I've had have deviated a bit more and tend to be more about my professional experience.

I could probably write a decent sized guide on how to prepare for entry level job interviews as a programmer in the games industry.
Well I'm past the interview stage :lol

My situation is that I'm the first and only programmer for my employer, so it's up to me to set the standards, but there's no one around to double-check my work. This isn't my first job, but I was just QA before, so I was never privvy to what goes on behind the scenes for the developer.
RiggenBlaque
Member
(05-18-2012, 01:12 PM)

RiggenBlaque's Avatar
#766

Originally Posted by Randolph Freelander: View Post
We talked to another guy. We typically slip them some code for them to talk about. The code will generally have some issues to improve. Maybe it needs some refactoring, maybe it needs a different abstraction, maybe there is even a COMPLETELY OBVIOUS bug. Small, small snippets of code. We just want them to talk about it and hopefully sound intelligent as they do so. We allow for nervousness. 9 out of 10 can't do that much. But this one guy literally snapped. "I don't want to do this. Maybe if I could take this home, I could do it, but I'm not doing it here." It is disheartening.

I keep thinking there is good code out there. After these interviews over the past few months, I am coming to grips that the cargo cultists have won.
Although these guys sound like idiots, I also have major issues with interviewers who put me on the spot with programming questions. What you're describing sounds reasonable, but lots of interviewers give those on-the-spot programming questions that are described in that Programming Interviews Exposed, which is infuriating.

"How would you reverse the words in a string?"

Yes, because I frequently run into complicated problems at work that must be solved within a couple minutes while being stared at by 3 interviewers. The good companies give you some sort of assignment and a week to complete it. The goal is just to show that the interviewee has competent programming skills regardless of language and doesn't write code that is bunched up into one 10,000 line file with no comments and variables named things like "temp","a_" or "num".

Speaking of dumb interviews, I had a recruiter call me on the phone who obviously had no technical experience at all (why else would he be a recruiter?) who asked me the most inane questions that just completely drove me up the wall.

"In your career, how many lines of code would you estimate you've written?" 0_o
Turfster
Member
(05-18-2012, 01:19 PM)

Turfster's Avatar
#767

Originally Posted by RiggenBlaque: View Post
Yes, because I frequently run into complicated problems at work that must be solved within a couple minutes while being stared at by 3 interviewers. The good companies give you some sort of assignment and a week to complete it. The goal is just to show that the interviewee has competent programming skills regardless of language and doesn't write code that is bunched up into one 10,000 line file with no comments and variables named things like "temp","a_" or "num".
They're even more fun when they give you A PIECE OF PAPER AND A PEN and ask you to WRITE YOUR ALGORITHM FROM SCRATCH while they're watching. Because we all know that's how we code stuff, we write it on a piece of paper...
jimi_dini
Member
(05-18-2012, 02:15 PM)

jimi_dini's Avatar
#768

Originally Posted by Mister Zimbu: View Post
Could be worse. Could always be worse.

Could be tbl_Cert_Partner and fld_Partner_Cert_ID.
That's nothing.

Tablename T_KK_LZ
Fields LstPatIDRel, LstDeleted, LstLszIDRel, LstID, LstLszIDRel, LstDatum, LstPrxIDRel, LstVKNR, LstAbrDiaIDRel, LstLink, LstDocID, DaySeparation and more crap
And that's one of maybe 400 tables, all named the same shitty way. And the shitty way isn't even consistent. I guess the developers could not be bothered typing a little more than a few letters. Too much work I guess.

I had to reverse engineer this pos database that's used for documenting dialysis, just because that fine company isn't capable of exporting to HL7.
usea
Member
(05-18-2012, 04:44 PM)

usea's Avatar
#769

Originally Posted by Turfster: View Post
They're even more fun when they give you A PIECE OF PAPER AND A PEN and ask you to WRITE YOUR ALGORITHM FROM SCRATCH while they're watching. Because we all know that's how we code stuff, we write it on a piece of paper...
Originally Posted by RiggenBlaque: View Post
Although these guys sound like idiots, I also have major issues with interviewers who put me on the spot with programming questions. What you're describing sounds reasonable, but lots of interviewers give those on-the-spot programming questions that are described in that Programming Interviews Exposed, which is infuriating.

"How would you reverse the words in a string?"

Yes, because I frequently run into complicated problems at work that must be solved within a couple minutes while being stared at by 3 interviewers. The good companies give you some sort of assignment and a week to complete it. The goal is just to show that the interviewee has competent programming skills regardless of language and doesn't write code that is bunched up into one 10,000 line file with no comments and variables named things like "temp","a_" or "num".
What? If somebody gets pissed when they're asked a simple programming question or refuses to answer even something like "I'd google the name of the library function that reverses strings" then...wtf.

You need to be able to show that you're at least base-line competent in an interview. That means writing code on a whiteboard or on paper or maybe even typing it. It doesn't have to be perfect. But if your reaction is to get mad when asked to demonstrate that you can do your job then goodbye.

An interview isn't just to make sure you don't name your variables stupidly. You need to demonstrate that you can actually code. Like, that you know what a for loop does. A week-long assignment? That's stupid. Just write 10 lines. They'll probably give you quite a lot of time to demonstrate your competency.

I have zero problem writing code on paper. Most of the time the code will actually compile, but I certainly don't expect that from everybody. It can be english, as long as it describes your thought process.
Randolph Freelander
Member
(05-18-2012, 11:55 PM)

Randolph Freelander's Avatar
#770

What usea said.

You are being hired to read and write code. You should read and write code in your interview. Just look at some code, talk about it. Go to the whiteboard. Write pseudocode. Yes, you should be able to do that on the spot. Again, nothing intended to trip you up. Nothing that is going to make you rack your brain for hours and hours. But an hour of Q & A isn't going to reveal everything. Code, on the other hand, reveals much.
Turfster
Member
(05-19-2012, 12:15 PM)

Turfster's Avatar
#771

Originally Posted by usea: View Post
I have zero problem writing code on paper.
1. My handwriting (and I'm sure a lot of other people's) is *atrocious*
2. Whiteboards, yes. Small pieces of paper where you can't easily undo/shuffle lines and then expect perfect code for something rather complex? Hell no.

I managed to do it, but it was a damned pain
Last edited by Turfster; 05-19-2012 at 12:20 PM.
Rez
(05-19-2012, 12:27 PM)

Rez's Avatar
#772

Originally Posted by Randolph Freelander: View Post
Speaking of ten years, it continually fascinates me just how many developers there are out there that absolutely cannot code. I've read all the blogs, the "199 out of 200 applicants cannot write code," all of that. Didn't believe it.

Then I started being involved in interviews. :/

I work in C#, .NET. There has been a lot of evolution in .NET over the past 10 years. Nearly every person I have interviewed has supposedly been involved in C# development for the better part of those 10 years. And nearly every person's skillsets are still mired in what wasn't even acceptable 10 years ago, let alone now. No OOP. No abstractions. Polymorphi-what? Collection of choice is still the ArrayList.

We talked to a guy. 20 years on his resume, with a lot of the recent years centered around C#, VB, and Java. He had on his resume that he taught a Java course at a community college. So I decide to, even though we're interviewing for C#, toss him a softball Java/C# compare/contrast question just to break the ice a bit. He cut me off. "I don't know Java." Thank you, drive through.

We talked to another guy. We typically slip them some code for them to talk about. The code will generally have some issues to improve. Maybe it needs some refactoring, maybe it needs a different abstraction, maybe there is even a COMPLETELY OBVIOUS bug. Small, small snippets of code. We just want them to talk about it and hopefully sound intelligent as they do so. We allow for nervousness. 9 out of 10 can't do that much. But this one guy literally snapped. "I don't want to do this. Maybe if I could take this home, I could do it, but I'm not doing it here." It is disheartening.

I keep thinking there is good code out there. After these interviews over the past few months, I am coming to grips that the cargo cultists have won.
I don't understand. Are these people graduates?
Zeouterlimits
Member
(05-19-2012, 12:39 PM)

Zeouterlimits's Avatar
#773

Finished my last exam last Friday and started work last Monday.
We mainly do web-apps and while I already had experienced some of it previously this was a big reminder of:

-There's a stupid level of voodoo magic in getting your dev environment set up correctly
-Having 8 different css files, 2 of which are for different IE versions can be a nightmare to debug, especially across different browsers and table column sizes with a mix auto sizeing and preset sizes.

But work has been fun, have achieved nice little fixes/updates for the application.
Randolph Freelander
Member
(05-19-2012, 06:39 PM)

Randolph Freelander's Avatar
#774

Originally Posted by Rez: View Post
I don't understand. Are these people graduates?
Fallacy: going to college makes you a good programmer.

But, yes, they all had CS "or related" degrees.
deadbeef
Member
(05-19-2012, 06:53 PM)

deadbeef's Avatar
#775

If you're a good developer / programmer / architect /engineer you'll never have trouble finding work because there are so many bad programmers out there.

We are falling behind at work because we are having to drag deadweight behind us. I'm in a more supervisory role than I have been before and I'm really frustrated because I'm not even in a position to prop these people up or help them even. They are as dumb as rocks.
thcsquad
Member
(05-19-2012, 06:58 PM)
#776

Originally Posted by Zoe: View Post
Is there a description somewhere of how a typical code review is conducted? I've never had one :(
My company uses Review Board. http://www.reviewboard.org/

My last company did the more traditional route - when somebody was about done with a big project, they had to print the entire project out on paper and distribute it to the team a week before the meeting. Then we just brought up things we'd improve in the meeting.

Review Board is pretty awesome though. It hooks into your existing source control, and you just upload diffs. It formats them all pretty and people just highlight code in their web browser to comment on it. We use it for cross-pollination as much as fixing potential problems. The entire team stays up to date on what's going on across the various codebases even if they're not currently working on each one.
Halvie
Member
(05-19-2012, 07:03 PM)
#777

Originally Posted by Fersis: View Post
I remember my first 'sleeping in the office' experience.
Do you guys remember your first crunch?

It was pretty awesome the first time, i was young and i rocked 14-18 hours days for weeks.
But then it became the norm =/
Had to watch some bs video in a coding class about a guy working as a game programmer. They asked him to work overtime before the launch of their game, but he had tickets to a concert that weekend... Classed was asked what they would do if in a similar situation. Pretty much the entire class said they wouldn't work the overtime, and quit if it came to that. Saying they could find an equal or better job within a day or two. How is it possible people are still that naive? Shocker, but I don't go to MIT either.
rhfb
Member
(05-19-2012, 07:04 PM)

rhfb's Avatar
#778

Originally Posted by thcsquad: View Post
My company uses Review Board. http://www.reviewboard.org/

My last company did the more traditional route - when somebody was about done with a big project, they had to print the entire project out on paper and distribute it to the team a week before the meeting. Then we just brought up things we'd improve in the meeting.

Review Board is pretty awesome though. It hooks into your existing source control, and you just upload diffs. It formats them all pretty and people just highlight code in their web browser to comment on it. We use it for cross-pollination as much as fixing potential problems. The entire team stays up to date on what's going on across the various codebases even if they're not currently working on each one.
Cool, I'll have to look into this. Currently my place doesn't do any code review, but with me pushing we might start. Also good to hear that "good" programmers are always in demand. I mean I know I'm not the best, but I am competent, I just usually crack when interviewing if asked bullshit questions that even the interviewer doesn't know the answers to off the top of their head with no computer in front of them to type it out and test it. Once had someone tell me there was a typo in my handwritten pseudo code, so I told him the IDE would catch it and not let me compile... Not the right answer apparently.
thcsquad
Member
(05-19-2012, 07:09 PM)
#779

Originally Posted by Randolph Freelander: View Post
. The class has X + 1 properties. Obviously, to initialize this thing, you have to technically violate the standard. !
This sounds like you're breaking a different rule. Why does this class have that many different properties? Just like a long method is begging to be broken down into smaller methods, a fat class is begging to be broken down into smaller classes. I'd find it odd for a team to care so much about LOC and not care how fat their classes are.

In general, the phrase 'technically breaks the rule but not in spirit' is a red flag for there being a larger problem, and in this instance it seems to be a fat class.
jimi_dini
Member
(05-19-2012, 07:12 PM)

jimi_dini's Avatar
#780

Originally Posted by Halvie: View Post
Had to watch some bs video in a coding class about a guy working as a game programmer. They asked him to work overtime before the launch of their game, but he had tickets to a concert that weekend... Classed was asked what they would do if in a similar situation. Pretty much the entire class said they wouldn't work the overtime, and quit if it came to that.
They are right. Why should you destroy your health. Look for a better job. I'm doing SAP development for module IS-H (hospital) and MM (materials managment, in my case pharmacy), and also take data from module HR into IS-H. If there is some severe problem, then I will stay at work of course - but that's a different beast, doctors need that stuff to work - also I'm not an admin, so normally this doesn't happen at all. Maybe 1-2 hours additionally in such special cases. Other than that, going home after regular work hours. And that's the norm. And that should be the norm.
Randolph Freelander
Member
(05-19-2012, 07:13 PM)

Randolph Freelander's Avatar
#781

Originally Posted by thcsquad: View Post
This sounds like you're breaking a different rule. Why does this class have that many different properties? Just like a long method is begging to be broken down into smaller methods, a fat class is begging to be broken down into smaller classes. I'd find it odd for a team to care so much about LOC and not care how fat their classes are.

In general, the phrase 'technically breaks the rule but not in spirit' is a red flag for there being a larger problem, and in this instance it seems to be a fat class.
In the cases I refer to, it's just a class representing a database entity and has no behaviors. Database table fields => class properties. Nothing more.
Last edited by Randolph Freelander; 05-19-2012 at 07:16 PM.
Rez
(05-19-2012, 07:49 PM)

Rez's Avatar
#782

Originally Posted by Randolph Freelander: View Post
Fallacy: going to college makes you a good programmer.

But, yes, they all had CS "or related" degrees.
I guess it depends on your definition of good. If they were even a little bit invested in a software engineering related degree, the things you're mentioning are drilled into your skull from first year. It's just mind boggling. Reading these stories really blows my mind.

On the plus side, finding a job when I graduate might not be as tough as I'm expecting.
Miutsu
Member
(05-19-2012, 08:28 PM)

Miutsu's Avatar
#783

Originally Posted by deadbeef: View Post
If you're a good developer / programmer / architect /engineer you'll never have trouble finding work because there are so many bad programmers out there.
If any of you are or knows a Montreal/Quebec employer, tell them we have like 3 or 4 competent developers here in Venezuela looking for a good opportunity :D *waits endlessly*
Ambitious
Member
(05-20-2012, 08:08 PM)

Ambitious's Avatar
#784

A few weeks ago I was charged with refactoring and adding some new features to a VB script in a MS Access document connected to an Oracle SQL database which is used by a notable number of employees all over the world.

The script had been written by an external consulting company, and the code was just horrible.

The records had a country field, and the Access form should only display records with the same country as the user, whose country was read from a MS Active Directory.
There were about 7 to 10 getters and global variables only for the country. The getCountry function checked if the country variable (a string) was empty and called another getCountry function if so. I can't remember what the second function did, but it was pretty similar to the first one and called another function too. Afterwards the return value of the second function was checked too, and if the string was empty, it read the value of the global DEFAULT_COUNTRY variable. If that one was empty, it called another function.

Those methods should return just the name of the country, but the country code was used too. So, all of those functions again, just with the country code instead of the country name. And this bunch of functions was interwoven with the first bunch, some of them called each other...

The database contained not a single primary key, I shit you not. The main table which contained the records for the Access form had an id field, but there were no constraints. They just looked if the id existed in the VB script when a record was added or edited and displayed an error message if so.

So of course, the main tables country field actually stored the country names. A workmate told that their had been a typo in the country table once, so they had to edit all references in the other tables, which had caused several problems. I think that was the first thing I did, adding primary key ids.

I can't remember most of the details from the remaining code, but it was a mess.

Using the VB editor is a pain in the ass too. If you have a syntax error in a line and attempt to move the cursor to another one, the line is not underlined with an angular red line or something like that, but you get a fucking modale error dialog. Occasionally makes me wanna yell out of rage.
To check for some semantic errors, you can compile the whole script, but instead of showing a table with all error descriptions and line numbers, you get a modale dialog again. It shows the error description of the first found error and puts the cursor to the corresponding line if you click ok. Fix it, compile again, message box about the second error. Fix it, compile again, and so on.


The following paragraphs are no rant but a funny anecdote, again about the country id stuff.

Without an ORDER BY clause, the sort order of the results of a SQL query is usually undefined. When adding the country ids, I wanted the alphabetically first country to have the id 1, the second 2 and so on. Of course there's no reason to do so, but it just looks nice in the database...
Curiously, I tried the following statement:

Quote:
UPDATE (select * from countries order by country_name asc) SET id = country_id_seq.nextVal;
And it worked! Did not you could use selects instead of table names in an update statement.
So I continued my work refactoring the script to use the ids instead.

Some users had extended rights, they were able to view and edit records for other countries other than their own too. Previously, this was handled in the VB script.
Quote:
IF user_country=A AND (record_country=A OR record_country=B record_country=C)
...
ELSEIF user_country=B AND (record_country=B OR record_country=D record_country=E)
...
Awesome, yes. So I created a table for user rights, consisting of a column for the country id of the editing user and one for the country ids he is allowed to edit.
I dumped the CREATE TABLE and INSERT statements into a file to add the data to the test and production databases.

Everything was working flawlessly, so after verifying it worked in the test environment too, it went into production.
A few days later we got a call from another employee abroad. She couldn't access her records. Alright, so I had a look into the database. The country id in the RIGHTS table was off by one. Figured a typo, fixed it and right before I closed the window, I noticed that EVERY SINGLE COUNTRY ID IN THE WHOLE TABLE WAS OFF BY ONE. Meaning, not a single user would have been able to get access to his/her records.. luckily no one seemed to have used it for days, or else we would have got dozens of emails and calls.
I was new at the company back then, and I panicked. I didn't even try to correct the ids via UPDATE statements, I fixed them manually line by line.

Still slightly shaking, I investigated how this could be possible. The reason was this:
Quote:
UPDATE (select * from countries order by country_name asc) SET id = country_id_seq.nextVal;
The first country in the country table was "Åland Islands". In the dev enviroment, the 'Å' was regarded as a special character, so the country was sorted behind 'Z' and got the last id.
In the test and production environments, which I guess are using a different Oracle version, it was regarded as an 'A' and got the id 3.

So, in the dumped INSERT script of the RIGHTS table, all country ids greater than 2 were too low by one...
hateradio
Member
(05-20-2012, 08:28 PM)

hateradio's Avatar
#785

Å does go after Z, depending on the DB's character set. I guess you should have checked for that first. :P Are the dev and production dbs different? Like one is UTF8 and the other Latin-something?
Last edited by hateradio; 05-20-2012 at 08:30 PM.
njr
Member
(05-20-2012, 08:34 PM)
#786

Originally Posted by deadbeef: View Post
If you're a good developer / programmer / architect /engineer you'll never have trouble finding work because there are so many bad programmers out there.

We are falling behind at work because we are having to drag deadweight behind us. I'm in a more supervisory role than I have been before and I'm really frustrated because I'm not even in a position to prop these people up or help them even. They are as dumb as rocks.
No kidding. I walked into an interview, aced it, and was able to get 10K more than I make now. The secret? There's no real competition when your competition isn't competent.
Fancy Corndog
Member
(05-20-2012, 08:34 PM)

Fancy Corndog's Avatar
#787

Is it fair to say that SQL is just an inherently messy language? I almost always have to double-check how things are written in SQL with ' vs ` stuff and whatnot. Then again, I'm not exactly experienced either.
hateradio
Member
(05-20-2012, 08:41 PM)

hateradio's Avatar
#788

For MySQL, you only need to use graves (`) if your database is older (legacy) or the name is reserved ie: LIKE and you have a field or table named like. So you would have to escape it with graves. However, you should avoid using reserved words. You should tweak it to avoid problems (use _like or likes).

You use single quotes for data.

Depending on the language, you can also an abstraction layer, which can help with circumventing the use of quotes. :P But you'll still have to watch out for reserved words.
Last edited by hateradio; 05-20-2012 at 08:44 PM.
Haly
One day I realized that sadness is just another word for not enough coffee.
(05-20-2012, 08:43 PM)

Haly's Avatar
Not exactly a rant but I thought I'd ask here anyway #789

I have four classes: GameManager, InputManager, GUIManager and GUIMenu

User input should be passed to whichever GUIMenu is active, and the input should be responded to by changing the state of the GameManager in some way. My problem is that I can't really decide what is the best way to go about doing this.

Solution 1:
When GUIMenu is updated, it asks the InputManager for any input from the user then responds to it by telling the GameManager what it should do. This is the simplest solution, I think, but it requires a lot of inter-class mingling I'm not comfortable with. For example, if I have a stage select menu, the menu would tell the GameManager to load level 1, but then the GUIMenu would have to be aware of the LevelManager, or at least the GameManager.

Solution 2:
GameManager gets user input from InputManager, gives GUIManager a state and asks it for the menu that corresponds to that state. GameManager then passes on the input to the GUIMenu and asks what it should do next. GUIMenu returns a task like PUSH_PAUSE or LOAD_NEW_GAME, which the GameManager then passes on to whatever class handles that stuff.

Solution 3:
Like Solution 2 except it adds an extra layer of indirection by having GameManager pass input to GUIManager, which passes it on to the GUIMenu. Later, GameManager asks GUIManager if there's anything that should happen because of the input. Then GUIManager asks GUIMenu what should happen, and finally takes the response and sends it back up to GameManager.

I like Solution 3 the most because it keeps all the classes nice and separate, but it also seems like I'm intentionally adding redundancies for the sake of organization. Since I'm still a student, stuff like this slips under the radar but I would like some opinions from on what I should do if I was in a professional setting.
Miutsu
Member
(05-20-2012, 10:19 PM)

Miutsu's Avatar
#790

Originally Posted by Haly: View Post
I have four classes: GameManager, InputManager, GUIManager and GUIMenu

User input should be passed to whichever GUIMenu is active, and the input should be responded to by changing the state of the GameManager in some way. My problem is that I can't really decide what is the best way to go about doing this.

Solution 1:
When GUIMenu is updated, it asks the InputManager for any input from the user then responds to it by telling the GameManager what it should do. This is the simplest solution, I think, but it requires a lot of inter-class mingling I'm not comfortable with. For example, if I have a stage select menu, the menu would tell the GameManager to load level 1, but then the GUIMenu would have to be aware of the LevelManager, or at least the GameManager.

Solution 2:
GameManager gets user input from InputManager, gives GUIManager a state and asks it for the menu that corresponds to that state. GameManager then passes on the input to the GUIMenu and asks what it should do next. GUIMenu returns a task like PUSH_PAUSE or LOAD_NEW_GAME, which the GameManager then passes on to whatever class handles that stuff.

Solution 3:
Like Solution 2 except it adds an extra layer of indirection by having GameManager pass input to GUIManager, which passes it on to the GUIMenu. Later, GameManager asks GUIManager if there's anything that should happen because of the input. Then GUIManager asks GUIMenu what should happen, and finally takes the response and sends it back up to GameManager.

I like Solution 3 the most because it keeps all the classes nice and separate, but it also seems like I'm intentionally adding redundancies for the sake of organization. Since I'm still a student, stuff like this slips under the radar but I would like some opinions from on what I should do if I was in a professional setting.
I think I like solution 3 but instead of returning a state back to the GameManager, let the GUIMenu save a reference (can be through reflection) to the class/method that needs to handle that specific action.

Mind you, I myself havent dealt with this specific problem but a friend in my team has and I think this was his solution, although we still have got to see how it behaves ;)
Tantalus
Junior Member
(05-20-2012, 10:48 PM)

Tantalus's Avatar
#791

Subbed to this thread! Was surprised there is no (to my knowledge?) general programming thread, glad that this one showed up.

Don't have a question or anything right now, just a rant. I'm a programmer who can't design. It's so frustrating, and combined with how I constantly restart entire projects in an attempt to clean up code, I have just about nothing to show for the past six years of programming.

For a year or so now I've been toying around with the idea of making a video game website. I know there are thousands of them out there, and this one probably wont do anything original or get more than 10 visitors per week, but it's something my friends have wanted to do and it sounds like a fun way for us to spend our free time together.

So I did some of the server-side stuff in PHP with the Yii framework (which I can't recommend enough, it's a fantastic framework, maybe the best one around right now), but then started to design the front end site and have been stuck at that stage ever since. This was the closest I ever got to a usable design, but I still don't like it. Too much white space.

Quote:
Maybe I'll just use that design for now and hope that someone can help me come up with something better in the future. I just want to get stuck into the server-side development and see a functional website start to form, regardless of how bad it looks.
Andrex
ὁ αἴσχιστος παῖς εἶ
(05-20-2012, 10:54 PM)

Andrex's Avatar
#792

I kinda like it, too many gaming sites these days have waaayyy too much distracting crap.

It could use some more color though, I think.
An-Det
Member
(05-21-2012, 01:04 AM)
#793

I know the feeling Tantalus. Give me a spec and mockups and I'll build it fine, but I've got no eye for design or color (being colorblind doesnt help that either), so left to my own designs I'll always second-guess my work. Nothing wrong with it.
Earthstrike
Member
(05-21-2012, 06:03 AM)

Earthstrike's Avatar
#794

Hey. I learned procedural programming in a university course where I did C++. (The course was called problem solving for scientists and engineers). I like reading this thread, but something that's always bothered me is that I don't quite have a full handle on what exactly object oriented programming is. I think the source of this confusion is me trying to understand what it can achieve that procedural programming cannot.

I looked at the code from randolph earlier in the page and I understand what everything does there. So I look at it and say "is object oriented programming just having a bunch of functions floating around that take and pass variables around?" I mean, I see how it works, but I'm having trouble seeing what is there that can't be done in a procedural program. Is it the idea of inheritance? Isn't that just a little something that makes coding easier? I've read the wikipedia article about OOP a couple times now, and honestly, the criticisms seem to make more sense of OOP to me than the actual explanations.
rhfb
Member
(05-21-2012, 06:10 AM)

rhfb's Avatar
#795

Originally Posted by Tantalus: View Post
Subbed to this thread! Was surprised there is no (to my knowledge?) general programming thread, glad that this one showed up.

Don't have a question or anything right now, just a rant. I'm a programmer who can't design. It's so frustrating, and combined with how I constantly restart entire projects in an attempt to clean up code, I have just about nothing to show for the past six years of programming.

For a year or so now I've been toying around with the idea of making a video game website. I know there are thousands of them out there, and this one probably wont do anything original or get more than 10 visitors per week, but it's something my friends have wanted to do and it sounds like a fun way for us to spend our free time together.

So I did some of the server-side stuff in PHP with the Yii framework (which I can't recommend enough, it's a fantastic framework, maybe the best one around right now), but then started to design the front end site and have been stuck at that stage ever since. This was the closest I ever got to a usable design, but I still don't like it. Too much white space.



Maybe I'll just use that design for now and hope that someone can help me come up with something better in the future. I just want to get stuck into the server-side development and see a functional website start to form, regardless of how bad it looks.
The only thing I'd say is coming from the UX side of things, is that links in that shade of purple have a very ingrained meaning.

And I actually like the whitespace, and it looks like it wouldn't be that hard to get the site looking good on mobile devices (seriously, huge push right now on making sites work well on iPads and iPhones)
Angelus Errare
black folks = Newports
(05-21-2012, 06:26 AM)

Angelus Errare's Avatar
#796

Originally Posted by bluemax: View Post
As someone recently tasked with porting a DirectX renderer to OpenGL, I couldn't agree more!

OpenGL is some arcane ass shit.




Data structures is probably one of the 3 most important and useful classes you will take as an undergrad. The other two would be Algorithms and Operating Systems.

Unless you're gonna be a namby pamby web "programmer" than forget what I just said.




There's an excellent book out there called Programming Interviews Exposed, I HIGHLY recommend it to anyone getting ready to graduate college. Obviously not all positions are equal, nor are all interviewers but in the 5 years I've been out of college I'd say 75% of interview material/structure was stuff that book covered. This goes moreso for entry level positions though, I think more recent interviews I've had have deviated a bit more and tend to be more about my professional experience.

I could probably write a decent sized guide on how to prepare for entry level job interviews as a programmer in the games industry.
FIGHT ME BRO!
Spoo
Member
(05-21-2012, 06:28 AM)
#797

Originally Posted by Earthstrike: View Post
Hey. I learned procedural programming in a university course where I did C++. (The course was called problem solving for scientists and engineers). I like reading this thread, but something that's always bothered me is that I don't quite have a full handle on what exactly object oriented programming is. I think the source of this confusion is me trying to understand what it can achieve that procedural programming cannot.

I looked at the code from randolph earlier in the page and I understand what everything does there. So I look at it and say "is object oriented programming just having a bunch of functions floating around that take and pass variables around?" I mean, I see how it works, but I'm having trouble seeing what is there that can't be done in a procedural program. Is it the idea of inheritance? Isn't that just a little something that makes coding easier? I've read the wikipedia article about OOP a couple times now, and honestly, the criticisms seem to make more sense of OOP to me than the actual explanations.
You're probably just asking the wrong question here. It's not necessarily about what you can achieve with OOP that you cannot achieve otherwise (that would be a loaded question in and of itself, I think).

Instead, OOP is just about three things in my opinion. Abstraction, People, and the "Noun." With OOP you engage in a lot of higher level constructs; code-hiding (encapsulation), polymorphism, inheritance, etc -- but really, you're interested in People, and people interact with things. Hence the "Noun" -- we want to escape the verb of code, that is "what you're doing, or how you're doing it" and replace it with a noun: "what are you interacting with."

edit: For clarity; at the end of the day, you're modeling things with code. What you're modeling doesn't matter, but the manner in which you express your model can be drastically different depending on the paradigm. OOP is a paradigm; you're working with objects (even if you're working with functions and variables still). Depending upon what you're doing, certain programmers will tell you where the paradigm may break down, or where it can excel. The truth is, you're not going to fully understand it until you find a project where the paradigm makes sense, and you can see that it has a positive impact on your development (for example, others are able to better understand your code, or what-have-you).

It's not so different from real-life. You can explain to me what your day to day is in terms of the things you do, or in terms of the things you've used (your bed, your phone, a door... etc).

OOP is a tool like any other, made by people for people, for explicit organizational purposes and productivity. It is not always the correct tool for the job. Knowing when to use it versus when not to is an acquired ability over time, though it's possible to go your entire career using one or the other exclusively (though, highly unlikely in this day and age).

Hope that helps.
Last edited by Spoo; 05-21-2012 at 06:32 AM.
hateradio
Member
(05-21-2012, 08:23 AM)

hateradio's Avatar
#798

To me it's that your code is divided into several different aspects. That's not to say that you can't divide code into different parts or sections when you're doing procedural programing, but the result of OOP is a cohesive set of objects.

I won't do the example of a Person or Cat or Blog or whatever class, but essentially you're creating a relationship in your code that is more than the functions you're writing.

If you want to create a function that returns the sum of some numbers you'd easily create it. But what if those numbers were not just part of a global scope? What if those numbers came from another function that worked with another function?

You'd have four or five functions in your code for that one sum.

Code:
function doAdd (x) {
 r = 0
 numbers = getNumbers()
 processed = processNumbers(numbers)
 total = processed + x
 if (total > 0)
  r = third
 
 return r
}
What you end up having is a lot of functions in your code available at any one time, and a constant need to have them around because you don't know what your code will demand at every instance. Depending on the language, this can hamper memory if there are a thousands of functions, yet depending on what the program is doing, maybe only a few are needed at any given time.

Anyway, I don't know much about C++, but I'm sure most languages have built-in objects/prototypes. Things that relate to strings or integers or arrays, etc. When you need a string's length, you'd do something like characters = MyString.length. So you're working with objects even if you don't realize it.


Lets say you need that aggregation. The aggregator has a very specific function (as any object should have) so you know how it will work before you even start writing it.

The aggregator should be able to get the numbers, process them, add them to a given value, and return 0 or the total.

Aggregator.getNumbers
Aggregator.process
Aggregator.doAdd


They're part of that aggregator object, not the whole program. If you need it, you'll call it with new, if you don't, you won't need to have it around at all.

Now, I know what you're thinking. Those methods could be normal functions because they're doing the same thing. However, as an object they're actually isolated from the rest of the program. If you instantiate an Aggregator to process your numbers, you'll be working within its scope, typically using this. Once you get your objects in place, all you might need to do when you want that sum is call something like the following.

Code:
Sum = new Aggregator
Total = Sum.doAdd(32)
I know the example is odd, but the point is that you have an new Aggregator and you're adding 32 to it. Maybe later you wan to remove that 32, so you can have an "undo" method that can do that.

Code:
// Later on the user decided not to have that addition so they undo it
Sum.undo()
It would be difficult to do that with a procedural program unless you have separate variables that retain that memory. But what if you have thousands of additions/subtractions at any given time? It would be hard to keep track.

Moreover, within your aggregator you have control of what it will do once its instantiated -- its properties and methods can change when that happens. That's also the case when it's destroyed or copied or what have you. There's a lot more control over your code.

I could go on and on, but that's, at least what I think, is the gist of OOP. You have an object, just as one of the native objects of your language (string, array, etc) that is specific to what you want to accomplish. And just like you can have thousands of different strings or arrays in your code, you can have thousands of these objects (if you required them) to do the work you need.
Last edited by hateradio; 05-21-2012 at 08:30 AM.
Tantalus
Junior Member
(05-21-2012, 08:58 AM)

Tantalus's Avatar
#799

Thanks for the feedback on my site design guys. It's actually really reassuring! I see what you mean about having links in purple; all of the main colours are stored in SASS variables, so those can be changed easily.

I'll keep using that design for now and maybe post an update every now and then on how development is going.
iapetus
Scary Euro Man
(05-21-2012, 10:35 AM)

iapetus's Avatar
#800

Originally Posted by Tantalus: View Post
Thanks for the feedback on my site design guys. It's actually really reassuring! I see what you mean about having links in purple; all of the main colours are stored in SASS variables, so those can be changed easily.

I'll keep using that design for now and maybe post an update every now and then on how development is going.
Do that. Site design looks beautiful to me - nice and simple, clear, a triumph of content over clutter.