Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

04-25-2012 , 01:43 AM
Quote:
Originally Posted by Neko
Noah, Python does treat virtually everything as a boolean afaik. & is a bitwise operator not a logical comparison. 1 and 2 == True, [1,2] and [3,2] == True
Strictly speaking, these statements won't evaluate to True because True and False cast to integers. But yeah, non-empty lists and nonzero ints and anything will evaluate to True in a boolean context. Logical and is not "&", it's "and".
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 01:46 AM
btw, "and" and "or" actually return one of their arguments, but I think it's generally considered bad practice to rely on this behavior:

Code:
>>>[1,2] and [3,4]
[3,4]
>>>[1,2] or [3,4]
[1,2]
>>>[1,2] and []
[]
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 02:35 AM
Hey what do you guys use to write Java code? I'm use eclipse and the compiler / debugger (or whatever it is that tells you what you did wrong) is really starting to get on my nerves. Is there any for Java that are like visual studios where it tells you specific errors on specific lines with details?

Quote:
Originally Posted by tyler_cracker
please illustrate a problem you have where multiple inheritance is the solution.

and java definitely has vectors. i think they're in java.lang.data.structures.mutable.extensible.listl ike.vector2.
Hmm, I cant think of any where it is the only solution, I doubt any exist there are always work arounds you are right. But probably something that uses a lot of virtual functions. That reminds me, in C++ i can have a virtual base class function that does x++ and a derived function of the same name that does {x ++; baseclass::functionofsamename();} and whenever i call derived function x +=2. I can do this in Java?

As far as vectors I did some reading and from what I have read via unreliable forum posts in random forums is that vectors in Java are not a good thing to use and instead I should use arrays / double ended ques / lists etc.

Last edited by Ryanb9; 04-25-2012 at 02:44 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 02:41 AM
What is the best way to learn general programming concepts? I don't even know what things like multiple inheritance or interfaces really are.

I'm about 6 months in to .NET and feel pretty comfortable, but I know I'm writing bad code.

I'm reading through Code Complete right now and learning RoR as well by reading Agile Web Development with Rails.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 02:46 AM
Quote:
Originally Posted by Freakin
What is the best way to learn general programming concepts? I don't even know what things like multiple inheritance or interfaces really are.

I'm about 6 months in to .NET and feel pretty comfortable, but I know I'm writing bad code.

I'm reading through Code Complete right now and learning RoR as well by reading Agile Web Development with Rails.
I'm new to programing but where I get a lot of info on general concepts is from internet articles. You can find good articles by good programers all over and they get pretty in-depth on a random topic and its not language-specific.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 03:13 AM
Quote:
Originally Posted by Ryanb9
Hmm, I cant think of any where it is the only solution, I doubt any exist there are always work arounds you are right. But probably something that uses a lot of virtual functions.
i guess my point is why do you care about a "missing feature" when you don't seem to need it for anything?

Quote:
That reminds me, in C++ i can have a virtual base class function that does x++ and a derived function of the same name that does {x ++; baseclass::functionofsamename();} and whenever i call derived function x +=2. I can do this in Java?
like this i think? (lol @ my java):

Code:
public class Parent {
  public void foo(int x) {
    this.var += x;
  }
}

public class Child extends Parent {
  public void foo(int x) {
    super.foo(x);
    this.var += 42;
  }
}
Quote:
As far as vectors I did some reading and from what I have read via unreliable forum posts in random forums is that vectors in Java are not a good thing to use and instead I should use arrays / double ended ques / lists etc.
this is a "what are you trying to do" problem as well as a "to a man with a hammer, all the world's a nail" problem.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 03:13 AM
... Eclipse/C++, I feel like it's buggy at times but I don't really have much experience on anything else to compare it to..
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 03:15 AM
speaking of which, follow up to that php megarant i posted last week -- i present the php hammer:



http://www.flickr.com/photos/raindri...57629492908038
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 03:44 AM
Quote:
Originally Posted by Freakin
What is the best way to learn general programming concepts? I don't even know what things like multiple inheritance or interfaces really are.

I'm about 6 months in to .NET and feel pretty comfortable, but I know I'm writing bad code.

I'm reading through Code Complete right now and learning RoR as well by reading Agile Web Development with Rails.
rt1, i think, linked to this book in another thread: http://www.amazon.com/Object-Oriente.../dp/020163385X

i'm almost done with it now, and it's pretty great for general OO stuff that you probably don't know, especially if you're new to programming. i've been doing it for years and still learned a lot.

here's a good post comparing the general concept of an interface in java and ruby: http://stackoverflow.com/questions/4...valent-in-ruby

