Jump to content
Xtreme .Net Talk

alreadyused

Avatar/Signature
  • Posts

    70
  • Joined

  • Last visited

Everything posted by alreadyused

  1. goodbye binary? one other semi-related comment, I read an article back in '04 about programmable processors, a technology nicknamed spintronics. The basic idea behind it is that rather than using a charge to flip an electron from on to off, thus creating heat due to the arc or flip, a magnet is used instead to control its phase, and the phase is then measured. In 2004, they were able to accurately measure the phase to a precision of 16 positions. Using the magnetic field to flip it reduces heat, and measuring its phase in positions, rather than checking if it's on or off, obviously leads to more powerful processors consuming less power and space. Another benefit to it was that processors could then be programmed on the fly. The article I originally read stated that this would be extremely attractive to cell phone mfgrs. It went on to say that a specific cell phone company was going to try to test it in a phone in Europe. Based on what I read today, that doesn't seem to have happened, at least not in 2004. But the article I listed at the bottom in #4 does state this is more easily achievable in "gallium arsenide, which is used in cell phones." Anyway the whole point behind this ramble is that the first thing that came to my mind was that if a chip can measure to 16 positions at that time, and presumably many more down the road, what does that do to binary? Originally that made me think ok, if processors can measure to 16 positions, can we really make binary obsolete, or at least not the underlying technology? The data storage seemed to be an obstacle to me. But reading now that spintronics is currently being explored for new data storage methods leads me to believe that processors and storage devices would be able to both operate on the same model. In other words, am I presuming too much to think that we're not too far off from ditching binary for the most common things, that processing and storage are soon no longer limited by 1s and 0s? Sure there will always be the true/false, or as TheDailyWTF displays sometimes true/false/maybe or true/false/reallytrue/reallyfalse, but can we eventually get away from that? That's a really long ramble to say that hopefully in the future, this problem of my 0.09 != the computer's 0.09 in a floating POV goes away. Some links and more info: Wikipedia has an article on it stating its currently being explored in the design of new data storage methods IBM has a chip history for 2004 with references about it here: http://www.ibm.com/developerworks/library/pa-yearend.html I believe the article I first read was in Scientific America and I know I saved it; I remember the cover said something about 10 Einstein theories, and where we are today, but I can't find it anywhere. This may be the article (not sure, I'm too cheap to buy it) because the pics on the left side look familiar... pic #4 shows the concepts of the different layers: http://www.sciam.com/article.cfm?id=0007A735-759A-1CDD-B4A8809EC588EEDF Article on the status in '07, showing a silicon chip capable of crudely measuring it: http://www.sciam.com/article.cfm?id=spintronics-breaks-the-silicon-barrier
  2. wow, thanks all! Since this is Random thoughts, I have a side note for Marble... I switched to Dvorak around November, thanks to your comment! I had heard about it a long time ago but never paid much attention. But I absolutely love it, it's a shame it's not not more widely taught or accepted! Nerseus, I never would have guessed, and likewise probably never caught, that the rounding would alternate... that violates everything I've ever known about rounding. Marble + Mr Paul, thanks for the tips, I'm reworking all open solutions now, and I guess this means I'm going to have to go back and check all the existing code I have that's out. I'm mostly (something around 90% prolly) self-taught. I've taken some classes and read a lot of books and online tutorials etc, so most likely this is something I didn't read about, or didn't pay attention to. Scary, but I guess hopefully it didn't cause an error (yet) in any of my old code, because I haven't heard about it yet. Maybe this a dumb question, or another lesson I didn't learn, but this basically comes from memory optimization, trying to fit a float into one byte? With the availability of memory these days, would it be the end of the world to represent it with two bytes, where one represents the number (9 is very easy to represent in one byte) and the second represents the decimal position? Or are floats too widely used to be able to handle that?
  3. Re: Maybe you flunked computer science? gotcha, nice example, thanks for the feedback! So what do I do to avoid errors? Luckily we're not dealing with $s, so 1/100 isn't going to make a difference in the end for this app. Right now I'm letting, using the values given, 0.25+0.09 = 0.3399....7, but when I go to store it, the function that handles doubles rounds it to two decimals. I'm thinking that'll take care of us here... should I mention we're building a space shuttle??? Just kidding.
  4. One more note, we recompiled and still got the same error... at least it's consistent. I've added a stupid Round function to my object for every double, I'm sure that's going to come back to bite us though...
  5. Just a note (maybe I flunked logic school) after posting this we tried: ?0.25+0.1 0.35 ?0.25+0.09 0.33999999999999997 ?0.26+0.08 0.34 So it seems like we found a magic number... I get a cookie, right???
  6. Not sure this is the right area, but this is pretty random. :D I'm running C# 2005, and was debugging the code and found that 0.09 + 0.25 returns: 0.33999999999999997 So just to test it and make sure I had the precision right, I went to the immediate window and did: ?0.25+0.09 0.33999999999999997 :-\ And that wasn't enough, so I rounded the numbers to make sure it knew there were only two decimals... ?System.Math.Round(0.25,2) + System.Math.Round(0.09,2); 0.33999999999999997 :confused: Now I know that if I round it AFTER I add them, it'll give me what I want, but why should I have to do that? Anyone else seen this? And who do I yell at, Intel or Microsoft??? I knew I wanted an AMD...:mad:
  7. First off I hope I am posting this to the right forum. We're using external apps and communicating through their dlls, so I think this is in the right spot. We have a console app that automates printing; the user sends a list of requests, then the app retreives the docs, creates the appropriate class for that type of doc, does some work to it, then prints to the requested printer. We have a main class that communicates with the other classes to perform the work (one finds/holds/tests the external app instances, one is a factory for creating the appropriate worker class, etc) We have a sub main that launches the main class. We need the app to persist, and want the user to be able to type exit, but we also want to send the status to the console. So this is what we had: Public Shared Sub Main(args() as String) '... Dim myClass as new MyClass() myClass.doSomeStuff '... Dim doExit as boolean = false Do Dim s As String = System.Console.ReadLine() If s.ToLower() = "exit" Then doExit = True Loop Until doExit 'finalize '... End Sub Up until recently, this was working fine. But then we added a VB6 app into the mix, and we started getting the non-pumping error. I immediately assumed that it was because of that loop and ReadLine. To me what it was saying is that we're blocking the main thread and that's causing issues. I guess at this point, it's obvious that I'm weak on threading, right? :( By adding a reference to System.Windows.Forms and then adding Application.Run() into the Do Loop, we have worked around it and the error goes away. But, I have this nagging suspicion that this isn't the best way to do it and it's going to sneak up and bite us later. Is there a better way to do it? Or a tutorial I need to read/do? ----------------------------- EDIT: I just found out that because of the Application.Run() statement, the loop is no longer effective. That's not a big deal, it was only there to keep the application alive anyway. So now the app persists until a ctrl+c, alt+f4, ... I read something on here yesterday that when doing an Application.Exit(), it still tries to call the dispose methods, we just may not see it while debugging, but it's not safe to rely on that. I'm not calling app.exit, but I'm assuming that the above are the equivalent to doing so? So I still have the question of, does anyone have any suggestions on what would be better?
  8. Well that did it! Thanks for the tip! (and thanks for changing my code tags, I couldn't remember what tag to use to get the formatting) There was one small thing that I ran into. When I dropped the interface name prefix and compiled, the error was saying that I was not implementing the method. But I found this post: http://www.xtremedotnettalk.com/showthread.php?t=97057&highlight=implicit+interface that stated to use it implicitly, you must declare it public, and that solved it. Anyway I'm putting this here in case someone else has this problem too (but it's probably just me :D ) // explicit: void MyInterface.myMethod(string a, string b){} // implicit but causes compile error - not implementing: void myMethod(string a, string b){} // implicit and compiles - stating public is required public void myMethod(string a, string b){} thanks again!
  9. I am trying to learn more c# and I'm having an issue. I managed to get it to work but I want to know if there's a better way. I have an interface in a common namespace, and a class that uses that in an application namespace. I have overloaded a function to receive a string, integer or double, and defined that in the interface. I'm storing it in XML and don't care about the variable type, so I want to save it as a string each time. I have to build up the xPath a bit, based on class vars, so ideally I want to call the setVal(string, string) function from the others. But, I'm not able to say this.setVal because it claims that my class doesn't have that function. Below is the only way I have been able to get it to work. Is there a better way? namespace company.project.common{ interface MyInterface{ void setVal(string,string); void setVal(string,integer); void setVal(string,double); } } // ------------------- uses company.project.common; namespace company.project.mainapp{ public class MyObject : MyInterface{ void MyInterface.setVal(string key, string value){ string xPath; // code to build xPath, verify the XmlNode exists, etc goes here but is omitted } // str,str // this works, but not sure how efficient? void MyInterface.setVal(string key, int value){ MyInterface b = this; b.setVal(key, value.ToString()); } // str,int // this does not work, but does in VB void MyInterface.setVal(string key, double value){ this.setVal(key, value.ToString()); } // str,2x } } so is that the best way of doing it? and if so, is there a term for this? sorry if that's a total noob question, I browsed around here and google and can't find anything on it.
  10. After I posted my reply to beau, I got to thinking... I work in a wierd environment, and there typically are no small projects. So that is the reason that I tend to lean to the OOP side. And my first reaction was post-war trauma syndrome, thinking back to the pages upon pages of proc code I've had to dig through... but then I remembered that there have been a few apps where to add OOP would have been silly. So mskeel, your quote about the right tools is right on with that, thanks for the reminder. PD thanks for the suggestions on the code review, that makes sense sounds like they'll work and I'll give that a shot. I've been working on the Head First Design Patterns book, tasty! They do a good job of making sure you learn it too, if you follow the instructions. Another nice thing about it is it had been several years since I used java; that got that back in my system, and also gave me the push to do more in c#. Anyway, I'm out for a week or so, thanks to all for your comments and suggestions, I really appreciate it. au
  11. PD, thanks for your reply. First off, I saw a link a while ago to *** in this forum and try to check it out regularly. I have to admit that while I personally am not on there, some of my previous thoughts were, so that has been a bit of a humbling experience! I like your first comment on the code reviews. Since there has only been myself plus one, this has been simple, and happens all the time. Since more people are involved I could see how this would be easy to overlook though. I could see myself trying to spend time with just that developer instead of everyone together at the same time. So I will work on bringing everyone together to review code and the designs, including mine. On the XP, I have seen it mentioned here and there and looked into it a bit in the past. I know that the basic idea is to break it down into small, meaningful steps that can be deployed and tested as you go. I don't know much else about it other than that, so I better look into that. Thanks for the tip. I'm curious, what's your feeling about OOP? As I said in my reply to beau, I think it is very powerful and easy enough to explain if you keep everyone involved in the entire process. I could see how this possibly takes a little longer up front, but I have personally seen that it saves time in the long run. mskeel, if you're still watching this, do you have an opinion on the OOP? Just as a note, I learned procedural first. It took me a while to begin to grasp OO, but I remember sitting in class one day and it just clicked.
  12. beau, there's a few things you said that really stood out to me. One is "...that basically just serves to prove how clever you are." I made that mistake early on, and many of times. I finally read a quote by someone that said something along the lines of code is twice as hard to debug as it is to write, so if you write something that is the most complex you can write, you won't be able to debug it. So I've been working on keeping it simple, but that is definitely an easy pitfall. As for the researching, I don't mean a new product, I mean some new widget that Microsoft has included in the visual studio. And by researching/learning I meant putting that to use in code, if it makes sense. An example would be generics, or threading, or whatever... list goes on. And a lot of that, I have left up to my assistant (I have had one developer working for/with me for a while, and I noticed inefficiencies on my part there... that's what really prompted me to post this). So I do see your point here, stay focused on code and try not to be distracted by shiny new tools. For the most part, I have done that, but your bringing that to my attention will definitely help me stay focused on it. OOP. I'm not saying that I'm right, but I currently disagree with you on this. I do see your point, however. But the reason I disagree is this... I am a huge believer and supporter of OOP. When you understand it (again assuming I didn't get carried away on the design) it makes code easy to debug and maintain. I have fought through way too much procedural code. But I also don't take the approach of disappearing into an office or cave and coming out with some crazy design... I have involved my assistant throughout the entire process, explaining my ideas and taking feedback and input on them. So to date, I do feel that OOP has worked for me. But I hear your points and will keep those in mind.
  13. Re: Project Management Approaches Thanks for the reply! From your examples, I would say I have been trying a blend between both, and that's probably why I'm struggling. I just ordered both the books and i'll definitely check those out, thanks again for the tips and links!
  14. I�m looking some pointers, advice, suggestion, etc. I am having a hard time balancing it all, and am curious what methods work best for everyone out there. Up until now it has been myself plus one, and I have had the lead role. That person is very fast, but also very impatient, so I have found myself having to be more detail-oriented than I would like. That also means that there are a lot of concepts and tasks that I have to have intimate knowledge of. While I definitely enjoy learning new concepts, that also takes a lot of time. (I am not comfortable with just doing something because it works... I like to understand why) Along with this, it means that I typically have to tackle the more complex tasks. And the more I do of that, the less time I have to stay focused on the big picture, which slows me down and the whole project down. Looking back on it, I�m guessing if I allocated a certain amount of time each week for researching the unknowns and new topics, and started that as soon as they arise, that I would be spending less time reacting to the issues in the end, but I�m not sure. Going forward, I will be working with the current developer plus two others, and I will have the lead role. What I�m really looking for is any tips that you may have that you found work well, and why. If it seems like a common sense thing, please mention it anyway. I know going into this, because of my knowledge of the product we're writing the software around, that I'm going to have to write some portions of the code. For others who are in this situation or have been in this situation, do you have any pointers? Here are some specific questions I have: How much code do you write, percentage-wise, versus how much you assign? Is there certain code that you prefer to write versus hand off? How many new topics are you comfortable taking on in a package? Do you have any rules on how you spend your time, ie design, writing code, reviewing code, researching new topics? Outside of that I'll take any other tips or suggestions that anyone may have as well. TIA!
  15. on the access vs SQL question (assuming you're doing it yourself)... The biggest thing I can suggest is make sure you use the n-Tier layout. The most important part of this is you want an object to handle the communication between your database(s) and your client application. We'll call that DatabaseHandler for this post. The reason this is important is because you expose methods in your DatabaseHandler class to your Client app to pass you information, and then DatabaseHandler determines which database to read/write from. It's sole purpose is receive input from the client, determine which database it should talk to, pass it on to that database, and vice versa. Then the last thing you need is a class for each Database, ie one for XML, one for SQL, etc, and you'll want to set up read/write functions with the same signature. Leave it up to that class to determine how to communicate with it's actual database, but what I'm saying is have XML.setInfo(key: String, value: String) and SQL.setInfo(key: String, value: String) You see where I'm going with that? What that allows you to do is integrate or remove any database at any time, assuming you keep the database's signature the same, without affecting your client application. It does take a little more design the first time, but what you end up with is something you can drop in to just about any database project from this point forward. SUMMARY: Client/GUI <--> Database Handler <-- Databases (SQL, Access, XML, etc) Now, on to the SQL. SQL isn't too hard to set up. Ideally you want to run it from your server, or set up a dedicated machine, like an old paperweight desktop. Wipe it out and put the bare minimum on it. You'll gain a lot of stability, scalability, speed, etc from doing that. edit: Again, that's ideally. You could run it from anyone's machine; I actually have mine on our test bench right now...(gasp!)... prolly shouldn't have admitted that How many people do you expect to be using it? FYI I'm fairly certain GnuCash lets you have multiple people use it at the same time... but again, I'd really spend a day or two checking it and/or other open source solutions out, because they've done all the work for you.
  16. i think this is what you're looking for: http://p2p.wrox.com/topic.asp?TOPIC_ID=37585 and/or http://richnewman.wordpress.com/2007/04/15/a-beginner%e2%80%99s-guide-to-calling-a-net-library-from-excel/
  17. I'm not trying to steer you away from Visual Studio, although both these thoughts may make you think that. And I'm no expert on either of these, so just throwing these out as options: 1. I'm not an accountant but have Quickbooks experience. Recently I started using GnuCash, which is an open source competitor to Quickbooks. All I'm doing with it is managing incomes/expenses on a couple things I have going, and I like it so much better than Qb. That being said, read the "Recently I started using..." part; But, you may want to spend a day or two with it to see if it will min checking it out see if it will meet your needs, or how easy/difficult it is to change. There may even be templates/reports out on the web, I dunno, I haven't searched. Here's a link: http://www.gnucash.org/ 2. If GnuCash (or anyone else's apps for that matter) doesn't meet your needs, have you considered AJAX? It's not a language, but rather a technique combining Java and XML to serve your web pages. I would imagine that if Access can handle the amount of data you're wanting, you can also handle it in XML fairly easily. About: http://en.wikipedia.org/wiki/Ajax_%28programming%29 Tutorial: http://www.w3schools.com/ajax/default.asp
  18. not sure i understand this right... is this correct: you have a form that you have divided into three sections (Main Form) you want to add controls to the Main Form to control the IFrame in the IFrame you're wanting to list the events, guessing manipulated by the controls on the main form? can you provide a code sample of what you're trying, and maybe a screenshot?
  19. just a quick fyi, when you have a combobox that you have added objects to, you have two options for setting that combobox to the specific object you want. 1. use .SelectedItem = myobject, and myobject must be an object in the list of items you added to the combobox 2. use .Text = mytext, where that matches the ToString of one of your objects. so likewise, when the user changes a combobox, you can get the object via .SelectedItem, or you can get the ToString property of it by saying cbo.Text. now for the binding, since you're overriding ToString with Me.Text, and you're wanting the Value instead, you're going to need the cbo.SelectedItem.Value property. Whether or not you're able to bind that, I'm not sure. I don't use binding b/c i received a few lectures that it was bulky and slows down large apps, so I never pursued it any further. (Instead, on the SelectedIndex_Chaned event for the combobox, i capture the .SelectedItem and then update my table. If your combobox name matches your column's name, you can do this with one handler)
  20. i see there are a couple things going on here... First, XML is case sensitive. In your sample, you have two nodes of <Text> and one of <text>. so if you did ("//text") you would only get one node in your XmlNodeList. Second, check out this quick ref for help on your xPath syntax. http://www.w3schools.com/xpath/xpath_syntax.asp specifically, you have errors with the double slashes "//" those mean any node anywhere in the document. when you want to select a first gen child to the current node, drop the slashes. so, for example if you had: <ROOT> <header> <table> <text /> <url /> </table> </header> <header> <table /> <table /> <table /> </header> </ROOT> you would want // this will return two nodes // you can use ("//header") if you know all of your headers are direct children to your ROOT node. otherwise do this: foreach (XmlNode header in d.SelectNodes("//ROOT/header")) { // first header node, this returns one table node // second header node, this returns three table nodes foreach (XmlNode table in header.SelectNodes("table") { string itemText = items.SelectSingleNode("text").InnerText; string itemUrl = items.SelectSingleNode("url").InnerText; } } and finally, because I'm lazy and don't want to 2x post, check out the tools and tutorials here: http://www.xtremedotnettalk.com/showthread.php?t=100572 hope that helps!
  21. Also, here's some handy XML links. A few good, semi-short tutorials: http://www.w3schools.com/xml/default.asp http://www.w3schools.com/xpath/default.asp A quick-ref for XPath query syntax, part of the xpath tutorial above: http://www.w3schools.com/xpath/xpath_syntax.asp And finally, an extremely handy tool, jEdit. It's an open source extensible text editor, and does wonders with Xml Docs. Get it here: http://www.jedit.org You'll want these plug-ins at a minimum: XML checks your xdoc for correct structure, adds text coloring, etc. XQuery Plugin lets you run queries against xdocs and displays the outputs; a few different options for source doc and output location. Yes, Plugin is part of it's name ;-) SideKick displays your xdoc in a tree Beauty auto-indents your document BufferTabs adds a little more control and nice features to the buffer Some of those have other required plugins, obviously take them as well. It will tell you on the site. And finally, sorry if you already knew all of this and I overexplained it.
  22. i haven't done anything with xml and webpages yet, but have some experience with xml, so I'm going to take a stab at the xml part only. You'll need help from someone else on the web part. Not sure how much Xml experience you have so I'm going to over-explain this. if your x file is as above, meaning you're not nesting groups inside of groups, then all you need is an xml node list, and you're not going to need recursion. In your file specifically, "AppParameters" is your root node. So, to select every child node to that, you say: 'load xdoc, etc here ... 'this part gets your root node; XML IS case sensitive!!! Dim xn as XmlNode xn = xDoc.selectSingleNode("//AppParameters") 'this part gets the child nodes. each child will include all subnodes, 'so it will look like this: '<Global> ' <Para.... '</Global> Dim xl as XmlNodeList xl = xDoc.ChildNodes 'Now you can iterate through each node: For each xn in xl ' do your display work here Next xn If you sometimes have grandchildren that are also groups, then you're going to have to use recursion, but i'm skipping that for now. If you do have that and run into problems, let me know.
  23. it's been a while, but we had to write something to export to excel. when I say we, I mean I had nothing to do with it, I tasked it out and let someone else handle it. ;-) but here's the important stuff in VB 2003 hope this helps as a starting point Imports System.IO Imports Microsoft.Office.Interop Imports System.Runtime.InteropServices ... Dim oXl As New Excel.Application Dim oWb As Excel.Workbook Dim oWs As Excel.Worksheet Dim fl As FileInfo = New FileInfo(sbPath.ToString) If fl.Exists = True Then Kill(sbPath.ToString) oXl = New Excel.Application oWb = oXl.Workbooks.Add(sbPath.ToString) ... wkIndex = 1 oWs = oWb.Worksheets(wkIndex) 'which worksheet in the workbook ... oWs.Cells(rowIndex, colIndex) = value ... oWb.SaveAs(sbPath.ToString) ...
  24. if you put a breakpoint and inspect the xdoc in memory, you'll see that it's there. however, that's only in memory so you need to save your changes using: doc.save(path) after you have appended the frag
  25. here's what Amir was talking about. when you add an item, it will allow you to add objects. so create a basic object for your "items", then add it. dim o as New InfoObject o.setName = "myname" o.setValue = "myvalue" cbo.items.add(o) For your InfoObect, you will want get/set functions (or use properties if you can so you can just say o.name="myname" You will also need to override the toString function and return what you want it to display. For example: Public Overrides Function toString() as String return me.name End Function in this case, your combobox will display the name of your object in the list Finally, what this results in is if you ask the combobox for its "SelectedItem" it will return an object of the type you added, so in this case InfoObject. so you can say o = cbo.selectedItem name = o.getName value = o.getValue
×
×
  • Create New...