As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

using(PennyArcade.Forum){Threads.push(ProgrammingThread())}

1575859606163»

Posts

  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited May 2010
    You can do almost everything you can do with macros, with template meta programming, and do it in a more syntax, scope and type safe way.

    There are a few exceptions to this, like Boosts PP iterator stuff, but for the most part, macros are bad and horrible.

    When a language feature routinely leads to bad programming, it becomes a bad language feature (see: goto).

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited May 2010
    MKR wrote: »
    HTML.cs:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    
    namespace Showbox
    {
        class HTML
        {
            //There's probably a better way to do this.
            private string basepath = Application.StartupPath.Replace(@"\", @"/") + "/";
            private string filename = "HTML/index.html";
    
            public string GenerateHTML(string title, string csspath, string body, string url)
            {
                //Generates an HTML document and returns it
                string generatedpath = @"file:///" + basepath + filename;
                
    
                //csspath will hold the location of the css used to generate pages
                //temporary indicates whether or not the file is temporary. May end up not
                //using it.
                
                //Add a check to create the file if it doesn't exist
                TextWriter w = new StreamWriter(Application.StartupPath + @"\HTML\index.html");
                
                //Build a simple HTML file
    
                string htmlfile = @"<html><head><title>";
                htmlfile = htmlfile + title + @"</title></head><body>";
                htmlfile = htmlfile + @"URL: " + url + "</body>";
    
                //write to file
                w.WriteLine(htmlfile);
                //close file
                w.Close();
                return generatedpath;
            }
    
            public void DeleteGeneratedHTML()
            {
                //Stub for a method that deletes a generated HTML file.
                //Used when the program starts and exits
            }
    
        }
    }
    

    The relevant methods:
    private void URLClicked(string url)
            {
                MessageBox.Show("Clicked a link");
            }
            private void tsReloadFeeds_Click(object sender, EventArgs e)
            {
                currenturl = Application.StartupPath.Replace(@"\", @"/");
                //Refresh all feeds
                //run a check to make sure something is selected
                lstFeeds.Items.Clear();
                RSS rss = new RSS();
                List<string> RSSList = rss.LoadRSS(Application.StartupPath.Replace(@"\", @"/") + "/Feeds.xml", 0);
                TitleList = rss.GetTitleList();
                URLList = rss.GetURLList();
                DescriptionList = rss.GetDescriptionList();
    
    
                List<int> count = new List<int>();
    
                count = rss.GetCount();
                int i = 0;
                while (i != URLList.Count)
                {
    
    
                    ListViewItem item = new ListViewItem(TitleList[i]);
    
                    item.SubItems.Add(URLList[i]);
                    item.SubItems.Add(CountList[i].ToString());
    
                    lstFeeds.Items.AddRange(new ListViewItem[] { item });
                    i++;
                }
    
                //test
                HTML generator = new HTML();
                //MessageBox.Show(generator.GenerateHTML("test", "buh", true));
                string thefile = generator.GenerateHTML(TitleList[i - 1], "no css", DescriptionList[i - 1], URLList[i - 1]);
                txtFeedContent.Navigate(thefile.Replace(@" ", @"%20"));
                //MessageBox.Show(thefile.Replace(@" ", @"%20"));
    
                currenturl = thefile;
            }
    
            private void txtFeedContent_Navigating(object sender, WebBrowserNavigatingEventArgs e)
            {
                //txtFeedContent.Url = URLList;
                //setting to the previous url to keep it from navigating
                //MessageBox.Show(e.Url.ToString());
                if(e.Url != new Uri(currenturl))
                {
                    e.Cancel = true;
                }
                //open link in default browser
                
            }
    

    The generated HTML and generated URL look correct when I have them show in a message box. There's no error when I click the link, only when I click the button that calls tsReloadFeeds_Click.

    edit: I forget that I took the onClick out of the anchor, but that's in the other post.

    Wait, is this a compile error on the C# side your getting, or a JavaScript error on the HTML side?

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    MKRMKR Registered User regular
    edited May 2010
    GnomeTank wrote: »
    MKR wrote: »
    HTML.cs:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    
    namespace Showbox
    {
        class HTML
        {
            //There's probably a better way to do this.
            private string basepath = Application.StartupPath.Replace(@"\", @"/") + "/";
            private string filename = "HTML/index.html";
    
            public string GenerateHTML(string title, string csspath, string body, string url)
            {
                //Generates an HTML document and returns it
                string generatedpath = @"file:///" + basepath + filename;
                
    
                //csspath will hold the location of the css used to generate pages
                //temporary indicates whether or not the file is temporary. May end up not
                //using it.
                
                //Add a check to create the file if it doesn't exist
                TextWriter w = new StreamWriter(Application.StartupPath + @"\HTML\index.html");
                
                //Build a simple HTML file
    
                string htmlfile = @"<html><head><title>";
                htmlfile = htmlfile + title + @"</title></head><body>";
                htmlfile = htmlfile + @"URL: " + url + "</body>";
    
                //write to file
                w.WriteLine(htmlfile);
                //close file
                w.Close();
                return generatedpath;
            }
    
            public void DeleteGeneratedHTML()
            {
                //Stub for a method that deletes a generated HTML file.
                //Used when the program starts and exits
            }
    
        }
    }
    

    The relevant methods:
    private void URLClicked(string url)
            {
                MessageBox.Show("Clicked a link");
            }
            private void tsReloadFeeds_Click(object sender, EventArgs e)
            {
                currenturl = Application.StartupPath.Replace(@"\", @"/");
                //Refresh all feeds
                //run a check to make sure something is selected
                lstFeeds.Items.Clear();
                RSS rss = new RSS();
                List<string> RSSList = rss.LoadRSS(Application.StartupPath.Replace(@"\", @"/") + "/Feeds.xml", 0);
                TitleList = rss.GetTitleList();
                URLList = rss.GetURLList();
                DescriptionList = rss.GetDescriptionList();
    
    
                List<int> count = new List<int>();
    
                count = rss.GetCount();
                int i = 0;
                while (i != URLList.Count)
                {
    
    
                    ListViewItem item = new ListViewItem(TitleList[i]);
    
                    item.SubItems.Add(URLList[i]);
                    item.SubItems.Add(CountList[i].ToString());
    
                    lstFeeds.Items.AddRange(new ListViewItem[] { item });
                    i++;
                }
    
                //test
                HTML generator = new HTML();
                //MessageBox.Show(generator.GenerateHTML("test", "buh", true));
                string thefile = generator.GenerateHTML(TitleList[i - 1], "no css", DescriptionList[i - 1], URLList[i - 1]);
                txtFeedContent.Navigate(thefile.Replace(@" ", @"%20"));
                //MessageBox.Show(thefile.Replace(@" ", @"%20"));
    
                currenturl = thefile;
            }
    
            private void txtFeedContent_Navigating(object sender, WebBrowserNavigatingEventArgs e)
            {
                //txtFeedContent.Url = URLList;
                //setting to the previous url to keep it from navigating
                //MessageBox.Show(e.Url.ToString());
                if(e.Url != new Uri(currenturl))
                {
                    e.Cancel = true;
                }
                //open link in default browser
                
            }
    

    The generated HTML and generated URL look correct when I have them show in a message box. There's no error when I click the link, only when I click the button that calls tsReloadFeeds_Click.

    edit: I forget that I took the onClick out of the anchor, but that's in the other post.

    Wait, is this a compile error on the C# side your getting, or a JavaScript error on the HTML side?

    It's the IE javascript error dialog. I should have been clearer. :P

    MKR on
  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited May 2010
    MKR wrote: »
    GnomeTank wrote: »
    MKR wrote: »
    HTML.cs:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    
    namespace Showbox
    {
        class HTML
        {
            //There's probably a better way to do this.
            private string basepath = Application.StartupPath.Replace(@"\", @"/") + "/";
            private string filename = "HTML/index.html";
    
            public string GenerateHTML(string title, string csspath, string body, string url)
            {
                //Generates an HTML document and returns it
                string generatedpath = @"file:///" + basepath + filename;
                
    
                //csspath will hold the location of the css used to generate pages
                //temporary indicates whether or not the file is temporary. May end up not
                //using it.
                
                //Add a check to create the file if it doesn't exist
                TextWriter w = new StreamWriter(Application.StartupPath + @"\HTML\index.html");
                
                //Build a simple HTML file
    
                string htmlfile = @"<html><head><title>";
                htmlfile = htmlfile + title + @"</title></head><body>";
                htmlfile = htmlfile + @"URL: " + url + "</body>";
    
                //write to file
                w.WriteLine(htmlfile);
                //close file
                w.Close();
                return generatedpath;
            }
    
            public void DeleteGeneratedHTML()
            {
                //Stub for a method that deletes a generated HTML file.
                //Used when the program starts and exits
            }
    
        }
    }
    

    The relevant methods:
    private void URLClicked(string url)
            {
                MessageBox.Show("Clicked a link");
            }
            private void tsReloadFeeds_Click(object sender, EventArgs e)
            {
                currenturl = Application.StartupPath.Replace(@"\", @"/");
                //Refresh all feeds
                //run a check to make sure something is selected
                lstFeeds.Items.Clear();
                RSS rss = new RSS();
                List<string> RSSList = rss.LoadRSS(Application.StartupPath.Replace(@"\", @"/") + "/Feeds.xml", 0);
                TitleList = rss.GetTitleList();
                URLList = rss.GetURLList();
                DescriptionList = rss.GetDescriptionList();
    
    
                List<int> count = new List<int>();
    
                count = rss.GetCount();
                int i = 0;
                while (i != URLList.Count)
                {
    
    
                    ListViewItem item = new ListViewItem(TitleList[i]);
    
                    item.SubItems.Add(URLList[i]);
                    item.SubItems.Add(CountList[i].ToString());
    
                    lstFeeds.Items.AddRange(new ListViewItem[] { item });
                    i++;
                }
    
                //test
                HTML generator = new HTML();
                //MessageBox.Show(generator.GenerateHTML("test", "buh", true));
                string thefile = generator.GenerateHTML(TitleList[i - 1], "no css", DescriptionList[i - 1], URLList[i - 1]);
                txtFeedContent.Navigate(thefile.Replace(@" ", @"%20"));
                //MessageBox.Show(thefile.Replace(@" ", @"%20"));
    
                currenturl = thefile;
            }
    
            private void txtFeedContent_Navigating(object sender, WebBrowserNavigatingEventArgs e)
            {
                //txtFeedContent.Url = URLList;
                //setting to the previous url to keep it from navigating
                //MessageBox.Show(e.Url.ToString());
                if(e.Url != new Uri(currenturl))
                {
                    e.Cancel = true;
                }
                //open link in default browser
                
            }
    

    The generated HTML and generated URL look correct when I have them show in a message box. There's no error when I click the link, only when I click the button that calls tsReloadFeeds_Click.

    edit: I forget that I took the onClick out of the anchor, but that's in the other post.

    Wait, is this a compile error on the C# side your getting, or a JavaScript error on the HTML side?

    It's the IE javascript error dialog. I should have been clearer. :P

    It has to be this: window.external.URLClicked('http://xkcd.com/744/')

    Try replacing that with something simple, like alert('Hello World'), see if that works, if the error goes away, it something to do with calling that function. I've never seen the window.external syntax before. It must be something special for the WebBrowser control?

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    LoneIgadzraLoneIgadzra Registered User regular
    edited May 2010
    So I've pretty much had it up to here with Java. It's like the platform that good documentation forgot. Yeah javadoc is a nice tool, if you actually use it or put the link to your javadoc some place mere mortals can find it. And I'm talking about official Sun stuff, particularly Java EE-related, not third party stuff. Though Sun tends more toward the hiding the documentation behind a sea of links none which look like they will take you to it (some of which take you to tutorials written in 1997 that are still considered authoritative), and third parties tend more toward the terse and useless.

    LoneIgadzra on
  • Options
    MKRMKR Registered User regular
    edited May 2010
    GnomeTank wrote: »
    MKR wrote: »
    GnomeTank wrote: »
    MKR wrote: »
    HTML.cs:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    
    namespace Showbox
    {
        class HTML
        {
            //There's probably a better way to do this.
            private string basepath = Application.StartupPath.Replace(@"\", @"/") + "/";
            private string filename = "HTML/index.html";
    
            public string GenerateHTML(string title, string csspath, string body, string url)
            {
                //Generates an HTML document and returns it
                string generatedpath = @"file:///" + basepath + filename;
                
    
                //csspath will hold the location of the css used to generate pages
                //temporary indicates whether or not the file is temporary. May end up not
                //using it.
                
                //Add a check to create the file if it doesn't exist
                TextWriter w = new StreamWriter(Application.StartupPath + @"\HTML\index.html");
                
                //Build a simple HTML file
    
                string htmlfile = @"<html><head><title>";
                htmlfile = htmlfile + title + @"</title></head><body>";
                htmlfile = htmlfile + @"URL: " + url + "</body>";
    
                //write to file
                w.WriteLine(htmlfile);
                //close file
                w.Close();
                return generatedpath;
            }
    
            public void DeleteGeneratedHTML()
            {
                //Stub for a method that deletes a generated HTML file.
                //Used when the program starts and exits
            }
    
        }
    }
    

    The relevant methods:
    private void URLClicked(string url)
            {
                MessageBox.Show("Clicked a link");
            }
            private void tsReloadFeeds_Click(object sender, EventArgs e)
            {
                currenturl = Application.StartupPath.Replace(@"\", @"/");
                //Refresh all feeds
                //run a check to make sure something is selected
                lstFeeds.Items.Clear();
                RSS rss = new RSS();
                List<string> RSSList = rss.LoadRSS(Application.StartupPath.Replace(@"\", @"/") + "/Feeds.xml", 0);
                TitleList = rss.GetTitleList();
                URLList = rss.GetURLList();
                DescriptionList = rss.GetDescriptionList();
    
    
                List<int> count = new List<int>();
    
                count = rss.GetCount();
                int i = 0;
                while (i != URLList.Count)
                {
    
    
                    ListViewItem item = new ListViewItem(TitleList[i]);
    
                    item.SubItems.Add(URLList[i]);
                    item.SubItems.Add(CountList[i].ToString());
    
                    lstFeeds.Items.AddRange(new ListViewItem[] { item });
                    i++;
                }
    
                //test
                HTML generator = new HTML();
                //MessageBox.Show(generator.GenerateHTML("test", "buh", true));
                string thefile = generator.GenerateHTML(TitleList[i - 1], "no css", DescriptionList[i - 1], URLList[i - 1]);
                txtFeedContent.Navigate(thefile.Replace(@" ", @"&#37;20"));
                //MessageBox.Show(thefile.Replace(@" ", @"%20"));
    
                currenturl = thefile;
            }
    
            private void txtFeedContent_Navigating(object sender, WebBrowserNavigatingEventArgs e)
            {
                //txtFeedContent.Url = URLList;
                //setting to the previous url to keep it from navigating
                //MessageBox.Show(e.Url.ToString());
                if(e.Url != new Uri(currenturl))
                {
                    e.Cancel = true;
                }
                //open link in default browser
                
            }
    

    The generated HTML and generated URL look correct when I have them show in a message box. There's no error when I click the link, only when I click the button that calls tsReloadFeeds_Click.

    edit: I forget that I took the onClick out of the anchor, but that's in the other post.

    Wait, is this a compile error on the C# side your getting, or a JavaScript error on the HTML side?

    It's the IE javascript error dialog. I should have been clearer. :P

    It has to be this: window.external.URLClicked('http://xkcd.com/744/')

    Try replacing that with something simple, like alert('Hello World'), see if that works, if the error goes away, it something to do with calling that function. I've never seen the window.external syntax before. It must be something special for the WebBrowser control?

    From what I read it's supposed to call a method in the calling class. I don't get any error with alert(), but I also don't get a popup.

    So I've pretty much had it up to here with Java. It's like the platform that good documentation forgot. Yeah javadoc is a nice tool, if you actually use it or put the link to your javadoc some place mere mortals can find it. And I'm talking about official Sun stuff, particularly Java EE-related, not third party stuff.

    Come over the to dark side. .NET calls to you.

    MKR on
  • Options
    syndalissyndalis Getting Classy On the WallRegistered User, Loves Apple Products regular
    edited May 2010
    Jasconius wrote: »
    You are putting NSMutableArrays into your parent array, but when you retrieve them in your table methods you are trying to assign them to NSDictionary ... why?

    hahaha, scratch that, I never fixed NSDictionary (which is how the project I borrowed from handled its data) and that was the problem.

    Now, I have a new and interesting problem... this is the code that is compiling and working as intended:
    #pragma mark Table view methods
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return [entityArrayCharacter count];
    //	NSLog(@"&#37;i",[entityArrayCharacter count]);
    }
    
    - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    	
    	if(section == 0)
    		return @"Classes";
    	else if(section == 1)
    		return @"Races";
    	else {
    		return @"Powers";
    	}
    
    }
    
    // Customize the number of rows in the table view.
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    	
    //Number of rows it should expect should be based on the section
    NSMutableArray *array = [self.entityArrayCharacter objectAtIndex:section];
    return [array count];
    
    }
    
    // Customize the appearance of table view cells.
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    	NSMutableArray *array = [entityArrayCharacter objectAtIndex:indexPath.row];
    
    		static NSString *CellIdentifier = @"Cell";
    		
    		UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    		if (cell == nil) {
    			cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    		}
    		
    	NSManagedObject *object = (NSManagedObject *)[array objectAtIndex:indexPath.row];
    
    		cell.text = [object valueForKey:@"Name"];
    		
    		return cell;
    	}
    

    Or so it would seem. There is a weird issue afoot regarding cell identity, and the following "character", who is currently being built weird will prove that point.

    He has one character class, two character races, and three powers.

    Each section in the tableView seems to be repeating the label (if not the contents altogether) of the item at row 0, row 1, etc, until there is a unique item in the section, at which point it takes its data from the section in question. Look at this image for clarification:

    4D4Z

    As you can see, the First section is fine, the second section has Fighter overwriting what SHOULD say Dragonborn, and the third section has the first two powers overwritten by the First and second items from the second section.

    This is stumping me.

    syndalis on
    SW-4158-3990-6116
    Let's play Mario Kart or something...
  • Options
    MKRMKR Registered User regular
    edited May 2010
    That looks so much like C#, which is a straight rip of Java + some nice frills.

    So much borrowing in this industry.

    MKR on
  • Options
    syndalissyndalis Getting Classy On the WallRegistered User, Loves Apple Products regular
    edited May 2010
    MKR wrote: »
    That looks so much like C#, which is a straight rip of Java + some nice frills.

    So much borrowing in this industry.
    If you are talking my code, objective-C has been around the block for quite a while... Early 80s I believe.

    That said, it has been extended and built upon with concepts clearly derived from more modern OOP environments.

    The world of programming languages is very incestuous.

    syndalis on
    SW-4158-3990-6116
    Let's play Mario Kart or something...
  • Options
    EndEnd Registered User regular
    edited May 2010
    GnomeTank wrote: »
    There is no point, at all, except wanting to be a crusty old codger who still thinks the pre-processor is a great idea.

    Hm? I can't imagine programming C or C++ without the pre-processor.

    (Actually, I can imagine it, but they're not designed real well to work without it.)

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Options
    templewulftemplewulf The Team Chump USARegistered User regular
    edited May 2010
    Who said "MUMPS"? Who said it, you awful son of a bitch!?

    @syndalis:
    Your app already looks awesome, as we could all use a little more 4e. Obj-C looks so crazy to me, but I've heard that Android runs on crazy-java, so I guess I'll be in for a similar experience with my new phone too.

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • Options
    LoneIgadzraLoneIgadzra Registered User regular
    edited May 2010
    MKR wrote: »
    So I've pretty much had it up to here with Java. It's like the platform that good documentation forgot. Yeah javadoc is a nice tool, if you actually use it or put the link to your javadoc some place mere mortals can find it. And I'm talking about official Sun stuff, particularly Java EE-related, not third party stuff.

    Come over the to dark side. .NET calls to you.

    Been there, still there. It's not bad but the Visual Studio documentation browser is an inscrutable POS that I still haven't figured out how to use to look up a class without getting 100 forum discussions and 20 references to different versions of .NET and as many examples in terrible languages that I don't care about. (I know you can uncheck all that stuff, but the checks always seem to come back and there are like 50 of them and I don't know what most of them even are.) And then when I finally get there every other word that matches my search phrase is highlighted, making the document impossible to read. Hitting F1 on a class name is about the only way it's useful. I wish hitting F1 on a variable name worked, because sometimes it's a pain to backtrack all the way to its declaration.

    The web site is okay, but leaves something to be desired. Working with the hierarchical pane on the left is particularly frustrating unless you switch to minimal view.

    At least the documentation isn't secret.

    LoneIgadzra on
  • Options
    MKRMKR Registered User regular
    edited May 2010
    MKR wrote: »
    So I've pretty much had it up to here with Java. It's like the platform that good documentation forgot. Yeah javadoc is a nice tool, if you actually use it or put the link to your javadoc some place mere mortals can find it. And I'm talking about official Sun stuff, particularly Java EE-related, not third party stuff.

    Come over the to dark side. .NET calls to you.

    Been there, still there. It's not bad but the Visual Studio documentation browser is an inscrutable POS that I still haven't figured out how to use to look up a class without getting 100 forum discussions and 20 references to different versions of .NET and as many examples in terrible languages that I don't care about. (I know you can uncheck all that stuff, but the checks always seem to come back and there are like 50 of them and I don't know what most of them even are.) And then when I finally get there every other word that matches my search phrase is highlighted, making the document impossible to read. Hitting F1 on a class name is about the only way it's useful. I wish hitting F1 on a variable name worked, because sometimes it's a pain to backtrack all the way to its declaration.

    The web site is okay, but leaves something to be desired. Working with the hierarchical pane on the left is particularly frustrating unless you switch to minimal view.

    At least the documentation isn't secret.

    I always go straight to MSDN or StackOverflow. I don't think C# Express has any sort of documentation browser, so I'm not 100% sure of what you're referring to.

    MKR on
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited May 2010
    syndalis wrote: »
    MKR wrote: »
    That looks so much like C#, which is a straight rip of Java + some nice frills.

    So much borrowing in this industry.
    If you are talking my code, objective-C has been around the block for quite a while... Early 80s I believe.

    That said, it has been extended and built upon with concepts clearly derived from more modern OOP environments.

    The world of programming languages is very incestuous.

    I can't tell for sure, thanks to lack of code highlighiting, but it appears that you are plucking your ARRAY out of the parent array using the row number, instead of the section number, with indexPath.row

    If you put a 4th row in that last section I bet it would just crash.

    You need to be pulling the section property from indexPath, not the row.

    Jasconius on
  • Options
    syndalissyndalis Getting Classy On the WallRegistered User, Loves Apple Products regular
    edited May 2010
    Jasconius wrote: »
    syndalis wrote: »
    MKR wrote: »
    That looks so much like C#, which is a straight rip of Java + some nice frills.

    So much borrowing in this industry.
    If you are talking my code, objective-C has been around the block for quite a while... Early 80s I believe.

    That said, it has been extended and built upon with concepts clearly derived from more modern OOP environments.

    The world of programming languages is very incestuous.

    I can't tell for sure, thanks to lack of code highlighiting, but it appears that you are plucking your ARRAY out of the parent array using the row number, instead of the section number, with indexPath.row

    If you put a 4th row in that last section I bet it would just crash.

    You need to be pulling the section property from indexPath, not the row.

    you are a flippin' genius! Thanks, dude.

    syndalis on
    SW-4158-3990-6116
    Let's play Mario Kart or something...
  • Options
    HalibutHalibut Passion Fish Swimming in obscurity.Registered User regular
    edited May 2010
    MKR wrote: »
    So I've pretty much had it up to here with Java. It's like the platform that good documentation forgot. Yeah javadoc is a nice tool, if you actually use it or put the link to your javadoc some place mere mortals can find it. And I'm talking about official Sun stuff, particularly Java EE-related, not third party stuff.

    Come over the to dark side. .NET calls to you.

    Been there, still there. It's not bad but the Visual Studio documentation browser is an inscrutable POS that I still haven't figured out how to use to look up a class without getting 100 forum discussions and 20 references to different versions of .NET and as many examples in terrible languages that I don't care about. (I know you can uncheck all that stuff, but the checks always seem to come back and there are like 50 of them and I don't know what most of them even are.) And then when I finally get there every other word that matches my search phrase is highlighted, making the document impossible to read. Hitting F1 on a class name is about the only way it's useful. I wish hitting F1 on a variable name worked, because sometimes it's a pain to backtrack all the way to its declaration.

    The web site is okay, but leaves something to be desired. Working with the hierarchical pane on the left is particularly frustrating unless you switch to minimal view.

    At least the documentation isn't secret.

    The problem with JavaDocs (and any other code-centric, automatically-generated documentation) is that it only tells you how to use the specific method or class (API), and doesn't tell you how to use the framework/library as a whole. For that type of documentation, you have to look for tutorials/examples or articles or get a good reference book, which can be a real pain.

    For the most part, I have found Sun's Javadoc documentation to be very good, especially if you use an IDE that can automatically link references in your source code to the appropriate Javadoc. The problem, especially in the JEE world, is that there are a lot of other things you need to do besides call the correct methods. There's web.xml, manifests, application.xml, the WAR/EAR/EJB-JAR structures themselves. And on top of that there's configuration on the container side.

    Once you've done one or two apps, it becomes second nature, but until then it's a trial by fire kind of experience trying to get your webapp running.

    I would recommend using something like Maven's archetype system to handle setting up all of that stuff for you, or maybe even a productivity tool like Spring Roo (which uses Maven to simplify some stuff under the hood). Or, you can give up on Java entirely and move to something simpler and more current like RoR or Django, it just depends on what your project needs are.

    Halibut on
  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited May 2010
    End wrote: »
    GnomeTank wrote: »
    There is no point, at all, except wanting to be a crusty old codger who still thinks the pre-processor is a great idea.

    Hm? I can't imagine programming C or C++ without the pre-processor.

    (Actually, I can imagine it, but they're not designed real well to work without it.)

    I'm not talking about cases where the pre-processor actually makes some sort of sense (#includes, some basic compiler configuration #defines, #pragmas if your environment supports them).

    I'm talking about:
    #define SOME_MACRO(x) \
         if((x) == 10)  {\
            doSomeRandomShit(); \
        }
    

    That is evil, and should never be encouraged except in extremely rare edge cases (see the Boost PP iterator stuff I talked about before).

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    InfidelInfidel Heretic Registered User regular
    edited May 2010
    That I can agree with GnomeTank.

    The exceptions are, like you mention, structural/framework macros. Your application shouldn't have it's own code as macros for no good reason.

    Infidel on
    OrokosPA.png
  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited May 2010
    MKR wrote: »
    That looks so much like C#, which is a straight rip of Java + some nice frills.

    So much borrowing in this industry.

    C# may have borrowed from Java, but it's evolved far beyond Java as a language. I program in both regularly, and C# has a lot of modern facilities that Java either completely lacks, or does in such a ham-fisted way it makes you want to scream. It's not that Java is a bad language (it's not), it's just that the Java standards team seems completely unwilling to bring in really ground breaking features, or to fix some lingering idiosyncrasies of the language. C# and Python, to me, are the bench marks for how a language should be written and maintained. Frequent updates, and a willingness to add new features and make old kludgyness easier to work with.

    (To give Java it's due, it actually did jump C# in one feature: Generic co/contravariance, which it had almost a year before C# did).

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    EtheaEthea Registered User regular
    edited May 2010
    bah calling all macros evil is very heavy handed. But that might be because I work with C++ code that uses macros every day for at least:
    • ObjectFactory
    • Object Reference Counting
    • Object Set/Get Macros

    Ethea on
  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited May 2010
    Ethea wrote: »
    bah calling all macros evil is very heavy handed. But that might be because I work with C++ code that uses macros every day for at least:
    • ObjectFactory
    • Object Reference Counting
    • Object Set/Get Macros

    And everyone of those cases could be handled by a template function/class in a much more type-safe, compiler friendly way. Just sayin'.

    Obviously if you work with an existing code base full of macros, then that's life...but if you are writing new code and doing it...for shame.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    InfidelInfidel Heretic Registered User regular
    edited May 2010
    GnomeTank wrote: »
    Ethea wrote: »
    bah calling all macros evil is very heavy handed. But that might be because I work with C++ code that uses macros every day for at least:
    • ObjectFactory
    • Object Reference Counting
    • Object Set/Get Macros

    And everyone of those cases could be handled by a template function/class in a much more type-safe, compiler friendly way. Just sayin'.

    Obviously if you work with an existing code base full of macros, then that's life...but if you are writing new code and doing it...for shame.

    Yeah, I'm not seeing why you would need to use macros or find it desirable. You can use macros of course but that's our point, many times you shouldn't. :D

    Infidel on
    OrokosPA.png
  • Options
    MKRMKR Registered User regular
    edited May 2010
    GnomeTank wrote: »
    MKR wrote: »
    That looks so much like C#, which is a straight rip of Java + some nice frills.

    So much borrowing in this industry.

    C# may have borrowed from Java, but it's evolved far beyond Java as a language. I program in both regularly, and C# has a lot of modern facilities that Java either completely lacks, or does in such a ham-fisted way it makes you want to scream. It's not that Java is a bad language (it's not), it's just that the Java standards team seems completely unwilling to bring in really ground breaking features, or to fix some lingering idiosyncrasies of the language. C# and Python, to me, are the bench marks for how a language should be written and maintained. Frequent updates, and a willingness to add new features and make old kludgyness easier to work with.

    (To give Java it's due, it actually did jump C# in one feature: Generic co/contravariance, which it had almost a year before C# did).

    I remember trying Java and several IDEs, and was frustrated to no end. Meanwhile, C# has VS, VS Express, SharpDevelop, and MonoDevelop, all of which are very easy to use.

    I think I managed to get a window with a button that popped up a box in Java once, but I never could figure it out again.

    MKR on
  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited May 2010
    This is why I hate MFC with a god damn passion. It's actually a halfway decent GUI toolkit, especially with VS2010 and the new features (theme manager, ribbon bar)...but god damn if it isn't a macro hell pit.

    If they ever did an "MFC2" that was all template based (they tried this, WTL, which was the hands down the best Win32 wrapper I ever used, but they dropped support for it), I would actually use it.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited May 2010
    Also, new thread time? Anyone want to do the honors? If not, I guess I can.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    EtheaEthea Registered User regular
    edited May 2010
    GnomeTank wrote: »
    Ethea wrote: »
    bah calling all macros evil is very heavy handed. But that might be because I work with C++ code that uses macros every day for at least:
    • ObjectFactory
    • Object Reference Counting
    • Object Set/Get Macros

    And everyone of those cases could be handled by a template function/class in a much more type-safe, compiler friendly way. Just sayin'.

    Obviously if you work with an existing code base full of macros, then that's life...but if you are writing new code and doing it...for shame.

    The code base was initial written in the early 90's by programmers that had little experience with meta-programming.

    Ethea on
  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited May 2010
    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    InfidelInfidel Heretic Registered User regular
    edited May 2010
    New thread time.

    Someone else always gets to it before I get unlazy enough. :lol:

    edit: see?

    Infidel on
    OrokosPA.png
  • Options
    EndEnd Registered User regular
    edited May 2010
    Ethea wrote: »
    GnomeTank wrote: »
    Ethea wrote: »
    bah calling all macros evil is very heavy handed. But that might be because I work with C++ code that uses macros every day for at least:
    • ObjectFactory
    • Object Reference Counting
    • Object Set/Get Macros

    And everyone of those cases could be handled by a template function/class in a much more type-safe, compiler friendly way. Just sayin'.

    Obviously if you work with an existing code base full of macros, then that's life...but if you are writing new code and doing it...for shame.

    The code base was initial written in the early 90's by programmers that had little experience with meta-programming.

    To be fair, I don't think a lot of that sort of stuff went into C++ before 1994.

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Options
    LoneIgadzraLoneIgadzra Registered User regular
    edited May 2010
    Halibut wrote: »
    MKR wrote: »
    So I've pretty much had it up to here with Java. It's like the platform that good documentation forgot. Yeah javadoc is a nice tool, if you actually use it or put the link to your javadoc some place mere mortals can find it. And I'm talking about official Sun stuff, particularly Java EE-related, not third party stuff.

    Come over the to dark side. .NET calls to you.

    Been there, still there. It's not bad but the Visual Studio documentation browser is an inscrutable POS that I still haven't figured out how to use to look up a class without getting 100 forum discussions and 20 references to different versions of .NET and as many examples in terrible languages that I don't care about. (I know you can uncheck all that stuff, but the checks always seem to come back and there are like 50 of them and I don't know what most of them even are.) And then when I finally get there every other word that matches my search phrase is highlighted, making the document impossible to read. Hitting F1 on a class name is about the only way it's useful. I wish hitting F1 on a variable name worked, because sometimes it's a pain to backtrack all the way to its declaration.

    The web site is okay, but leaves something to be desired. Working with the hierarchical pane on the left is particularly frustrating unless you switch to minimal view.

    At least the documentation isn't secret.

    The problem with JavaDocs (and any other code-centric, automatically-generated documentation) is that it only tells you how to use the specific method or class (API), and doesn't tell you how to use the framework/library as a whole. For that type of documentation, you have to look for tutorials/examples or articles or get a good reference book, which can be a real pain.

    For the most part, I have found Sun's Javadoc documentation to be very good, especially if you use an IDE that can automatically link references in your source code to the appropriate Javadoc. The problem, especially in the JEE world, is that there are a lot of other things you need to do besides call the correct methods. There's web.xml, manifests, application.xml, the WAR/EAR/EJB-JAR structures themselves. And on top of that there's configuration on the container side.

    Once you've done one or two apps, it becomes second nature, but until then it's a trial by fire kind of experience trying to get your webapp running.

    I would recommend using something like Maven's archetype system to handle setting up all of that stuff for you, or maybe even a productivity tool like Spring Roo (which uses Maven to simplify some stuff under the hood). Or, you can give up on Java entirely and move to something simpler and more current like RoR or Django, it just depends on what your project needs are.

    That's it in a nutshell. I use java basically because I'm being paid to. For my personal shit, I'll take Django or something where finding the documentations or tutorials written in the last decade isn't like being an archeologist. (RoR never made much sense to me, from a conceptual standpoint, though I only ever did the most basic tutorials. I love Django because the ways in which it does what it does - which is a lot - are immediately intuitive and transparent.)

    LoneIgadzra on
  • Options
    DeathPrawnDeathPrawn Registered User regular
    edited May 2010
    Anyone here familiar with the Google maps API? I've got an idea for a project to automate some boring stuff I have to do every now and then and was wondering if it's possible to feed lists of partial addresses (usually missing city and zip code) and retrieving the full address instead of having to do it one by one by copy and paste.

    If you haven't figured this out yet, it's a pretty straight-forward task using their geolocation API. It's been a while since I've used it, but you might have to geolocate the addresses and then reverse geolocate them (i.e. turn the addresses into lat/long coords, then back again).

    DeathPrawn on
    Signature not found.
  • Options
    His CorkinessHis Corkiness Registered User regular
    edited May 2010
    Infidel wrote: »
    GnomeTank wrote: »
    Ethea wrote: »
    bah calling all macros evil is very heavy handed. But that might be because I work with C++ code that uses macros every day for at least:
    • ObjectFactory
    • Object Reference Counting
    • Object Set/Get Macros

    And everyone of those cases could be handled by a template function/class in a much more type-safe, compiler friendly way. Just sayin'.

    Obviously if you work with an existing code base full of macros, then that's life...but if you are writing new code and doing it...for shame.

    Yeah, I'm not seeing why you would need to use macros or find it desirable. You can use macros of course but that's our point, many times you shouldn't. :D
    I've actually run across a case where a macro makes code safer. I'm writing a plugin-based system, and as part of that, I need to get the address of a function by passing its name to GetProcAddress (edit: dlsym on Linux, I guess). If I don't want to restrict a plugin to only use a specific name for this function (and therefore only one of these functions per DLL), the name ultimately needs to come from the plugin writer themself. I could let the author pass a string containing the name of the function (and potentially misspell it or give the wrong function name), or I could let them pass the function itself and stringify it:
    #define REGISTER_FACTORY(FACTORY_FUNC) registerFactory(#FACTORY_FUNC, (FACTORY_FUNC));
    
    (I've omitted parts of it to make it simpler)

    That macro passes its arguments off to a template function that performs type-checking to ensure that FACTORY_FUNC is of the right type. Assuming the author uses that macro, then, it's impossible for them to supply an invalid name. If this checking weren't done, we wouldn't know it was invalid until runtime.

    (I think so, anyway)

    His Corkiness on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited May 2010
    Infidel wrote: »
    GnomeTank wrote: »
    Ethea wrote: »
    bah calling all macros evil is very heavy handed. But that might be because I work with C++ code that uses macros every day for at least:
    • ObjectFactory
    • Object Reference Counting
    • Object Set/Get Macros

    And everyone of those cases could be handled by a template function/class in a much more type-safe, compiler friendly way. Just sayin'.

    Obviously if you work with an existing code base full of macros, then that's life...but if you are writing new code and doing it...for shame.

    Yeah, I'm not seeing why you would need to use macros or find it desirable. You can use macros of course but that's our point, many times you shouldn't. :D
    I've actually run across a case where a macro makes code safer. I'm writing a plugin-based system, and as part of that, I need to get the address of a function by passing its name to GetProcAddress (edit: dlsym on Linux, I guess). If I don't want to restrict a plugin to only use a specific name for this function (and therefore only one of these functions per DLL), the name ultimately needs to come from the plugin writer themself. I could let the author pass a string containing the name of the function (and potentially misspell it or give the wrong function name), or I could let them pass the function itself and stringify it:
    #define REGISTER_FACTORY(FACTORY_FUNC) registerFactory(#FACTORY_FUNC, (FACTORY_FUNC));
    
    (I've omitted parts of it to make it simpler)

    That macro passes its arguments off to a template function that performs type-checking to ensure that FACTORY_FUNC is of the right type. Assuming the author uses that macro, then, it's impossible for them to supply an invalid name. If this checking weren't done, we wouldn't know it was invalid until runtime.

    (I think so, anyway)

    We're talking more about using macros as if they were inline functions and riddled with macro expansion side effects.

    edit: you shouldn't have a semicolon on the end there but that's probably just a mistake from memory?

    Infidel on
    OrokosPA.png
  • Options
    His CorkinessHis Corkiness Registered User regular
    edited May 2010
    Infidel wrote: »
    edit: you shouldn't have a semicolon on the end there but that's probably just a mistake from memory?
    You're right, but as it returns void (and therefore probably won't be used in compound statements) I don't think it would've been likely to be a problem. I'll still change it. I don't use macros much. :)

    His Corkiness on
  • Options
    EndEnd Registered User regular
    edited May 2010
    Infidel wrote: »
    We're talking more about using macros as if they were inline functions and riddled with macro expansion side effects.

    I don't think that qualification was actually made.

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
Sign In or Register to comment.