EDIT: another good general online resource http://c2.com/cgi/wiki?WelcomeVisitors
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 03:48 AM
Quote:
Originally Posted by Freakin
What is the best way to learn general programming concepts? I don't even know what things like multiple inheritance or interfaces really are.
Quote:
Originally Posted by Ryanb9
I'm new to programing but where I get a lot of info on general concepts is from internet articles. You can find good articles by good programers all over and they get pretty in-depth on a random topic and its not language-specific.
i was going to say "read everything", but ryan's advice is a bit more practical . knowing that the thing you want to learn about is called e.g. "multiple inheritance" is a huge head start in a universe where google exists. once you've done some homework, ask questions in a community such as this one.

(pro tip: afaik the advice in the above paragraph can take you infinitely far in software engineering. stay tuned for updates.)

multiple inheritance is something you'll figure out if you happen to need it some day (i need a thing that's both a Foo and a Bar... hmm, how do i do that?). interfaces in this context are a java-specific concept: they are like virtual functions in c++ and they exist in part to help java deal with multiple inheritance. you would learn about them if you were a java programmer who had the above Foo + Bar problem. if you are lucky, you will never be a java programmer, so i wouldn't worry about it until you need it.

Quote:
I'm about 6 months in to .NET and feel pretty comfortable, but I know I'm writing bad code.
bad news: this feeling basically never goes away.

good news: your definition of "bad" levels up with you. code you consider "bad" today becomes "wtf is this ****" in a year.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 03:54 AM
g_m,

The Wiki++
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 07:01 AM
I bet googling for interview questions and then googling for the answers would get you pretty far in understanding basic CS concepts. Probably not as efficient as using a good book though.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 08:58 AM
Quote:
Originally Posted by Ryanb9
Hey what do you guys use to write Java code? I'm use eclipse and the compiler / debugger (or whatever it is that tells you what you did wrong) is really starting to get on my nerves. Is there any for Java that are like visual studios where it tells you specific errors on specific lines with details?
What is bugging you about it? I found Eclipse to be quite similar to the way VS handles such things (though I'm not extremely familiar with any of them).

The only thing that really tilted me about Eclipse was that it insisted on spell checking my comments, but luckily that can be turned off
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 10:02 AM
Quote:
Originally Posted by Xhad
Strictly speaking, these statements won't evaluate to True because True and False cast to integers. But yeah, non-empty lists and nonzero ints and anything will evaluate to True in a boolean context. Logical and is not "&", it's "and".
you're right I did forget to include "in a boolean context".
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 10:41 AM
Quote:
Originally Posted by Ryanb9
Hey what do you guys use to write Java code? I'm use eclipse and the compiler / debugger (or whatever it is that tells you what you did wrong) is really starting to get on my nerves. Is there any for Java that are like visual studios where it tells you specific errors on specific lines with details?
The Problems view will show you the list of errors (and warnings) with all the details you mentioned. if you are at the line that has the error, hovering over the red X in the left sidebar wil display the error message.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 11:36 AM
Quote:
Originally Posted by Freakin
What is the best way to learn general programming concepts? I don't even know what things like multiple inheritance or interfaces really are.

I'm about 6 months in to .NET and feel pretty comfortable, but I know I'm writing bad code.

I'm reading through Code Complete right now and learning RoR as well by reading Agile Web Development with Rails.
I guess what you meant to say is "learn OOP concepts". I can always recommend the timeless "Object-Oriented Software Construction" by Meyer.
"Object Oriented Design Heuristics" by Riel is also solid.
I had a OOP concepts/modelling etc. wild mix class (also included stuff like Aspect Oriented programming) at university that was roughly based on the two and picked them up (only own the Riel one) and it was a pretty great class. The prof was a SmallTalk guy himself so he took pure OOP concepts very seriously.

You should probably also know stuff about data structures (linked list, graphs etc) and maybe searching (depth first, breadth first, A* etc) and well algorithm design O-notation and whatnot can't hurt (Knuth stuff).

For data structures I think just reading through this
https://en.wikipedia.org/wiki/List_of_data_structures
And implementing stuff like linked lists yourself instead of using the library ones is the best way (then of course you'll use the library because your own stuff is going to suck :P).

Last edited by clowntable; 04-25-2012 at 11:42 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 12:00 PM
Couple of cool things I came across this morning:

The source code for the Apollo missions has been made publicly available: http://www.ibiblio.org/apollo/links.html

A camera that prints descriptions of the pictures you take. The genius is that it uses Amazons Mechanical Turk to get the descriptions, so they are actually human generated: http://mattrichardson.com/Descriptive-Camera/
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 02:23 PM
Quote:
Originally Posted by gaming_mouse
rt1, i think, linked to this book in another thread: http://www.amazon.com/Object-Oriente.../dp/020163385X

i'm almost done with it now, and it's pretty great for general OO stuff that you probably don't know, especially if you're new to programming. i've been doing it for years and still learned a lot.
Thanks for the recommendation! There are so many books out there it's hard to figure out what is worth reading.

Quote:
Originally Posted by tyler_cracker
i was going to say "read everything", but ryan's advice is a bit more practical . knowing that the thing you want to learn about is called e.g. "multiple inheritance" is a huge head start in a universe where google exists. once you've done some homework, ask questions in a community such as this one.

(pro tip: afaik the advice in the above paragraph can take you infinitely far in software engineering. stay tuned for updates.)
This is how I try to approach everything I do. One comment I have on most programming communities (this one included) is how *incredibly* helpful everyone is when you ask a well-formulated question. I think the public has an impression of programmers as unapproachable and egotistical, but I've found exactly the opposite. The patience and thoroughness given when answering questions just blows me away.

Quote:
bad news: this feeling basically never goes away.

good news: your definition of "bad" levels up with you. code you consider "bad" today becomes "wtf is this ****" in a year.
Yeah I'm already saying "wtf was I thinking" to code from just a few months ago. I have some projects I want to start over from scratch just so I can make them less terrible.

Quote:
Originally Posted by clowntable
I guess what you meant to say is "learn OOP concepts". I can always recommend the timeless "Object-Oriented Software Construction" by Meyer.
"Object Oriented Design Heuristics" by Riel is also solid.
I had a OOP concepts/modelling etc. wild mix class (also included stuff like Aspect Oriented programming) at university that was roughly based on the two and picked them up (only own the Riel one) and it was a pretty great class. The prof was a SmallTalk guy himself so he took pure OOP concepts very seriously.

You should probably also know stuff about data structures (linked list, graphs etc) and maybe searching (depth first, breadth first, A* etc) and well algorithm design O-notation and whatnot can't hurt (Knuth stuff).

For data structures I think just reading through this
https://en.wikipedia.org/wiki/List_of_data_structures
And implementing stuff like linked lists yourself instead of using the library ones is the best way (then of course you'll use the library because your own stuff is going to suck :P).
Implementing my own version of a data structure seems like a great way to learn them. Thanks for the tip!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 05:55 PM
Quote:
Originally Posted by Chips Ahoy
here's one good reason:
Code:
x = 3;
if(x = 5) LaunchNuclearMissiles();
haha, this had me loling. I now think it should be a requirement that every illustration of bad code ever requires a "LaunchNuclearMissiles()" function.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 06:02 PM
I like that idea

fun Python question: What does this code do?

Code:
True = False
if (1 == 1):
   LaunchNuclearMissles()
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 06:31 PM
This one should do the trick I think.
Code:
bool Alive = true; 
int Deg = 0; 
while(Alive) {
    LaunchNuclearMissles(Deg); 
    Deg++; 
    if(Deg >= 360)
         Deg = 0; 
}
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 06:38 PM
Infinite loop though. Fix:

Code:
volatile bool Alive
Also I prefer heading to Deg.

%= seems idiomatic but I don't care.

For the basic problem I always use
Code:
if(5 == x) ...
in languages where it matters. That way the compiler tells me when I do = by mistake.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 08:44 PM
If anyone is bored....

Code:
import java.awt.*;
import javax.swing.ImageIcon;
import javax.swing.JFrame;

public class JApp extends JFrame
{
	Image Image_Background; 
	Image Image_Picture; 
	
	public JApp(){}
	
	public static void main(String[] args)
	{
		JApp theApp = new JApp();
		theApp.OnExecute();
	}
	public void OnExecute()
	{
		OnInit();
		OnRender();
	}
	public void OnRender()
	{
		super.repaint(); 
	}
	public void OnInit()
	{
		super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		super.setSize(640,480);
		super.setLocationRelativeTo(null);
		super.setResizable(false);
		super.setTitle("test");
		super.setVisible(true);
		
		Image_Background = new ImageIcon("C:\\background.jpg").getImage();
		Image_Picture = new ImageIcon("C:\\Zelda.jpg").getImage();
		
	}
	public void paint(Graphics Graphics_Window)
	{
		Graphics_Window.drawImage(Image_Background,0,0,null);
		Graphics_Window.drawImage(Image_Picture,100,100,null);
	}
}
Where is Graphics_Window coming from? I cant understand what is going on there it does not look like it should work. I tried declaring my own instance of Graphics and passing it to paint, and also tried the same thing but passing it to a copy of void paint but I renamed the function to something else, both failed.

It looks like repaint is going back to super and making this Graphics object and then calling my paint function with it, but I would rather make the Graphics object myself but it is being stubborn.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 10:40 PM
That's just the way Swing is set up. If you are going to do custom painting, you have to use the Graphics instance passed to the class. However, If you have a static image, you can do the following:
Code:
JLabel imageLabel = new JLabel(new ImageIcon(imageInstance));
And then add the JLabel to the JFrame.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
04-25-2012 , 11:15 PM
Rich Hickey, creator of Clojure, talking to Lispers about Clojure:

http://********/clojure/clojure-for-...part-1-1319721
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m